Skip to content

Commit

Permalink
Bluetooth: ATT: Set correct MTU for EATT L2CAP channel
Browse files Browse the repository at this point in the history
The EATT MTU in Zephyr is static. We know it at channel creation time,
so we should communicate the MTU as part of channel creation.

Side note: With this approach, it should no longer be neccessary or
useful to do a channel reconfigure.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
  • Loading branch information
alwa-nordic authored and carlescufi committed Apr 24, 2023
1 parent 3de6f7c commit af5103b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions subsys/bluetooth/host/Kconfig.l2cap
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ config BT_L2CAP_TX_MTU
int "Maximum supported L2CAP MTU for L2CAP TX buffers"
default 253 if BT_BREDR
default 69 if BT_MESH_GATT
default 66 if BT_EATT
default 65 if BT_SMP
default 64 if BT_BAP_UNICAST_SERVER || \
BT_BAP_UNICAST_CLIENT || \
Expand All @@ -39,6 +40,7 @@ config BT_L2CAP_TX_MTU
BT_BAP_BROADCAST_ASSISTANT
default 49 if BT_HAS || BT_HAS_CLIENT
default 23
range 66 2000 if BT_EATT
range 65 2000 if BT_SMP
range 23 2000
help
Expand Down
11 changes: 10 additions & 1 deletion subsys/bluetooth/host/att.c
Original file line number Diff line number Diff line change
Expand Up @@ -3250,7 +3250,16 @@ static struct bt_att_chan *att_chan_new(struct bt_att *att, atomic_val_t flags)
chan->att = att;
att_chan_attach(att, chan);

if (!bt_att_is_enhanced(chan)) {
if (bt_att_is_enhanced(chan)) {
/* EATT: The MTU will be sent in the ECRED conn req/rsp PDU. The
* TX MTU is received on L2CAP-level.
*/
chan->chan.rx.mtu = BT_LOCAL_ATT_MTU_EATT;
} else {
/* UATT: L2CAP Basic is not able to communicate the L2CAP MTU
* without help. ATT has to manage the MTU. The initial MTU is
* defined by spec.
*/
chan->chan.tx.mtu = BT_ATT_DEFAULT_LE_MTU;
chan->chan.rx.mtu = BT_ATT_DEFAULT_LE_MTU;
}
Expand Down

0 comments on commit af5103b

Please sign in to comment.