Closed vicgwee closed 2 years ago
What time is received:
Byte | Meaning |
---|---|
10 | Adjust reasons (1 bit per reason) |
9 | Fractions of a second (256th) |
8 | Day of Week |
7 | Seconds |
6 | Minutes |
5 | Hours |
4 | Day of Month |
3 | Month |
1-2 | Year since 1792 |
Byte 1-7 is commonly known as ble_date_time_t Code here: https://github.com/iot-bus/iot-bus-bluetooth-examples-platformio/blob/7e79bdbfd48774ccd8dcc4f37b71d7f4c40255fa/temperature-monitor/src/bluetooth_time.h
According to https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/peripheral_cts_client/README.html
Tested
I compared how long it took for the onboard clock (millis) to be de-synced with the CTS clock by 1000ms:
MCU 1 took 126 seconds MCU 2 took 120 seconds
In both cases, the Arduino clock was consistently slower than the CTS clock.
Syncing with the RTC, the results are more consistent, no significant de-syncing after several minutes. Will need to test it for longer.
I synced the RTC and the CTS times at the start. Then, I plotted the RTT (blue) of each CTS packet and the time difference (red) in ms between the RTC time and the received time over several minutes. If the RTT was over 80ms, the datapoint was not plotted:
Some insights:
Right now, the filter is not optimised. But the RTC updating function works. Will just merge it in and plan to enhance the filter later.
Will close #11
Right now, it reads unformatted time (after current time). Comparison with millis():