1#ifndef _PAINLESS_MESH_RTC_HPP_
2#define _PAINLESS_MESH_RTC_HPP_
78 RTCManager() : rtcInterface(nullptr), rtcEnabled(false), lastSyncTime(0) {}
92 rtcInterface = interface;
94 if (!rtcInterface->
begin()) {
96 rtcInterface =
nullptr;
102 rtcInterface =
nullptr;
117 rtcInterface =
nullptr;
127 return rtcEnabled && rtcInterface !=
nullptr && rtcInterface->
isAvailable();
154 if (ntpTimestamp == 0) {
164 lastSyncTime = millis();
176 if (lastSyncTime == 0) {
179 return millis() - lastSyncTime;
191 return rtcInterface->
getType();
196 bool rtcEnabled =
false;
197 uint32_t lastSyncTime = 0;
virtual ~RTCInterface()
Definition rtc.hpp:32
virtual uint32_t getUnixTime()=0
virtual bool isAvailable()=0
virtual bool setUnixTime(uint32_t timestamp)=0
virtual RTCType getType()=0
bool enable(RTCInterface *interface)
Definition rtc.hpp:86
bool syncFromNTP(uint32_t ntpTimestamp)
Definition rtc.hpp:148
RTCManager()
Definition rtc.hpp:78
uint32_t getTime()
Definition rtc.hpp:135
void disable()
Definition rtc.hpp:115
RTCType getType() const
Definition rtc.hpp:187
bool isEnabled() const
Definition rtc.hpp:126
uint32_t getTimeSinceLastSync() const
Definition rtc.hpp:175
@ GENERAL
Definition logger.hpp:26
@ ERROR
Definition logger.hpp:19
RTCType
Definition rtc.hpp:15
@ RTC_DS3231
Definition rtc.hpp:17
@ RTC_PCF8523
Definition rtc.hpp:19
@ RTC_NONE
Definition rtc.hpp:16
@ RTC_DS1307
Definition rtc.hpp:18
@ RTC_PCF8563
Definition rtc.hpp:20
@ RTC_ESP32_INTERNAL
Definition rtc.hpp:21
painlessmesh::logger::LogClass Log
Definition wifi.cpp:2
painlessmesh::logger::LogClass Log
Definition wifi.cpp:2