AceTimeClock
1.3.0
Clock classes for Arduino that can synchronize from an NTP server or an RTC chip
|
An implementation of Clock that uses an STM32 RTC chip using the STM32RTC library. More...
#include <StmRtcClock.h>
Public Member Functions | |
StmRtcClock ()=default | |
Constructor. | |
void | setup () |
Setup does nothing. More... | |
acetime_t | getNow () const override |
Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z). More... | |
void | setNow (acetime_t epochSeconds) override |
Set the time to the indicated seconds. More... | |
bool | isTimeSet () const |
Return true if the RTC is available and the time is set. | |
![]() | |
Clock ()=default | |
Default constructor. | |
~Clock ()=default | |
We deliberately avoid using a virtual destructor. 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... | |
Additional Inherited Members | |
![]() | |
static const acetime_t | kInvalidSeconds = LocalTime::kInvalidSeconds |
Error value returned by getNow() and other methods when this object is not yet initialized. | |
An implementation of Clock that uses an STM32 RTC chip using the STM32RTC library.
The STM32RTC singleton object should be configured using STM32RTC::getInstance()
in the global setup()
function.
AceTime v2 allows the epoch year of the library to be adjustable by the client application, from the year 2000 until the year 10000. Unfortunately, the STM32 hardware supported by this class (through the dependent STM32RTC library) uses a 2-digit year offset from the year 2000. This will break in the year 2100 unless a software fix can be created to work around that limitation.
Ironically, the STM32F1 chip has a more limited RTC functionality in the hardware but that limitation actually works to its advantage so that the F1 can be fully compatible with AceTime to its limit of the year 10000 if Stm32F1Clock class is used instead of this class. (See notes in Stm32F1Clock.h).
Definition at line 41 of file StmRtcClock.h.
|
inlineoverridevirtual |
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.
Implements ace_time::clock::Clock.
Definition at line 49 of file StmRtcClock.h.
|
inlineoverridevirtual |
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 from ace_time::clock::Clock.
Definition at line 55 of file StmRtcClock.h.
|
inline |
Setup does nothing.
Defined for API consistency with other Clocks.
Definition at line 47 of file StmRtcClock.h.