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

How to confirm that all packets are received over BLE - nRF52840 SDK16

Hi everyone,

I have created a custom BLE service with a characteristic and I update the custom value after enabling notifications by calling the ble_cus_custom_value_update function when the app_timer expires. So far it works great and I update the value with a frequency of 1Hz.  Now I have to update the value with a frequency of 100Hz (10ms).

How could I verify that no data are lost and the custom value is updated every 10ms? I want to ensure that central receives all the packets.

Thanks in advance

Nick

  • Hello Nick,

    How could I verify that no data are lost and the custom value is updated every 10ms? I want to ensure that central receives all the packets.

    First off all, you will need to set your connection interval to 10 ms for the BLE communication to happen often enough. If you are connecting to a smartphone central you should also ensure that the smartphone supports the specified connection interval - some older versions of Androids/iOS does not support < 15 ms, for example.

    For checking that the value is updated often enough: are you familiar with using the nRF Sniffer? It will allow you to monitor all ongoing BLE Traffic - which would easily verify that the data is being sent at the correct interval.
    Keep in mind that the sniffer might get packets that never arrive at the central, and vice verse.
    You could also add an NRF_LOG_INFO statement on the central side, so that you may see a timestamp for ever received packet.

    For completeness, I will also mention that packet loss/corruption is possible in BLE communication, and depends heavily on the environment in which the devices are operating in. In an environment with low wireless interference and direct line-of-sight between devices it should not be a problem.

    Best regards,
    Karl

  • Thank you Karl for your advice!!

    I do not have experience with nRF sniffer but I know that it is a very useful tool so I will give a try. As you said, at least I will be able to verify that the data are being sent correctly. Also, I will verify that central support a connection interval of <10ms

    However,  I have two questions:

    1. I have built my app based on the ble_peripheral -> ble_app_template example (SDK16). To set the connection interval to 10ms I have to configure the MIN_CONN_INTERVAL? Something like this?

    #define MIN_CONN_INTERVAL               MSEC_TO_UNITS(10, UNIT_1_25_MS)        
    #define MAX_CONN_INTERVAL               MSEC_TO_UNITS(200, UNIT_1_25_MS)       

    It is better to set the connection interval less than 10ms e.g. 9ms

    2. At the moment I am using nRF dongle with nRF Connect as central. Is it possible to add an NRF_LOG_INFO at nRF connect, or in general, is it possible to keep track of the received packets and their associated timestamps?

    Thanks in advance

    Nick

  • Nikosant03 said:
    Thank you Karl for your advice!!

    No problem at all Nick, I am happy to help!

    Nikosant03 said:
    I do not have experience with nRF sniffer but I know that it is a very useful tool so I will give a try.

    Great! It is indeed a very useful tool when working with BLE.

    Nikosant03 said:
    1. I have built my app based on the ble_peripheral -> ble_app_template example (SDK16). To set the connection interval to 10ms I have to configure the MIN_CONN_INTERVAL? Something like this?

    Both yes and no - you minimum connection interval is correct, but your maximum connection interval is still 200 ms.
    Keep in mind that the peripheral specifies a connection interval(a range of possible connection intervals really), but it is actually the central that determines which interval to use - within the specified range.With your current configuration you may end up with "any" connection interval between 10 - 200 ms.
    As such, you should set both MIN_ and MAX_ to 10 ms, to ensure that the central will choose 10 ms intervals.

    Nikosant03 said:
    It is better to set the connection interval less than 10ms e.g. 9ms

    Is this a question? You may have the connection interval be 8.75 ms instead, but it would not mean much of a difference for your application, since new data will only be available every 10 ms.
    In general, shorter connection intervals means higher throughput through more radio time, but in turns also increase current consumption.

    Nikosant03 said:
    2. At the moment I am using nRF dongle with nRF Connect as central. Is it possible to add an NRF_LOG_INFO at nRF connect, or in general, is it possible to keep track of the received packets and their associated timestamps?

    Ah, sorry, it seems my last reply was inaccurate on this matter.
    If you are using nRF Connect then you should see a log with timestamps at the bottom of the application window. This log will log any notifications about changed characteristic values - so you may use this to monitor value update intervals.

    Best regards,
    Karl

Related