2019-09-03 01:25 PM
I'm evaluating the STM32WB55 for use in a product which needs to read user input (button press and associated sensor data), and communicate it to another device over BLE.
I'm using a pair of STM32WB55 Nucleo boards to communicate with each other over BLE. I'm using the BLE_p2pClient and BLE_p2pServer example programs as a starting point. I would like to reduce the latency as much as possible for sending notifications between the 2 boards. Currently, I'm able to start both boards and establish a connection between them. The example code is designed such that when you press a button on one board, an LED on the other board changes state. Using a logic analyzer to measure the delay between the button press and the LED changing, I'm seeing times that range from ~70ms to 150 ms. I'm trying to understand what parameters can be changed within the code to affect this time. I see that BLE has a connection interval spec that can range from 7.5ms to 4s. I believe this corresponds to the CONN_P1 and CONN_P2 macros in app_conf.h. However, when I change these from 50 and 100 to 7.5 and 10 on the BLE_p2pClient side, I don't see any affect on the time between a button press and an LED change.
So, several questions -
My goal is to get to a system with a minimum latency, as well as to understand the resulting affect on battery life this would have.
Thanks!
Brian
Solved! Go to Solution.
2019-09-03 08:14 PM
As you mentioned, the connection interval, which can range from 7.5ms to 4s, impacts the latency.
The P2PServer example demonstrates how to change the connection interval after the connection has been established via L2CAP message. The connection interval can be modified from 50ms to 1s and vice-versa using SW2 button, you can take a look at BLE_SVC_L2CAP_Conn_Update() which gets called when SW2 is pressed. In this routine, you'll see how the min and max connection interval gets updated using the aci_l2cap_connection_parameter_update_req() API, so you can change the min and max connection interval to the minimum, 7.5ms, as below inside BLE_SVC_L2CAP_Conn_Update()
uint16_t interval_min = CONN_P(7.5);
uint16_t interval_max = CONN_P(7.5);
Regards,
JT
2019-09-03 08:14 PM
As you mentioned, the connection interval, which can range from 7.5ms to 4s, impacts the latency.
The P2PServer example demonstrates how to change the connection interval after the connection has been established via L2CAP message. The connection interval can be modified from 50ms to 1s and vice-versa using SW2 button, you can take a look at BLE_SVC_L2CAP_Conn_Update() which gets called when SW2 is pressed. In this routine, you'll see how the min and max connection interval gets updated using the aci_l2cap_connection_parameter_update_req() API, so you can change the min and max connection interval to the minimum, 7.5ms, as below inside BLE_SVC_L2CAP_Conn_Update()
uint16_t interval_min = CONN_P(7.5);
uint16_t interval_max = CONN_P(7.5);
Regards,
JT
2019-09-05 08:50 AM
Hi Joe,
Thanks - this worked well! I modified the tab_conn_interval array and can now get a latency down around 10ms.
Brian