What is the exact maximum data_length I can set to send in BLE?

Hi,

I notice that every time I can only send 244 bytes per time in nus service, if I set higher I will not receive the data in RX. 

But I also see that the thoughput sample we can set data_length to 251.

Which one should be the exact one? Thank you for your help!

Parents
  • Hi Ziyao,

    The NUS service uses the function  `bt_gatt_notify()` to notify subscribers about new data. The amount of data that can be sent at once depends on the MTU.

    This MTU is a bit confusing indeed. I hope am not adding more confusion to the equation. But, to be able to send, for example 512 bytes in one call to `bt_gatt_notify()` we would need to have a MTU of 512+3 = 515 bytes.

    By digging a bit in the code we can conclude that by configuring the following:

    CONFIG_BT_L2CAP_TX_MTU=515
    CONFIG_BT_BUF_ACL_RX_SIZE=519

    on both devices we will get the MTU we want.

    Note that the initial MTU is 23 after a connection is initiated. A MTU negotiation can be triggered manually or automatically. This negotiation is typically initiated by the central node. Configure it like this to make the negotiation automatic:

    CONFIG_BT_GATT_AUTO_UPDATE_MTU=y

    Note also that Data Length Extension is also a term in Bluetooth LE that is worth looking in to if you are interested in high throughput. The throughput example is a perfect starting point to evaluate throughput. Here is another forum post about Data Length Extension: BLE Data Length Extension Usage and Example - Nordic Q&A - Nordic DevZone - Nordic DevZone

    I am sure your favorite search engine can give you more information on this. Good luck!

Reply
  • Hi Ziyao,

    The NUS service uses the function  `bt_gatt_notify()` to notify subscribers about new data. The amount of data that can be sent at once depends on the MTU.

    This MTU is a bit confusing indeed. I hope am not adding more confusion to the equation. But, to be able to send, for example 512 bytes in one call to `bt_gatt_notify()` we would need to have a MTU of 512+3 = 515 bytes.

    By digging a bit in the code we can conclude that by configuring the following:

    CONFIG_BT_L2CAP_TX_MTU=515
    CONFIG_BT_BUF_ACL_RX_SIZE=519

    on both devices we will get the MTU we want.

    Note that the initial MTU is 23 after a connection is initiated. A MTU negotiation can be triggered manually or automatically. This negotiation is typically initiated by the central node. Configure it like this to make the negotiation automatic:

    CONFIG_BT_GATT_AUTO_UPDATE_MTU=y

    Note also that Data Length Extension is also a term in Bluetooth LE that is worth looking in to if you are interested in high throughput. The throughput example is a perfect starting point to evaluate throughput. Here is another forum post about Data Length Extension: BLE Data Length Extension Usage and Example - Nordic Q&A - Nordic DevZone - Nordic DevZone

    I am sure your favorite search engine can give you more information on this. Good luck!

Children
Related