Skip to content

Commit 8a65b3f

Browse files
jori-nordiccarlescufi
authored andcommitted
tests: Bluetooth: don't assume handle is 0
Don't assume the connection handle will always be 0. This is currently the case with the Zephyr link layer, but recently changed in the Softdevice Controller. Another problem is that apparently the spec allows the controller to just blackhole data instead of returning `BT_HCI_ERR_UNKNOWN_CONN_ID` if the host uses a wrong handle. Signed-off-by: Jonathan Rico <[email protected]>
1 parent c022f41 commit 8a65b3f

File tree

1 file changed

+5
-1
lines changed
  • tests/bsim/bluetooth/host/l2cap/split/tester/src

1 file changed

+5
-1
lines changed

tests/bsim/bluetooth/host/l2cap/split/tester/src/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ static K_SEM_DEFINE(cmd_sem, 1, 1);
4141
static struct k_sem acl_pkts;
4242
static struct k_sem tx_credits;
4343
static uint16_t peer_mps;
44+
static uint16_t conn_handle;
4445

4546
static uint16_t active_opcode = 0xFFFF;
4647
static struct net_buf *cmd_rsp;
@@ -123,6 +124,9 @@ static void handle_meta_event(struct net_buf *buf)
123124

124125
switch (code) {
125126
case BT_HCI_EVT_LE_ENH_CONN_COMPLETE:
127+
case BT_HCI_EVT_LE_ENH_CONN_COMPLETE_V2:
128+
conn_handle = sys_get_le16(&buf->data[4]);
129+
LOG_DBG("connected: handle: %d", conn_handle);
126130
SET_FLAG(is_connected);
127131
break;
128132
case BT_HCI_EVT_LE_DATA_LEN_CHANGE:
@@ -488,7 +492,7 @@ static int send_acl(struct net_buf *buf)
488492
uint8_t flags = BT_ACL_START_NO_FLUSH;
489493

490494
hdr = net_buf_push(buf, sizeof(*hdr));
491-
hdr->handle = sys_cpu_to_le16(bt_acl_handle_pack(0, flags));
495+
hdr->handle = sys_cpu_to_le16(bt_acl_handle_pack(conn_handle, flags));
492496
hdr->len = sys_cpu_to_le16(buf->len - sizeof(*hdr));
493497

494498
bt_buf_set_type(buf, BT_BUF_ACL_OUT);

0 commit comments

Comments
 (0)