Diff between 90fd2a2f98258749ae105c519c18e686b597ef8f and 287c075913ab28f01681f96d6312de63bf2f3091

Changed Files

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

Full Patch

diff --git a/emulator/bthost.c b/emulator/bthost.c
index afdc3a8..59a6b8d 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -1552,6 +1552,41 @@ static void rfcomm_ua_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 (!channel && RFCOMM_TEST_CR(RFCOMM_GET_TYPE(hdr->control)) &&
+						 bthost->rfcomm_conn_data) {
+		uint8_t buf[14];
+		struct rfcomm_hdr *hdr = (struct rfcomm_hdr *)buf;
+		struct rfcomm_mcc *mcc = (struct rfcomm_mcc *)
+							(buf + sizeof(*hdr));
+		struct rfcomm_pn *pn_cmd = (struct rfcomm_pn *)
+							(buf + sizeof(*hdr)
+							+ sizeof(*mcc));
+
+		memset(buf, 0, sizeof(buf));
+
+		hdr->address = RFCOMM_ADDR(1, 0);
+		hdr->control = RFCOMM_CTRL(RFCOMM_UIH, 0);
+		hdr->length  = RFCOMM_LEN8(sizeof(*mcc) +
+							sizeof(*pn_cmd));
+
+		mcc->type = RFCOMM_MCC_TYPE(1, RFCOMM_PN);
+		mcc->length = RFCOMM_LEN8(sizeof(*pn_cmd));
+
+		pn_cmd->dlci = bthost->rfcomm_conn_data->channel * 2;
+		pn_cmd->priority = 7;
+		pn_cmd->ack_timer = 0;
+		pn_cmd->max_retrans = 0;
+		pn_cmd->mtu = 667;
+		pn_cmd->credits = 7;
+
+		buf[sizeof(*hdr) + sizeof(*mcc) + sizeof(*pn_cmd)] =
+							rfcomm_fcs(buf);
+
+		send_acl(bthost, conn->handle, l2conn->dcid, buf, sizeof(buf));
+	}
 }
 
 static void rfcomm_dm_recv(struct bthost *bthost, struct btconn *conn,