i have a bluetooth device built on BGM121 which sends sensor data to a smart phone. If the smart phone is not connected or loses connection, The sensor data is still gathered and stored in a flash memory attached to the BGM121.
When the smart phone reconnects, the BGM121 sends all missed data from the flash to the smart phone.
So what i need is accurate timestamping of the sensor data.
My idea is that on the first time after power up when the BGM121 connects to the smart phone it gets the correct time from it.
It then keeps its internal date/time using something like this method:
When it loses the connection to the smart phone, it uses its internal date/time to timestamp the sensor data samples and then stores it in its flash.
Then when it regains connection it sends all the stored data to the smartphone.
SO:
I wonder about two points here:
On first powerup the smartphone (which is BLE client) needs to write the current date/time to the BGM121. Unfortunately the official BLE current time service doesnt support writes, so i think i can never "set the clock right" in my BGM121 using this service. Whats the alternative? Custom service? Or is there a better way to do it?
If the smart phone lost connection to the BGM121 and then reconnects to it again, say after 5 hours, will the clocks have drifted significantly? Do i have to resync somehow and what if this makes a "gap" where there is no sensor sample?
I think i need some expert advise to tackle this problem properly, can you please suggest a robust solution?
Thanks a lot,
Sds
Bluetooth Low Energy
Discussion Forums
Bluetooth Classic
Unanswered
I'm not an expert on the current time service, but a quick look here:
Seems that for current_time characteristic write is marked as "optional". So I'm not sure how you came to this conclusion:
>> official BLE current time service doesnt support writes
About the drift: not sure how much the drift is going to be over 5 hours, but I would expect it to be in the order of couple of seconds max. This can be tested quite easily. Make a test app that will report the time (seconds since RTCC reset) periodically, for example once per minute. Then leave it running for a couple of hours. Make note the exact time when application was started and after X hours check what is the drift.
I remember there has been some forum threads about the clock accuracy, using the search function you may find some additional info on this.
0
Hi JaakkoV,
you are right it is possible to write now. I have the specification version for CTS V10r00, seems that its been changed and writes are now possible to the current time characteristics. My bad, i should've checked the most up-to-date specification. But good to know.
I will look into the drift issue, i hope its really small, becasue i only need second accuracy, not milliseconds...
0
Hi smalldevshack,
I am implementing something very similar to your project, and I'm having the same issue. Exactly what kind of code did you use to sync the time? I'm totally lost...
Which BLE service for time sync?
Hi,
i have a bluetooth device built on BGM121 which sends sensor data to a smart phone. If the smart phone is not connected or loses connection, The sensor data is still gathered and stored in a flash memory attached to the BGM121.
When the smart phone reconnects, the BGM121 sends all missed data from the flash to the smart phone.
So what i need is accurate timestamping of the sensor data.
My idea is that on the first time after power up when the BGM121 connects to the smart phone it gets the correct time from it.
It then keeps its internal date/time using something like this method:
http://community.silabs.com/t5/Bluetooth-Wi-Fi-Knowledge-Base/Using-RTCC-as-Timer-or-Calendar-while-running-BLE-stack/ta-p/180402
When it loses the connection to the smart phone, it uses its internal date/time to timestamp the sensor data samples and then stores it in its flash.
Then when it regains connection it sends all the stored data to the smartphone.
SO:
I wonder about two points here:
I think i need some expert advise to tackle this problem properly, can you please suggest a robust solution?
Thanks a lot,
Sds
I'm not an expert on the current time service, but a quick look here:
https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.service.current_time.xml
Seems that for current_time characteristic write is marked as "optional". So I'm not sure how you came to this conclusion:
>> official BLE current time service doesnt support writes
About the drift: not sure how much the drift is going to be over 5 hours, but I would expect it to be in the order of couple of seconds max. This can be tested quite easily. Make a test app that will report the time (seconds since RTCC reset) periodically, for example once per minute. Then leave it running for a couple of hours. Make note the exact time when application was started and after X hours check what is the drift.
I remember there has been some forum threads about the clock accuracy, using the search function you may find some additional info on this.
Hi JaakkoV,
you are right it is possible to write now. I have the specification version for CTS V10r00, seems that its been changed and writes are now possible to the current time characteristics. My bad, i should've checked the most up-to-date specification. But good to know.
I will look into the drift issue, i hope its really small, becasue i only need second accuracy, not milliseconds...
Hi smalldevshack,
I am implementing something very similar to your project, and I'm having the same issue. Exactly what kind of code did you use to sync the time? I'm totally lost...