Skip to content

Commit 012b73e

Browse files
committed
TimeService: improve debug prints and comments
1 parent 419b39b commit 012b73e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/utility/time/TimeService.cpp

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

@@ -173,13 +174,13 @@ bool TimeServiceClass::sync()
173174
utc = getRemoteTime();
174175
#endif
175176
#ifdef 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;
@@ -306,6 +307,7 @@ unsigned long TimeServiceClass::getRemoteTime()
306307
return ntp_time;
307308
}
308309
}
310+
DEBUG_WARNING("TimeServiceClass::%s cannot get time from NTP, fallback on connection handler", __FUNCTION__);
309311

310312
/* As fallback if NTP request fails try to obtain the
311313
* network time using the connection handler.
@@ -314,6 +316,7 @@ unsigned long TimeServiceClass::getRemoteTime()
314316
if(isTimeValid(connection_time)) {
315317
return connection_time;
316318
}
319+
DEBUG_WARNING("TimeServiceClass::%s cannot get time from connection handler", __FUNCTION__);
317320
}
318321

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

0 commit comments

Comments
 (0)