AceTime
0.5.1
Date and time classes for Arduino that support timezones from the TZ Database, and a system clock that can synchronize from an NTP server or an RTC chip.
|
A class that that syncs the SystemClock with its mSyncTimeProvider. More...
#include <SystemClockSyncLoop.h>
Public Member Functions | |
SystemClockSyncLoop (SystemClock &systemClock, uint16_t syncPeriodSeconds=3600, uint16_t initialSyncPeriodSeconds=5) | |
Constructor. More... | |
void | loop () |
Call this from the global loop() method. More... | |
uint16_t | getSecondsSinceLastSync () const |
Return the number of seconds since last sync. More... | |
A class that that syncs the SystemClock with its mSyncTimeProvider.
The call to mSyncTimeProvider will be a blocking call which can be a problem for time providers like NtpTimeProvider which makes a network request. If this is a problem, use SystemClockSyncCoroutine instead.
Initial syncing occurs at initialSyncPeriodSeconds interval, until the first successful sync, then subsequent syncing occurs at syncPeriodSeconds interval. Initial syncing implements an exponential backoff when the sync request fails, increasing from initialSyncPeriodSeconds to until a maximum of syncPeriodSeconds.
Definition at line 29 of file SystemClockSyncLoop.h.
|
inlineexplicit |
Constructor.
systemClock | the system time keeper to sync up |
syncPeriodSeconds | seconds between normal sync attempts (default 3600) |
initialSyncPeriodSeconds | seconds between sync attempts when the systemClock is not initialized (default 5) |
Definition at line 40 of file SystemClockSyncLoop.h.
|
inline |
Return the number of seconds since last sync.
Mostly for debugging purposes.
Definition at line 81 of file SystemClockSyncLoop.h.
|
inline |
Call this from the global loop() method.
This uses a blocking call to the SystemClock.mSyncTimeProvider.
Definition at line 51 of file SystemClockSyncLoop.h.