-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to tell if NTP has been successfully update after manually setting time with setTime #143
Comments
I have come across this too and was hoping for an event that might be fired off when the time is synced with NTP successfully. I have a project that requires very accurate time but may be offline. It is using an RTC as it's time source but synced/Set with ezTime. If the device boots with no internet, it relies on the battery backed RTC only, then theoretically, once the device has internet it will update the RTC. I was using the RTC time to set ezTime on boot but confused that when I called a function containing waitForSync() to update the time on the RTC after internet was connected, it did not update. i.e
UTC.now() will actually be the rtc time and not the internet time, regardless of internet connectivity. waitForSync() does not seem to actually check internet time if timeStatus() == timeSet (which seems to be the case if you have called setTime() less than 1hr ago. Because my project will behave differently between RTC time and ezTime, i need to know when ezTime has synced with NTP rather than the RTC. Author seems to be MIA this year... Edit: This is confirmed by the source - Line 537 of ezTime.cpp...
So because the time is set, regardless of the source, it's not actually checking internet time... |
I managed to work around this issue by reviewing the source code of the library If you call Unfortunately, I ended up with:
By setting an if statement such as: I also run it if network gets disconnected/reconnected. |
Since ezt::timeStatus() == timeset even if only due to being set manually, I was hoping there was just as easy way to find out if time was set by NTP only after having set the time manually with setTime say after a reboot with no internet where a manual time entry is required and then subsequently the internet becomes available again. How can I tell (in code without monitoring serial) that the NTP time is available again?
I'm sure I'm missing something obvious here!!
The text was updated successfully, but these errors were encountered: