From c64b9baa9998acec5c11aad02fc0bf10528bec78 Mon Sep 17 00:00:00 2001 From: Marcin Kraglak Date: Fri, 10 Jan 2014 10:18:27 +0100 Subject: [PATCH] emulator/bthost: Call rfcomm_connect_cb when connected This will call connect callback when connected or failed to connect. --- emulator/bthost.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/emulator/bthost.c b/emulator/bthost.c index ec6f6aa52..b66d25322 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -1586,6 +1586,15 @@ static void rfcomm_ua_recv(struct bthost *bthost, struct btconn *conn, rfcomm_fcs(buf); send_acl(bthost, conn->handle, l2conn->dcid, buf, sizeof(buf)); + } else if (bthost->rfcomm_conn_data && + bthost->rfcomm_conn_data->channel == channel) { + if (bthost->rfcomm_conn_data->cb) + bthost->rfcomm_conn_data->cb(conn->handle, + l2conn->scid, channel, + bthost->rfcomm_conn_data->user_data, + true); + free(bthost->rfcomm_conn_data); + bthost->rfcomm_conn_data = NULL; } } @@ -1593,6 +1602,19 @@ static void rfcomm_dm_recv(struct bthost *bthost, struct btconn *conn, struct l2conn *l2conn, const void *data, uint16_t len) { + const struct rfcomm_cmd *hdr = data; + uint8_t channel = RFCOMM_GET_CHANNEL(hdr->address); + + if (bthost->rfcomm_conn_data && + bthost->rfcomm_conn_data->channel == channel) { + if (bthost->rfcomm_conn_data->cb) + bthost->rfcomm_conn_data->cb(conn->handle, + l2conn->scid, channel, + bthost->rfcomm_conn_data->user_data, + false); + free(bthost->rfcomm_conn_data); + bthost->rfcomm_conn_data = NULL; + } } static void rfcomm_msc_recv(struct bthost *bthost, struct btconn *conn, -- 2.47.3