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

packet loss issue with nus service

I am sending IMU data as 20 byte packets through nus service at the rate of 50 such packets per second. The device is a nrf51 DK configured as ble peripheral (S110). The application contains twi to read data from sensor, nus to send data, and uart to print error messages. The packets are labelled with a continuous sequence number.

When using Master Control panel ( windows 7 and Android 5.0 ) to receive data from the nrf51 DK, the sequence numbers are continuous with no missing packets. However, when I use another nrf51 / 52 DK configured as central (S130 / S132) to receive data (ble_app_uart_c), I observe missing sequence numbers showing loss of about more than 50%. The error code being logged is 0x3004, which means buffer overflow in the stack.

What could the problem possibly be?

I was using Keil IDE initially and recently started working with IAR too.

P.S: I've tested those nrf51 / 52 central devices with other ARM based ble SoCs from other vendors implementing the same nus profiles. They seem to work fine without any packet loss in the reception.

  • Hi Dan

    My first thought is that your connection interval is too low. There is a maximum of 6 packets per connection interval. If you are e.g. feeing the softdevice with a packet with 50Hz frequency, but your connection interval is e.g. 200ms, then the packets will pile up in the softdevice and you will have a buffer overflow.

    Update 26.4.2016 As far as I can see, the acceptable connection intervals of the central ble_app_uart_c application is the same as in the peripheral ble_app_uart application, i.e. minimum connection interval of 20ms and maximum connection interval of 75ms. I tried connecting the two devices to see what connection interval is actually present when connecting, and it is 75ms.

    For S130/S132 2.0.x the RX and TX bandwidth is configurable, individually for peripheral and central links. The default configuration for connections as a central is BLE_CONN_BW_MID (both for TX and RX), and for connections as a peripheral it is BLE_CONN_BW_HIGH (both for TX and RX). The BLE_CONN_BW_MID is 3 packets per connection interval max and BLE_CONN_BW_HIGH is 6 packets per connection interval max. So I suspect the central ble_app_uart_c application is limited to maximum 3 packets per connection interval. The result is that you are able to send in one direction 1/0.075*3 = 40 packets per second. Since you are feeding the softdevice with 50 packets per second, it is logical that you will get a buffer overflow.

    So I see two ways of fixing this

    • Change the connection interval for the central device, e.g. min 20ms and max 40ms
    • Change the bandwidth of the central links to BLE_CONN_BW_HIGH

    To see how to change the bandwidth of the central links, look at the s13x_nrf5x_2.0.0_migration-document, chapter about "Configurable bandwidth". The migration document is bundled with the softdevice download file.

  • Thank you for your response, Stefan. My connection interval is currently set to "MSEC_TO_UNITS(8, UNIT_1_25_MS)" which is the least possible value, if I'm right.

    And as I've said above, the central (receiver) works fine with other non-Nordic peripheral devices which implement the NUS in a custom profile. Similarly, the Nordic peripheral works properly with the Master Control Panel, without ANY packet loss.

Related