2020-01-29 10:38 PM
Hi,
I am currently using the P2P Server/Client example as a base for one of my projects. The server is constantly sleeping, waking up and reconnecting. After connecting the Services & Characteristics have to be rediscovered and notification re-enabled before data can be sent. This is taking a few seconds and is causing data to be lost. What steps can I take to reduce the time for the connection to reestablished?
Thanks,
Daniel
2020-01-30 09:02 AM
There are a few way to reduce the reconnection time.
2020-01-30 01:20 PM
We are currently using standby mode for a lower power consumption, so a direct connection would be ideal. Do you have and examples on how to implement this on the STM32WB GATT client?
2020-01-31 06:57 AM
Unfortunately not.
Unfortunately not. But we can confirm that the server device is maintaining the GATT data base in Flash memory. So if a notification was requested by a client, enabled by the server and the 2 devices were paired and bonded, the server will continue to notify the client after the reconnection.
On client side, the application can keep all the info related to services and characteristics for each server and make a direct connection without any service discovery phase. The client could also reconnect and asking for services with a connection_interval = 7.5ms. It is quite quick. And then a connection_update .
Use the p2pClient application and modify it to include the management of the service data base in Flash memory on the client side.
2020-04-19 06:07 PM
Hi Daniel,
You're asking how the connection/reconnection time could be decreased in order to reduce the power consumption of the sensor/server. Remi had suggested you use Direct Connection and upon investigation I found that you could also skip the discovery procedure as you’re always connecting to the same sensor/server.
I will detail below how to achieve each of those steps:
This step involves the following modifications in BLE_p2pClient:
This is done in the BLE_p2pClient_SerChaDiscBypass example code attached. This example is based on the BLE_p2pClient example. Below is the Program flow for the scan/discovery/connection process which starts with SW1 being pressed:
Other files attached:
As you can see on the algorithm, the connection time from Connect_Request() to aci_gatt_write_char_desc is reduced from 1800ms to 60ms when Flag_ServicesCharacteristics_In_Flash == 1. That is when the Services and Characteristics were stored in Flash and the discovery ACI aci_gatt_disc_all_primary_services and aci_gatt_disc_all_char_of_service are bypassed.
Moreover, stopping the scan once a server has been detected instead of waiting for it to timeout reduces the scan time from 10042ms to 50ms.
How to test BLE_p2pClient_SerChaDiscBypass:
@Note: On the algorithm, when two “paths�? are available, go left and top option first and go back to the nod when you get to a dead-end.
As shown on the algorithm above, I modified case EVT_LE_ADVERTISING_REPORT: in SVCCTL_App_Notification to terminate aci_gap_start_general_discovery_proc as soon as any server is detected, thereby not waiting for the 10.24s hardcoded timeout (which is observed as a 10.42s delay). A condition could be added to check the SERVER_REMOTE_BDADDR against a previously stored address. (Would have been stored in flash in a similar manner to storing the services and characteristics). The stored address could even be potentially used to directly connect and skip the scan.
This however has nothing to do with Direct Connection.
In order to implement Direct Connection we must modify the BLE_p2pServer example to use aci_gap_set_direct_connectable. Yet, I haven’t managed to do so and the division told me it wouldn’t lead to a faster reconnection time.
If you do still want to try and implement it, you could try the following:
Note that the only LOW_DUTY_CYCLE_DIRECTED_ADV (0x04) can be used for the Directed_Advertising_Type argument of ACI_GAP_SET_DIRECT_CONNECTABLE.
Moreover, bd_address and initiator_addr must be swapped: if bd_address=0x333333222222, initiator_addr=0x222222333333.
FYI, when I tried implementing ACI_GAP_SET_DIRECT_CONNECTABLE, I was never able to observe a HCI_LE_CONNECTION_COMPLETE_EVENT despite the AN5270 saying it should be triggered.
Regards,
Hugues
2020-05-25 03:09 PM
Hello! @Remi QUINTIN how can I enable notification in the client board?I'm using Nucleo wb55. I can enable notification in the ST BLE Sensor app but not in p2p_client_app.c
2020-05-25 03:23 PM
Hi @Kolab, please create your own thread and be more specific on what you want to do.
If you want to toggle the LED on the server from the client, see P2PC_APP_SW1_Button_Action in p2p_client_app.c:
void P2PC_APP_SW1_Button_Action(void)
{
UTIL_SEQ_SetTask(1<<CFG_TASK_SW1_BUTTON_PUSHED_ID, CFG_SCH_PRIO_0);
}
2020-06-05 02:56 AM
Hello @Community member I don't want to toggle a LED. I have created a case where I describe what I am trying to do.