Diff between 37a1b0fa3de57c903c6abd164bad5f8eb1dd25e3 and c64b9baa9998acec5c11aad02fc0bf10528bec78

Changed Files

File Additions Deletions Status
emulator/bthost.c +22 -0 modified

Full Patch

diff --git a/emulator/bthost.c b/emulator/bthost.c
index ec6f6aa..b66d253 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,