Hello Christian
There's certainly no API for doing anything like this. There's not even an official Bluetooth way to do time synchronization. (Well, I remember theres's Clock Synchronization specified in the Multi Channel Adaption Protocol, but I think it leaves the actual time sync open for the actual implementation, like how you get a time stamp on both sides)
On top of most OS including iOS, you cannot access Bluetooth time at all. However, I still think you can get time sync down to 1ms if you have full control on the LE side.
Here's the idea: you're repeatedly sending LE messages (e.g. characteristic writes without response) that include the current iOS time. Now, as we know, there's some indeterministic delay between sending the packet and receiving it on the other device. However, there's one simple fact: the delay is greater than some fixed minimal time in the iOS Bluetooth stack (incl. the sending schedule). So, it isn't your regular gauss error distribution.
On the device, you can record the pairs of time received and send time. This gives you some delta. The interesting property is that the smallest delay between the received time and the send time results from the packet with the smallest delay in the iOS send queue. Also, repeating this will increase the chances to receive a packet with an even smaller delay.
If this works as intended, you have established a common time base and could tell your device ahead of time to do something at point x in the future. Btw. this is independent from the connection interval, and using a larger one makes sorting the time stamps easier.
While this scheme should work in (academic) theory, I'd happy to hear how well it works in practice if you give it a try.
Best Matthias
--- BlueKitchen GmbH, Zurich, Switzerland
On 09.02.2016, at 05:48, Christian Ridderström < email@hidden> wrote:
Hi,
I'm investigating/thinking of how I could synchronize events in time between an iOS app and an external device over BLE.
Does the iOS API have any callbacks or similar that the iOS invoke at certain points in time based on the timing of the BLE comunication? For example (being wishful here), in connection with each connection event? Is it possible to make the iOS somewhere log the "iOS time" (e.g. mach-time) of connection events? Best regards, Christian -- Christian Ridderström, +46-70 687 39 44
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
|