AceTime  0.5
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.
Public Member Functions | List of all members
ace_time::clock::SystemClockSyncLoop Class Reference

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...
 

Detailed Description

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 27 of file SystemClockSyncLoop.h.

Constructor & Destructor Documentation

◆ SystemClockSyncLoop()

ace_time::clock::SystemClockSyncLoop::SystemClockSyncLoop ( SystemClock systemClock,
uint16_t  syncPeriodSeconds = 3600,
uint16_t  initialSyncPeriodSeconds = 5 
)
inlineexplicit

Constructor.

Parameters
systemClockthe system time keeper to sync up
syncPeriodSecondsseconds between normal sync attempts (default 3600)
initialSyncPeriodSecondsseconds between sync attempts when the systemClock is not initialized (default 5)

Definition at line 38 of file SystemClockSyncLoop.h.

Member Function Documentation

◆ getSecondsSinceLastSync()

uint16_t ace_time::clock::SystemClockSyncLoop::getSecondsSinceLastSync ( ) const
inline

Return the number of seconds since last sync.

Mostly for debugging purposes.

Definition at line 79 of file SystemClockSyncLoop.h.

◆ loop()

void ace_time::clock::SystemClockSyncLoop::loop ( )
inline

Call this from the global loop() method.

This uses a blocking call to the SystemClock.mSyncTimeProvider.

Definition at line 49 of file SystemClockSyncLoop.h.


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