BLE Data Fragmentation and Layers

Hi, I am trying to understand how BLE data is fragmented and how I can send large amounts of data over BLE.

I have log files that I want to send from an nRF54L15 to a mobile app, let's say these log files are 20 KB.

My understanding is the normal largest MTU size if 247, which actually ends up being 244 bytes of data.

I will be sending my data on the Notify of a custom BLE service and characteristic.

Do I need to fragment my 20 KB log into 244 byte pieces in my application code? This seems like it would require some flow control and be more complex.

Is there a way to get the BLE stack to fragment my data automatically into the 244 byte MTU size.

Additionally, if my L2CAP data size is smaller than the MTU size, will the stack automatically fragment MTU packets into L2CAP data sizes?

I have briefly tried to do this and get the following error codes:

[473364:01:22.000,000] <wrn> bt_att: No ATT channel for MTU 293

[473364:01:22.000,000] <wrn> bt_gatt: No buffer available to send notification

The following ticket mentions fragmenting GATT data at the application layer, but that GAP data is automatically fragmented by the BLE stack:  How to fragment the BLE Data 
Is there a way for me to send my data through the GAP layer so it is automatically fragmented?

  • Yes, if you want to send data, using GATT notify, you have to first, figure out, what the actual, negotiated MTU size is (could be less than 247, even when your peripheral supports that size, there is no guarantee, that you central supports that size too). After that, you could send out the log file in parts of MTU size -3 (one byte opcode and 16 bit ATT attribute handle). If you are sure, that there is no chance that notifications get lost on the receiving side, you probably need not much of a protocol (maybe log size at the beginning).

    For efficiency, you should make sure, that your peripherals link layer supports Data Length Updates. Otherwise, your large ATT PDUs will be fragmented into very much small LL SDUs.

    Alternatively, you could open a user L2CAP channel and send that file directly, using L2CAP, then you do not need any application support for the fragmentation. But make sure, that all centrals you need to support actually have an API to access the L2CAP protocol layer.

    If you really mean to send data through GAT (not GATT), then you are probably talking about sending data through advertisments.

Related