diff options
author | Marcin Kraglak <marcin.kraglak@tieto.com> | 2014-01-10 10:18:15 +0100 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2014-01-16 12:23:15 +0200 |
commit | 75c7ab2d995a46d3ba439ffbd4ffe2f75bbde9d2 (patch) | |
tree | 17b6da120fb2b7a20dcd46b818233a75b00a9b1d | |
parent | 0c27ca7f4586ac3387343ad5d11fdf745bd8d75d (diff) |
emulator/bthost: Add method to create rfcomm server
It allows user to create rfcomm server on bthost.
-rw-r--r-- | emulator/bthost.c | 32 | ||||
-rw-r--r-- | emulator/bthost.h | 7 |
2 files changed, 39 insertions, 0 deletions
diff --git a/emulator/bthost.c b/emulator/bthost.c index 0f072599b..eb2eb73d5 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -96,6 +96,13 @@ struct l2cap_conn_cb_data { struct l2cap_conn_cb_data *next; }; +struct rfcomm_conn_cb_data { + uint8_t channel; + bthost_rfcomm_connect_cb func; + void *user_data; + struct rfcomm_conn_cb_data *next; +}; + struct bthost { uint8_t bdaddr[6]; bthost_send_func send_handler; @@ -108,6 +115,7 @@ struct bthost { bthost_new_conn_cb new_conn_cb; void *new_conn_data; struct l2cap_conn_cb_data *new_l2cap_conn_data; + struct rfcomm_conn_cb_data *new_rfcomm_conn_data; struct l2cap_pending_req *l2reqs; uint8_t pin[16]; uint8_t pin_len; @@ -260,6 +268,13 @@ void bthost_destroy(struct bthost *bthost) free(cb); } + while (bthost->new_rfcomm_conn_data) { + struct rfcomm_conn_cb_data *cb = bthost->new_rfcomm_conn_data; + + bthost->new_rfcomm_conn_data = cb->next; + free(cb); + } + free(bthost); } @@ -1620,6 +1635,23 @@ void bthost_set_reject_user_confirm(struct bthost *bthost, bool reject) bthost->reject_user_confirm = reject; } +void bthost_add_rfcomm_server(struct bthost *bthost, uint8_t channel, + bthost_rfcomm_connect_cb func, void *user_data) +{ + struct rfcomm_conn_cb_data *data; + + data = malloc(sizeof(struct rfcomm_conn_cb_data)); + if (!data) + return; + + data->channel = channel; + data->user_data = user_data; + data->func = func; + data->next = bthost->new_rfcomm_conn_data; + + bthost->new_rfcomm_conn_data = data; +} + void bthost_start(struct bthost *bthost) { if (!bthost) diff --git a/emulator/bthost.h b/emulator/bthost.h index 5fb7ad4f0..50185a2f2 100644 --- a/emulator/bthost.h +++ b/emulator/bthost.h @@ -89,5 +89,12 @@ void bthost_set_pin_code(struct bthost *bthost, const uint8_t *pin, void bthost_set_io_capability(struct bthost *bthost, uint8_t io_capability); void bthost_set_reject_user_confirm(struct bthost *bthost, bool reject); +typedef void (*bthost_rfcomm_connect_cb) (uint16_t handle, uint16_t cid, + uint8_t channel, void *user_data, + bool status); + +void bthost_add_rfcomm_server(struct bthost *bthost, uint8_t channel, + bthost_rfcomm_connect_cb func, void *user_data); + void bthost_start(struct bthost *bthost); void bthost_stop(struct bthost *bthost); |