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

ble_app_uart ATT MTU size configuration

Hi, guys. I'm using two PCA10040 boards. One is using the ble_app_uart__saadc_timer_driven__scan_mode example

github.com/.../main.c

and the other board is flashed with the BLE NUS Scanner (central) example from SDK 15.2.0.

Since the peripheral is sampling ADC data, I wish to set a higher throughput.

devzone.nordicsemi.com/.../throughput-and-long-range-demo

ATT MTU size: ATT Maximum Transmission Unit is the maximum length of an ATT packet. A write, read, notification or indication packet will have a 3-byte header including the OP-code (operation, 1 byte) and the attribute handle (2 bytes). The rest will be attribute data. The default size of the ATT MTU is 23 bytes, but the SoftDevice allows for sizes up to 512. In this demo you can choose between 23 bytes, 158 bytes and 247 bytes. A larger packet will have less overhead (header per effective data) and will therefore lead to higher throughput.

...

The throughput measured may vary depending on the environment, but the maximum throughput should be around 1365 Kbps for BLE 5 High Speed, 775 Kbps for BLE 4.2, 128 Kbps for BLE 4.1 and 21.3 Kbps for BLE 5 Long Range. Be aware that there may be some inaccuracies in the measurements.

May I ask,

0. "the SoftDevice allows for sizes up to 512." When using this ADC + UART example, regarding that the peripheral will be connected to another PCA10040 central, can I set my peripheral to allow for sizes up to 512 bytes?

If not, what is the maximum for the nRF52832?

1. What function do I have to call in order to set my desired size (ATT MTU 512 bytes)?

2. If I change the size to 512 for instance, can I set the length for the NUS data up to 512 when I call the `ble_nus_data_send` function?

3. About the throughput, this example samples 4 ADC channels (12-bit). If I change the size to 512 for instance,

should I fill 512 bytes (4 channels * 12-bit to 2-byte separation* 64 sampling) to get better throughput, instead of sending 8 bytes of data after each sampling tasks?

4. Lastly, do I have to modify the NUS Central example to get the 512 bytes?

I wasn't sure whether I have to set the ATT MTU settings from the central side.

Similarly, when using mobile apps (iOS, Android), do I have to configure on the mobile central side to get 512 bytes?

-Thanks

Parents
  • If you look at the peripheral BLE examples you can find that most of them use gatt_init(), which will upon connection exchange max MTU sizes, you can get the result of the max supported MTU size by looking at the callback handler: gatt_evt_handler() and the events NRF_BLE_GATT_EVT_ATT_MTU_UPDATED (max attribute size) and NRF_BLE_GATT_EVT_DATA_LENGTH_UPDATED (max on air size, a long attribute may be split across several of these).

    Typically you want the data sent to be as close as possible to the max data length (NRF_BLE_GATT_EVT_DATA_LENGTH_UPDATED) for most efficient transfers.

    Best regards,
    Kenneth

Reply
  • If you look at the peripheral BLE examples you can find that most of them use gatt_init(), which will upon connection exchange max MTU sizes, you can get the result of the max supported MTU size by looking at the callback handler: gatt_evt_handler() and the events NRF_BLE_GATT_EVT_ATT_MTU_UPDATED (max attribute size) and NRF_BLE_GATT_EVT_DATA_LENGTH_UPDATED (max on air size, a long attribute may be split across several of these).

    Typically you want the data sent to be as close as possible to the max data length (NRF_BLE_GATT_EVT_DATA_LENGTH_UPDATED) for most efficient transfers.

    Best regards,
    Kenneth

Children
Related