cancel
Showing results for 
Search instead for 
Did you mean: 

[STM32WB] time synchronization over BLE/radio

AMahm.2
Associate

I have the following setup:

  • 1 STM32WB based device (A) is configured as both master and slave
  • A is connected to up to 4 slave devices (B)

I need to implement RTC synchronization over BLE, and my initial approach is following:

  • A smartphone that's connected to A sends a time synchronization command
  • A drops all active connections, both to smartphone and all B devices
  • A connects to B devices one at a time with a connection interval of 7.5 ms
  • A reads RTC and writes data to B device's custom RTC BLE characteristic

I know that the timing for the write to characteristic operation is random. It will happen on the next connection interval, and it may be repeated on the MAC layer in case it failed.

In order to measure the round trip time (RTT), I set the RTC BLE characteristic using ATTR_ACCESS_WRITE_REQ_ONLY. After B device receives data on the characteristic and sets its RTC it calls aci_gatt_write_resp which should in return send a write response to A and generate aci_gatt_proc_complete_event_rp0 in A's BLE stack.

The idea behind measuring the RTT is that I can repeat the whole procedure in case the RTT is too big. Using the described approach the RTT I measure is usually 22ms or more. I was expecting it to be 2xconnection interval time (2*7.5ms = 15ms) in the worst case, but it looks like it's 3xconnection interval time.

My goal is to achieve under 10ms RTC time synchronization.

1 - Is there anything I can do to get better control over the timing when the packet is sent over BLE if I am using the GATT layer?

2 - Is there any other way to make a similar procedure using STM32WB's radio and perhaps avoid the GATT layer but have this process run much faster? Nordic's SoftDevice API provides Timeslots API which can be used for the above. Is there any similar functionality in ST's BLE stack provided to the end-user?

1 REPLY 1
handelem
Associate

I am facing a similar problem. Could please share with me hold did you implemented your code?