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

nrf52 as remote input

Hi

We have project where we want to use a nrf52 in an remote keypad for control various devices.

For investigating the capabilities I have tested the ble_uart and ble_blinky demos for measuring respons times.We want the device to disconnect when not needed and wake-up if a key is pressed for sending the new key state.

ble_uart demo:

From wake-up it takes around 100ms to establish a BLE connection and additional 900ms to establish the NUS service. Hereafter the response time for sending data is 75ms. Not very impressive.

ble_blinky demo:

For somehow the ble_blinky demo is much faster to establish the blinky service, that the ble_uart is to establish the nus service. Around 200ms, but the service is of cause much simpler. By the response time from button press to turning the LED on is between 5 and 35 ms which is fine for the application.

Question:

It seems that it takes very long time to establishing the service (creating characteristics and so on), and we are therefore looking for a more simple method to transport data in connected state. Of cause we could use the advertising packet for transmitting the data, but it is not as reliable than using connected state. So, is there a method to transmit data in connected state without establishing a service? We would like to have a response time below 50ms.

BR

Kasper

  • Hi,

    How familiar are you with the BLE protocol? In general, latency issues like this all boil down to how BLE works. Quickly explained:

    Before connection, your peripheral sends advertising packets at regular intervals. The length of this interval is directly linked to how fast your central will discover and connect to a your peripheral. In the SDK examples you can tweak the advertising interval using the the APP_ADV_INTERVAL definition in main.c. Here is an informative blog post: https://devzone.nordicsemi.com/b/blog/posts/bluetooth-smart-and-the-nordics-softdevices-part-1

    After you have connected your devices they keep communicating at regular intervals called connection intervals. Once again, the bandwidth is directly linked to how short these intervals are. You can play around with the intervals by tweaking the MAX/MIN_CONN_INTERVAL defines in the examples. Note though, that not all devices support the same connection intervals which leads to a difference in performance across devices. Here is another informative blog post: https://punchthrough.com/blog/posts/maximizing-ble-throughput-on-ios-and-android

    From wake-up it takes around 100ms to establish a BLE connection and additional 900ms to establish the NUS service.

    900ms sounds like a lot. How do you measure this? 

  • Hi,

    I have worked a lot with the SDK, but I have not focused on what happening in the air. All time measurements are made with an oscilloscope, and the events are "visualized" by toggling some unused IO pins.

    I have tried to tune the parameters like APP_ADV_INTERVAL and MAX/MIN_CONN_INTERVAL, but these parameters only have effect in the period before the actual connection. 

    Hereafter (I expect) there is a period where the central device queries which services available on the peripheral device. following by the setup of the characteristics. And all this takes time.

    I tried to setup the nFR Sniffer V2 to investigate which part was the time consuming. But I cannot get Wireshark show the packets, despite that the interface is correctly found. :-(  Somehow it was easier with V1 of the sniffer.

    So my question is stille the same, but it might be more BLE related than nRF SDK related: Is it possible to exchange small amount of data in connected state without setting up a service?

    Kasper

  • Hi,

    APP_ADV_INTERVAL is effective before connection, MAX/MIN_CONN_INTERVAL are effective during a connection. As you have understood these intervals are critical and the interval is directly proportional with latency. Latency is a critical issue in many applications though, so there are many strategies. I suggest that you have a look at the ble_app_hids_mouse / keyboard examples. They use tight connection parameters and also utilize what is called highy duty cycle directed advertising specifically to reduce the time it takes to connect. 

    Is it possible to exchange small amount of data in connected state without setting up a service?
    No, if you want to use BLE you will have to use services. However, the initial exchange of service information (called a Service Discovery) only needs to happen once. It is possible for a device to store all the relevant information in persistent memory and skip the service discovery to save time and energy. This process is called bonding. If you use bonding and directed advertising as mentioned above, you can make applications with very low latencies.

    Martin

Related