diff --git a/emulator/bthost.c b/emulator/bthost.c
index 0f07259..eb2eb73 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
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;
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;
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);
}
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 5fb7ad4..50185a2 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
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);