AceTime  0.1
Date and time classes for Arduino that supports the TZ DAtabase, and a system clock synchronized from an NTP server or an RTC chip.
Public Member Functions | Friends | List of all members
ace_time::provider::SystemTimeSyncCoroutine Class Reference

A coroutine that syncs the SystemTimeKeeper with its syncTimeProvider. More...

#include <SystemTimeSyncCoroutine.h>

Inheritance diagram for ace_time::provider::SystemTimeSyncCoroutine:
Inheritance graph
[legend]
Collaboration diagram for ace_time::provider::SystemTimeSyncCoroutine:
Collaboration graph
[legend]

Public Member Functions

 SystemTimeSyncCoroutine (SystemTimeKeeper &systemTimeKeeper, uint16_t syncPeriodSeconds=3600, uint16_t initialSyncPeriodSeconds=5, uint16_t requestTimeoutMillis=1000, common::TimingStats *timingStats=nullptr)
 Constructor. More...
 
int runCoroutine () override
 

Friends

class ::SystemTimeSyncCoroutineTest
 

Detailed Description

A coroutine that syncs the SystemTimeKeeper with its syncTimeProvider.

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 21 of file SystemTimeSyncCoroutine.h.

Constructor & Destructor Documentation

ace_time::provider::SystemTimeSyncCoroutine::SystemTimeSyncCoroutine ( SystemTimeKeeper systemTimeKeeper,
uint16_t  syncPeriodSeconds = 3600,
uint16_t  initialSyncPeriodSeconds = 5,
uint16_t  requestTimeoutMillis = 1000,
common::TimingStats timingStats = nullptr 
)
inline

Constructor.

Parameters
systemTimeKeeperthe system time keeper to sync up
syncPeriodSecondsseconds between normal sync attempts (default 3600)
initialSyncPeriodSecondsseconds between sync attempts when the systemTimeKeeper is not initialized (default 5)
requestTimeoutMillisnumber of milliseconds before the request to syncTimeProvider times out
timingStatsinternal statistics

Definition at line 35 of file SystemTimeSyncCoroutine.h.

Member Function Documentation

int ace_time::provider::SystemTimeSyncCoroutine::runCoroutine ( )
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 54 of file SystemTimeSyncCoroutine.h.


The documentation for this class was generated from the following file: