Skip to content

Commit 278f653

Browse files
committed
TimeService: improve debug prints and comments
1 parent cf78d4e commit 278f653

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: src/utility/time/TimeService.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ unsigned long TimeServiceClass::getTime()
141141
unsigned long const current_tick = millis();
142142
bool const is_ntp_sync_timeout = (current_tick - _last_sync_tick) > _sync_interval_ms;
143143
if(!_is_rtc_configured || is_ntp_sync_timeout) {
144+
/* Try to sync time from NTP or connection handler */
144145
sync();
145146
}
146147

@@ -173,13 +174,13 @@ bool TimeServiceClass::sync()
173174
#if defined(HAS_NOTECARD) || defined(HAS_TCP)
174175
utc = getRemoteTime();
175176
#elif defined(HAS_LORA)
176-
/* Just keep incrementing stored RTC value*/
177+
/* Just keep incrementing stored RTC value starting from EPOCH_AT_COMPILE_TIME */
177178
utc = getRTC();
178179
#endif
179180
}
180181

181182
if(isTimeValid(utc)) {
182-
DEBUG_DEBUG("TimeServiceClass::%s Drift: %d RTC value: %u", __FUNCTION__, getRTC() - utc, utc);
183+
DEBUG_DEBUG("TimeServiceClass::%s done. Drift: %d RTC value: %u", __FUNCTION__, getRTC() - utc, utc);
183184
setRTC(utc);
184185
_last_sync_tick = millis();
185186
_is_rtc_configured = true;
@@ -307,6 +308,7 @@ unsigned long TimeServiceClass::getRemoteTime()
307308
return ntp_time;
308309
}
309310
}
311+
DEBUG_WARNING("TimeServiceClass::%s cannot get time from NTP, fallback on connection handler", __FUNCTION__);
310312
#endif /* HAS_TCP */
311313

312314
/* As fallback if NTP request fails try to obtain the
@@ -316,6 +318,7 @@ unsigned long TimeServiceClass::getRemoteTime()
316318
if(isTimeValid(connection_time)) {
317319
return connection_time;
318320
}
321+
DEBUG_WARNING("TimeServiceClass::%s cannot get time from connection handler", __FUNCTION__);
319322
}
320323

321324
/* Return known invalid value because we are not connected */

0 commit comments

Comments
 (0)