I'm working with a BLE peripheral application that must transfer large amounts of data to a phone central. The application uses the MTU negotiation to determine the max notification size it can send. I ran into a problem where the BLE stack reported a TX MTU or 517 when connected to a Pixel 7 Pro, but if I try and send a gatt notification of size 517 (513 + 4 byte header), I get an error from the ATT stack:
BLE: Updated MTU: TX: 517 RX: 247 bytes
...
bt_att: No ATT channel for MTU 517
bt_gatt: No buffer available to send notification
If I clamp the max size of the message fragments to CONFIG_BT_L2CAP_TX_MTU=498 then the notification goes through. My impression was that the ATT layer is allowed to send any data equal or under the size of the negotiated TX MTU but it seems like this isn't the case. I also thought that the L2CAP layer is responsible to fragmentation and reassembly of incoming and outgoing messages in which case the L2CAP MTU should be abstracted away from the ATT layer. Is CONFIG_BT_L2CAP_TX_MTU actually just the MTU between the ATT and L2CAP layer and not the L2CAP <-> HCI?
One other weird thing I noticed was that in the ble gatt tester in btp_gatt.c, the max notification size is set like so: