From fe0668ea7e3b966f89ed46cb3b84f9ee9b234e65 Mon Sep 17 00:00:00 2001 From: pennam Date: Wed, 11 Sep 2024 10:22:59 +0200 Subject: [PATCH] TimeService: improve debug prints and comments --- src/utility/time/TimeService.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/utility/time/TimeService.cpp b/src/utility/time/TimeService.cpp index 021232ba..8d4df4d6 100644 --- a/src/utility/time/TimeService.cpp +++ b/src/utility/time/TimeService.cpp @@ -141,6 +141,7 @@ unsigned long TimeServiceClass::getTime() unsigned long const current_tick = millis(); bool const is_ntp_sync_timeout = (current_tick - _last_sync_tick) > _sync_interval_ms; if(!_is_rtc_configured || is_ntp_sync_timeout) { + /* Try to sync time from NTP or connection handler */ sync(); } @@ -172,14 +173,20 @@ bool TimeServiceClass::sync() } else { #if defined(HAS_NOTECARD) || defined(HAS_TCP) utc = getRemoteTime(); +<<<<<<< HEAD #elif defined(HAS_LORA) /* Just keep incrementing stored RTC value*/ +======= +#endif +#ifdef HAS_LORA + /* Just keep incrementing stored RTC value starting from EPOCH_AT_COMPILE_TIME */ +>>>>>>> 012b73e6 (TimeService: improve debug prints and comments) utc = getRTC(); #endif } if(isTimeValid(utc)) { - DEBUG_DEBUG("TimeServiceClass::%s Drift: %d RTC value: %u", __FUNCTION__, getRTC() - utc, utc); + DEBUG_DEBUG("TimeServiceClass::%s done. Drift: %d RTC value: %u", __FUNCTION__, getRTC() - utc, utc); setRTC(utc); _last_sync_tick = millis(); _is_rtc_configured = true; @@ -307,6 +314,7 @@ unsigned long TimeServiceClass::getRemoteTime() return ntp_time; } } + DEBUG_WARNING("TimeServiceClass::%s cannot get time from NTP, fallback on connection handler", __FUNCTION__); #endif /* HAS_TCP */ /* As fallback if NTP request fails try to obtain the @@ -316,6 +324,7 @@ unsigned long TimeServiceClass::getRemoteTime() if(isTimeValid(connection_time)) { return connection_time; } + DEBUG_WARNING("TimeServiceClass::%s cannot get time from connection handler", __FUNCTION__); } /* Return known invalid value because we are not connected */