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

How to reduce the response time of read requests

Hi,

I am working on the heart_rate_collector example code of nrf51-ble-driver_linux_0.5.0. I try to modify the example code let it can connect the Environmental Sensing Service (ESS profile) peripheral.

The ESS peripheral have temperature(Assigned Number: 0x2A6E) and humidity(Assigned Number: 0x2A6F) characteristic. Both of characteristic all support notify property.

When I connect the ESS peripheral and use the "sd_ble_gattc_read" to read its characteristic(such characteristic uuid: 0x2A29). Time between read request and read response is short.image description

But, when the notify function of temperature and humidity characteristic is be enabled, I also use "sd_ble_gattc_read" to read characteristic uuid: 0x2A29. Time between read request and read response is become very long.

image description

I capture this sniffer packet sniffer.pcapng

And then, I use my android smart phone and install "nRF Connect for Mobile" APP to connect the ESS peripheral. Time between read request and read response is always short. (even the notify function of temperature and humidity characteristic is be enabled)

Does anyone have any way to reduce the response time of read requests?

  • The peripheral should queue the notification packet. Could you let me know how do you send the notification ? Adding some code snippet in the question would help. How frequent do you sample data and send data with hvx ? I can see that the connection interval is 1s if you have timer interval shorter than that, you will stack up the queue. If you don't want to use timer, you can use the BLE_EVT_TX_COMPLETE event to queue the next data. BLE_EVT_TX_COMPLETE event return when there is a packet sent in the last connection event.

  • Hi Hung Bui,

    I start a timer and then setting 1s timeout to sample data and and send data with hvx.

    Please see code snippet

    Thanks

    Ryan

  • @Ryan: Could you try to increase the timer to something longer than 1s ? I'm seeing from the sniffer trace that just after the first notification, you already have stacked up the buffer (MoreData (MD) bit was set) . In addition, I'm seeing that you have two function to send notification, humidity_measurement_send and temperature_measurement_send() this will queue two packet per 1 seconds and since you can only send one packet per connection event. It will pile up the queue. If you don't want to increase the timeout to say 2seconds, you can try to change the connection interval to 300ms, so that it would be able to handle your data throughput (2 packet per seconds ). You can think of integrate the 2 characteristics into one if you don't have to many bytes (less than 20 in total) and send one notification for both of them.

    Also please check and make sure you don't have authorization properties on your characteristic. This authorization requires the application to accept before it send the read response back.

  • Hi Hung Bui,

    Thank you for your detailed explanation, I understand the root cause of this issue.

Related