AceTimeClock
1.3.0
Clock classes for Arduino that can synchronize from an NTP server or an RTC chip
|
Abstract base class for objects that provide and store time. More...
#include <Clock.h>
Public Member Functions | |
Clock ()=default | |
Default constructor. | |
~Clock ()=default | |
We deliberately avoid using a virtual destructor. More... | |
virtual acetime_t | getNow () const =0 |
Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z). More... | |
virtual void | sendRequest () const |
Send a time request asynchronously. | |
virtual bool | isResponseReady () const |
Return true if a response is ready. | |
virtual acetime_t | readResponse () const |
Returns number of seconds since AceTime epoch (2000-01-01). More... | |
virtual void | setNow (acetime_t) |
Set the time to the indicated seconds. More... | |
Static Public Attributes | |
static const acetime_t | kInvalidSeconds = LocalTime::kInvalidSeconds |
Error value returned by getNow() and other methods when this object is not yet initialized. | |
Abstract base class for objects that provide and store time.
For example, a DS3231 RTC chip, an NTP client, or a GPS module.
|
default |
We deliberately avoid using a virtual destructor.
This saves 618 bytes of flash on 8-bit AVR processors, 328 bytes on SAMD21, but only 50-60 bytes on other 32-bit processors.
|
pure virtual |
Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z).
Returns kInvalidSeconds if an error has occured.
This is a blocking call. Some clocks (e.g. NTP client) this may take many seconds. On those clocks, use the asynchronous methods (sendRequest(), isResponseReady(), and readResponse()) instead.
Implemented in ace_time::clock::UnixClock, ace_time::clock::SystemClockTemplate< T_CI >, ace_time::clock::SystemClockTemplate< T_SCCI >, ace_time::clock::StmRtcClock, ace_time::clock::Stm32F1Clock, ace_time::clock::NtpClock, ace_time::clock::EspSntpClock, and ace_time::clock::DS3231Clock< T_WIREI >.
|
inlinevirtual |
Returns number of seconds since AceTime epoch (2000-01-01).
Return kInvalidSeconds if there is an error. Valid only if isResponseReady() returns true.
Reimplemented in ace_time::clock::NtpClock.
|
inlinevirtual |
Set the time to the indicated seconds.
Calling with a value of kInvalidSeconds indicates an error condition, so the method should do nothing. Some clocks do not support this feature, for example, NTP or GPS clocks and this method will be a no-op.
Reimplemented in ace_time::clock::SystemClockTemplate< T_CI >, ace_time::clock::SystemClockTemplate< T_SCCI >, ace_time::clock::StmRtcClock, ace_time::clock::Stm32F1Clock, and ace_time::clock::DS3231Clock< T_WIREI >.