Diff between 9b2500ee0ac711cfa7c742f8f8799b655f04f097 and 4f5290a2a3449e1138b882028999d7f368bcbdf4

Changed Files

File Additions Deletions Status
emulator/bthost.c +36 -3 modified

Full Patch

diff --git a/emulator/bthost.c b/emulator/bthost.c
index e724c2d..d0d1830 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -434,6 +434,37 @@ static bool l2cap_conn_req(struct bthost *bthost, uint16_t handle,
 	bthost_l2cap_cmd(bthost, handle, BT_L2CAP_PDU_CONN_RSP, ident, &rsp,
 								sizeof(rsp));
 
+	if (!rsp.result) {
+		struct bt_l2cap_pdu_config_req conf_req;
+
+		memset(&conf_req, 0, sizeof(conf_req));
+		conf_req.dcid = rsp.dcid;
+
+		bthost_l2cap_cmd(bthost, handle, BT_L2CAP_PDU_CONFIG_REQ, 0,
+						&conf_req, sizeof(conf_req));
+	}
+
+	return true;
+}
+
+static bool l2cap_conn_rsp(struct bthost *bthost, uint16_t handle,
+				uint8_t ident, const void *data, uint16_t len)
+{
+	const struct bt_l2cap_pdu_conn_rsp *rsp = data;
+
+	if (len < sizeof(*rsp))
+		return false;
+
+	if (le16_to_cpu(rsp->result) == 0x0001) {
+		struct bt_l2cap_pdu_config_req req;
+
+		memset(&req, 0, sizeof(req));
+		req.dcid = rsp->dcid;
+
+		bthost_l2cap_cmd(bthost, handle, BT_L2CAP_PDU_CONFIG_REQ, 0,
+							&req, sizeof(req));
+	}
+
 	return true;
 }
 
@@ -453,9 +484,6 @@ static bool l2cap_config_req(struct bthost *bthost, uint16_t handle,
 	bthost_l2cap_cmd(bthost, handle, BT_L2CAP_PDU_CONFIG_RSP, ident, &rsp,
 								sizeof(rsp));
 
-	bthost_l2cap_cmd(bthost, handle, BT_L2CAP_PDU_CONFIG_REQ, 0, req,
-								sizeof(*req));
-
 	return true;
 }
 
@@ -529,6 +557,11 @@ static void l2cap_sig(struct bthost *bthost, uint16_t handle, const void *data,
 						data + sizeof(*hdr), hdr_len);
 		break;
 
+	case BT_L2CAP_PDU_CONN_RSP:
+		ret = l2cap_conn_rsp(bthost, handle, hdr->ident,
+						data + sizeof(*hdr), hdr_len);
+		break;
+
 	case BT_L2CAP_PDU_CONFIG_REQ:
 		ret = l2cap_config_req(bthost, handle, hdr->ident,
 						data + sizeof(*hdr), hdr_len);