AceTime
0.5.2
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 coroutine that syncs the SystemClock with its mSyncTimeProvider. More...
#include <SystemClockSyncCoroutine.h>
Public Member Functions | |
SystemClockSyncCoroutine (SystemClock &systemClock, uint16_t syncPeriodSeconds=3600, uint16_t initialSyncPeriodSeconds=5, uint16_t requestTimeoutMillis=1000, common::TimingStats *timingStats=nullptr) | |
Constructor. More... | |
int | runCoroutine () override |
Friends | |
class | ::SystemClockSyncCoroutineTest |
A coroutine that syncs the SystemClock with its mSyncTimeProvider.
The call to mSyncTimeProvider is asynchronous, which is helpful when the syncTimeProvider issues a network request to an NTP server.
Initially, the class attempts to sync with its syncTimeProvider every initialSyncPeriodSeconds. If the request fails, then it retries with an exponential backoff (doubling the delay every iteration), until the sync period becomes greater than syncPeriodSeconds, then the delay is set permanently to syncPeriodSeconds.
Definition at line 31 of file SystemClockSyncCoroutine.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) |
requestTimeoutMillis | number of milliseconds before the request to syncTimeProvider times out |
timingStats | internal statistics |
Definition at line 45 of file SystemClockSyncCoroutine.h.
|
inlineoverride |
The CoroutineScheduler will use this method if enabled. Don't forget to call setupCoroutine() (inherited from Coroutine) in the global setup() to register this coroutine into the CoroutineScheduler.
Definition at line 63 of file SystemClockSyncCoroutine.h.