This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Nordic UART service max data len in nrf52840

Hi I am trying to develop a an application to send data packets over ble using nordic uart service. I wanted to know what is the maximum bytes of data that I can send in one ble transfer. I looked into sdk example ble_app_uart example where I found the variable

m_ble_nus_max_data_len gives maximum length which turns out to be 14 bytes

static uint16_t m_ble_nus_max_data_len = BLE_GATT_ATT_MTU_DEFAULT - 3; This is how the max length is set . I wanted to know if I can increase the length. I also found in one of nrf documentation for ble 5 that length can be 27 bytes for max throughput

  • No, default size of APP layer data over GATT layer is 20 because BLE_GATT_ATT_MTU_DEFAULT is 23. However you can assume all lower layers (including GATT) as transparent transport layers and simply push data through regardless of lower layer fragmentations. That's how Norduc UART Service is meant: push unstructured data over radio similarly how you push UART over wire. Until you have enough bandwidth it will work well. Indeed once you hit the limit of actual link bandwidth you will start to get errors when pushing new data "packets" to BLE stack (Soft Device) GATT API but again that can be handled by your app (e.g. by slowing down the transfer or throwing some data out of the queue). Last but not least you can use two extensions on lower BLE layers to help this bandwidth and fragmentation: ATT_MTU extension (which will increase this BLE_GATT_ATT_MTU_DEFAULT above 23 so you will be able to utilize longer packets already on the highest layer) and LL PDU extension (which will remain hidden under (G)ATT but might lead to higher bandwidth - if you also play with connection interval value a bit).

Related