@@ -141,6 +141,7 @@ unsigned long TimeServiceClass::getTime()
141
141
unsigned long const current_tick = millis ();
142
142
bool const is_ntp_sync_timeout = (current_tick - _last_sync_tick) > _sync_interval_ms;
143
143
if (!_is_rtc_configured || is_ntp_sync_timeout) {
144
+ /* Try to sync time from NTP or connection handler */
144
145
sync ();
145
146
}
146
147
@@ -172,14 +173,20 @@ bool TimeServiceClass::sync()
172
173
} else {
173
174
#if defined(HAS_NOTECARD) || defined(HAS_TCP)
174
175
utc = getRemoteTime ();
176
+ <<<<<<< HEAD
175
177
#elif defined(HAS_LORA)
176
178
/* Just keep incrementing stored RTC value*/
179
+ =======
180
+ #endif
181
+ #ifdef HAS_LORA
182
+ /* Just keep incrementing stored RTC value starting from EPOCH_AT_COMPILE_TIME */
183
+ >>>>>>> 012b73e6 (TimeService: improve debug prints and comments)
177
184
utc = getRTC ();
178
185
#endif
179
186
}
180
187
181
188
if (isTimeValid (utc)) {
182
- DEBUG_DEBUG (" TimeServiceClass::%s Drift: %d RTC value: %u" , __FUNCTION__, getRTC () - utc, utc);
189
+ DEBUG_DEBUG (" TimeServiceClass::%s done. Drift: %d RTC value: %u" , __FUNCTION__, getRTC () - utc, utc);
183
190
setRTC (utc);
184
191
_last_sync_tick = millis ();
185
192
_is_rtc_configured = true ;
@@ -307,6 +314,7 @@ unsigned long TimeServiceClass::getRemoteTime()
307
314
return ntp_time;
308
315
}
309
316
}
317
+ DEBUG_WARNING (" TimeServiceClass::%s cannot get time from NTP, fallback on connection handler" , __FUNCTION__);
310
318
#endif /* HAS_TCP */
311
319
312
320
/* As fallback if NTP request fails try to obtain the
@@ -316,6 +324,7 @@ unsigned long TimeServiceClass::getRemoteTime()
316
324
if (isTimeValid (connection_time)) {
317
325
return connection_time;
318
326
}
327
+ DEBUG_WARNING (" TimeServiceClass::%s cannot get time from connection handler" , __FUNCTION__);
319
328
}
320
329
321
330
/* Return known invalid value because we are not connected */
0 commit comments