This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Increasing BLE MTU/Data Length For Notifications on NCS v1.8

Hello,

I am new to embedded/BLE development so forgive me for my ignorance on some of these topics. I am creating a fairly simple BLE Peripheral Server device that has a few sensors connected and will notify the Central Client with the sensor values on a regular basis via a GATT service with characteristics for each sensor (it seems like this is the proper way to do this?). I have adapted some of the code from the Zephyr BLE Peripheral sample (albeit simplified) to write my program. The biggest sensor value I have to send is a uint16_t array of length 12 (24 bytes). When I setup notifications for this characteristic I get the following outputs from the NRF terminal and the notifications do not work:

<wrn> bt_att: No ATT channel for MTU 27
<wrn> bt_att: No buffer available to send notification

When I reduce the size of the array to length 6 (12 bytes) then it works properly and notifies without errors. I suspect this problem is due to the ATT and/or Data Length parameters. I have been browsing online and these forums for a few hours today and none of the answers I've found have worked for me. I have tried pasting various things in prj.conf and also attempting to use the "Update MTU" and "Update Data Length" options in the NRF Connect BLE tool once connected but the console output shows that the update does not work and the value stays at 23 or whatever the default is.

So my question is, what is the proper and most simple way to fix this and be able to read and send notifications for a characteristic with data of this size?

For reference, I am using:

NRF Connect SDK v1.8.0 with VS Code

NRF52833DK (the device I'm programming)

NRF52840 Dongle (for the NRF Connect BLE tool)

I would include the code and prj.conf values I've tried so far but there are so many of them it would be long and pointless considering none have worked and some have caused compilation issues. Any example of code and/or configuration options to fix this would be great. If those don't work then I will start attaching my files for everyone to view.

Thanks to anyone who has the time to help!

  • Hi, 

    You could refer to the prj.conf of Bluetooth: Throughput to add the following config settings:

    CONFIG_BT_BUF_ACL_RX_SIZE=251
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_L2CAP_TX_MTU=247
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

    This should increase both the max. MTU size and maximum radio packet length.

    Regards,
    Amanda

  • Thanks for the suggestion Amanda,

    This is one of the setups I tried. It compiles and runs fine but as soon as it connects to another device (NRF5x BLE tool on dongle) it prints the following in the console (from the att_mtu_updated callback):

    Updated MTU: TX: 23 RX: 23 bytes

    So maybe the config settings work at first but then as soon as it connects they automatically change? I remember reading something about a MTU negotiating/updating config setting but I don't think it worked for me when I tried it. Do you know of such a config setting? For reference, here is my current prj.conf:

    CONFIG_BT=y
    CONFIG_BT_DEBUG_LOG=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Device"
    CONFIG_BT_DEVICE_NAME_DYNAMIC=y
    CONFIG_BT_DEVICE_NAME_MAX=65
    
    CONFIG_BT_BUF_ACL_RX_SIZE=251
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_L2CAP_TX_MTU=247
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

    Thanks for the help.

  • Hi, 

    What is the ATT MTU size on another device?

    ATT MTU size is dependent on the device you are connected to. A sniffer trace may also be helpful (nRF Sniffer).

    -Amanda

  • I was using the NRF52840 dongle with the NRFx program uploaded from the NRF Connect BLE tool. Now I reprogrammed it as NRF Sniffer and captured some packets with Wireshark while I connected to the peripheral (NRF52833) from the NRF Connect app on my iPhone. Here is the link to the capture (trimmed to right before connection). To me it seems like the config options did nothing, since the very first packets sent after CONNECT_IND are of length 26 instead of 251 as we tried to configure. However, I may be misunderstanding this, so I look forward to your opinion about this packet capture.

    Thanks

  • Hi, 

    From the sniffer log, the peripheral (NRF52833) send out the request for 251, and the Master responds with 251. The ATT MTU is 251 now. 

    -Amanda

Related