Increasing MTU size on NRF5340

I am in the process of making a custom service for a peripheral I am developing. I have some data that I would like to have in the same characteristic because it will be retrieved and used together on the central side, but I will likely need 21 bytes to do this. As I have understood this there was previously a limit of 20 bytes to characteristics that can be notified, while now we can have up to 251? 

I've seen a few posts about increasing MTU size, but none of them have helped me actually implement the needed size on my NRF5340DK. Without modifying any configurations I get the warning: <wrn> bt_att: No ATT channel for MTU 24.

based on some forum posts I found I need to set these in the network core config:

CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
and 
CONFIG_BT_L2CAP_TX_MTU=247
in the app config. 
Doing this however gives errors when trying to enable bluetooth: 
bt_hci_core: opcode 0x0c33 status 0x11
Bluetooth initialization failed (err -5)
What am I doing wrong?
And is there any good reasons why I should divide my data into 2 characteristics instead of increasing the size?
I am using nrf Connect SDK v2.6.0 and the softdevice controller for the network core.
Parents Reply Children
  • Trying the configs in the examples above, gives me build errors. There seems to have been made changes in configs since the release of v2.6.0?

    CONFIG_BT_ATT_TX_COUNT is "unknown symbol"..
    I changed it to CONFIG_BT_ATT_L2CAP_TX_BUF_COUNT because I see that is what is used in the example I have for 2.6.0.
    I also removed 
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 from the app config because it had missing dependencies.
    Also had to add CONFIG_BT_SMP=y because it was a dependency of
    CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y 
    But what really did the trick was actually adjusting the settings on the central. I was using the nrf connect app to connect and subscribe to the characteristic and I found a setting that says "Auto request maximum MTU". I assume we will have to do something similar on the central side of our application, or can I initiate mtu exchange from the peripheral?
  • Hi,

    RakeLund said:
    Trying the configs in the examples above, gives me build errors. There seems to have been made changes in configs since the release of v2.6.0?

    These configs are supported in v2.6.0. You can check those configs files under  v2.6.0\nrf\samples\bluetooth\throughput

    RakeLund said:
    I assume we will have to do something similar on the central side of our application

    That's true. 

    RakeLund said:
    or can I initiate mtu exchange from the peripheral?

    Yes, see https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-3-bluetooth-le-connections/topic/blefund-lesson-3-exercise-2/ regarding increasing our Data Length and MTU size.

    -Amanda H.

Related