AceTime  0.3
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.
TimeProvider.h
1 #ifndef ACE_TIME_TIME_PROVIDER_H
2 #define ACE_TIME_TIME_PROVIDER_H
3 
4 #include <stdint.h>
5 #include "../common/common.h"
6 #include "../LocalTime.h"
7 
8 namespace ace_time {
9 namespace clock {
10 
15 class TimeProvider {
16  public:
17  static const acetime_t kInvalidSeconds = LocalTime::kInvalidSeconds;
18 
20  virtual ~TimeProvider() {}
21 
26  virtual acetime_t getNow() const = 0;
27 
29  virtual void sendRequest() const {}
30 
32  virtual bool isResponseReady() const { return true; }
33 
39  virtual acetime_t readResponse() const { return getNow(); }
40 };
41 
42 }
43 }
44 
45 #endif
virtual ~TimeProvider()
Virtual destructor.
Definition: TimeProvider.h:20
static const acetime_t kInvalidSeconds
An invalid seconds marker that indicates isError() true.
Definition: LocalTime.h:23
Base class for objects that provide a source of time whose time cannot be changed by the end-user...
Definition: TimeProvider.h:15
virtual bool isResponseReady() const
Return true if a response is ready.
Definition: TimeProvider.h:32
virtual void sendRequest() const
Send a time request asynchronously.
Definition: TimeProvider.h:29
virtual acetime_t readResponse() const
Returns number of seconds since AceTime epoch (2000-01-01).
Definition: TimeProvider.h:39
virtual acetime_t getNow() const =0
Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z).