File tree Expand file tree Collapse file tree 1 file changed +22
-7
lines changed
Expand file tree Collapse file tree 1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change 3434#ifndef FIREBASE_UTIL_H
3535#define FIREBASE_UTIL_H
3636
37+ #include " EmberIotShared.h"
38+
3739#ifdef ESP32
3840#include < WiFi.h>
3941#elif ESP8266
@@ -43,6 +45,12 @@ extern "C" {
4345}
4446#endif
4547
48+ namespace EmberIotShared
49+ {
50+ unsigned long timezoneOffsetSeconds = 0 ;
51+ unsigned long daylightSavingsOffsetSeconds = 0 ;
52+ }
53+
4654namespace FirePropUtil {
4755 inline size_t countOccurrences (const char *str, const char *sub) {
4856 int count = 0 ;
@@ -123,19 +131,26 @@ namespace FirePropUtil {
123131 inline void initTime ()
124132 {
125133#ifdef ESP32
126- configTime (0 , 0 , " pool.ntp.org" );
134+ configTime (EmberIotShared::timezoneOffsetSeconds, EmberIotShared::daylightSavingsOffsetSeconds , " pool.ntp.org" );
127135#endif
128136 }
129137
138+ bool firstCheckTime = true ;
139+
130140 inline bool isTimeInitialized ()
131141 {
132- // if (WiFi.status() != WL_CONNECTED)
133- // {
134- // return false;
135- // }
142+ if (firstCheckTime)
143+ {
144+ tm time;
145+ bool success = getLocalTime (&time);
146+ if (success)
147+ {
148+ firstCheckTime = false ;
149+ }
150+ return success;
151+ }
136152
137- tm time;
138- return getLocalTime (&time);
153+ return true ;
139154 }
140155
141156
You can’t perform that action at this time.
0 commit comments