Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fe0668e

Browse files
committedSep 16, 2024·
TimeService: improve debug prints and comments
1 parent cf78d4e commit fe0668e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
 

‎src/utility/time/TimeService.cpp

Lines changed: 10 additions & 1 deletion
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

@@ -172,14 +173,20 @@ bool TimeServiceClass::sync()
172173
} else {
173174
#if defined(HAS_NOTECARD) || defined(HAS_TCP)
174175
utc = getRemoteTime();
176+
<<<<<<< HEAD
175177
#elif defined(HAS_LORA)
176178
/* 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)
177184
utc = getRTC();
178185
#endif
179186
}
180187

181188
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);
183190
setRTC(utc);
184191
_last_sync_tick = millis();
185192
_is_rtc_configured = true;
@@ -307,6 +314,7 @@ unsigned long TimeServiceClass::getRemoteTime()
307314
return ntp_time;
308315
}
309316
}
317+
DEBUG_WARNING("TimeServiceClass::%s cannot get time from NTP, fallback on connection handler", __FUNCTION__);
310318
#endif /* HAS_TCP */
311319

312320
/* As fallback if NTP request fails try to obtain the
@@ -316,6 +324,7 @@ unsigned long TimeServiceClass::getRemoteTime()
316324
if(isTimeValid(connection_time)) {
317325
return connection_time;
318326
}
327+
DEBUG_WARNING("TimeServiceClass::%s cannot get time from connection handler", __FUNCTION__);
319328
}
320329

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

0 commit comments

Comments
 (0)
Please sign in to comment.