Skip to content

Commit cd43e03

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: classic: shell: Support L2CAP channel seg_recv
Add the callback function `seg_recv` if the configuration `CONFIG_BT_L2CAP_SEG_RECV` is enabled. Signed-off-by: Lyle Zhu <[email protected]>
1 parent df1e226 commit cd43e03

File tree

1 file changed

+17
-1
lines changed
  • subsys/bluetooth/host/classic/shell

1 file changed

+17
-1
lines changed

subsys/bluetooth/host/classic/shell/bredr.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
static struct bt_conn *pairing_conn;
3838
#endif /* CONFIG_BT_CONN */
3939

40-
#define DATA_BREDR_MTU 48
40+
#define DATA_BREDR_MTU 200
4141

4242
NET_BUF_POOL_FIXED_DEFINE(data_tx_pool, 1, BT_L2CAP_SDU_BUF_SIZE(DATA_BREDR_MTU),
4343
CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL);
@@ -311,11 +311,27 @@ static struct net_buf *l2cap_alloc_buf(struct bt_l2cap_chan *chan)
311311
return net_buf_alloc(&data_rx_pool, K_NO_WAIT);
312312
}
313313

314+
#if defined(CONFIG_BT_L2CAP_SEG_RECV)
315+
static void seg_recv(struct bt_l2cap_chan *chan, size_t sdu_len, off_t seg_offset,
316+
struct net_buf_simple *seg)
317+
{
318+
bt_shell_print("Incoming data channel %p SDU len %u offset %lu len %u", chan, sdu_len,
319+
seg_offset, seg->len);
320+
321+
if (seg->len) {
322+
bt_shell_hexdump(seg->data, seg->len);
323+
}
324+
}
325+
#endif /* CONFIG_BT_L2CAP_SEG_RECV */
326+
314327
static const struct bt_l2cap_chan_ops l2cap_ops = {
315328
.alloc_buf = l2cap_alloc_buf,
316329
.recv = l2cap_recv,
317330
.connected = l2cap_connected,
318331
.disconnected = l2cap_disconnected,
332+
#if defined(CONFIG_BT_L2CAP_SEG_RECV)
333+
.seg_recv = seg_recv,
334+
#endif /* CONFIG_BT_L2CAP_SEG_RECV */
319335
};
320336

321337
#define BT_L2CAP_BR_SERVER_OPT_RET BIT(0)

0 commit comments

Comments
 (0)