AceTime  0.5.2
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 /*
2  * MIT License
3  * Copyright (c) 2018 Brian T. Park
4  */
5 
6 #ifndef ACE_TIME_TIME_PROVIDER_H
7 #define ACE_TIME_TIME_PROVIDER_H
8 
9 #include <stdint.h>
10 #include "../common/common.h"
11 #include "../LocalTime.h"
12 
13 namespace ace_time {
14 namespace clock {
15 
20 class TimeProvider {
21  public:
22  static const acetime_t kInvalidSeconds = LocalTime::kInvalidSeconds;
23 
25  virtual ~TimeProvider() {}
26 
31  virtual acetime_t getNow() const = 0;
32 
34  virtual void sendRequest() const {}
35 
37  virtual bool isResponseReady() const { return true; }
38 
44  virtual acetime_t readResponse() const { return getNow(); }
45 };
46 
47 }
48 }
49 
50 #endif
virtual ~TimeProvider()
Virtual destructor.
Definition: TimeProvider.h:25
static const acetime_t kInvalidSeconds
An invalid seconds marker that indicates isError() true.
Definition: LocalTime.h:29
Base class for objects that provide a source of time whose time cannot be changed by the end-user...
Definition: TimeProvider.h:20
virtual bool isResponseReady() const
Return true if a response is ready.
Definition: TimeProvider.h:37
virtual void sendRequest() const
Send a time request asynchronously.
Definition: TimeProvider.h:34
virtual acetime_t readResponse() const
Returns number of seconds since AceTime epoch (2000-01-01).
Definition: TimeProvider.h:44
virtual acetime_t getNow() const =0
Return the number of seconds since the AceTime epoch (2000-01-01T00:00:00Z).