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.
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,
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.
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...
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...