Closed PaulZC closed 1 week ago
I'll take this one. It fits in nicely with NTP #372
rtcUpdate
will only set the RTC once. It can't resync it once online.rtc
is true.
lastRTCAttempt
and lastRTCSync
are doing different things. lastRTCAttempt
restricts how often rtcUpdate
can validate the time and attempt to set the RTC. lastRTCSync
controls how often tpISR
can resync the RTC. Both are needed.
syncRTCInterval
initially limits rtcUpdate
to validating the time to once per second. It later limits tpISR
to resyncing the RTC once per minute.
rtcSyncd
indicates that the RTC has been set accurately by tpISR
. It controls if the system state enters STATE_NTPSERVER_SYNC
and starts responding to NTP requests.
menuSystem
can set online.rtc
back to false, but only when the timeZone is changed. That's fine. The user can't expect NTP time to be accurate after changing the time zone. I'm adding code to change the state back to STATE_NTPSERVER_NO_SYNC
if rtcSyncd
becomes false - i.e. because the user has changed the time zone.
Resolved by #404
It looks like we are currently synchronising the ESP32 RTC to GNSS in two places:
rtcUpdate
- here if(millis() - lastRTCAttempt > syncRTCInterval)
tpISR
- here via interrupt, on the rising edge of PPS if(millisNow - lastRTCSync > syncRTCInterval)
Let's make sure
tpISR
wins - on platforms that support it - for the most accurate clock synchronisation...I think we have some redundancy and probable conflict between
lastRTCAttempt
andlastRTCSync
. Let's resolve that...