bugfix timekeeper.cpp fallback logic

This commit is contained in:
Klaus K Wilting 2020-03-07 19:41:27 +01:00
parent 1467d2145b
commit 85c342e3d7

View File

@ -33,6 +33,9 @@ void calibrateTime(void) {
timesync_sendReq(); timesync_sendReq();
#endif #endif
// only if we lost time, we try to fallback to local time source RTS or GPS
if (timeSource == _unsynced) {
// has RTC -> fallback to RTC time // has RTC -> fallback to RTC time
#ifdef HAS_RTC #ifdef HAS_RTC
t = get_rtctime(); t = get_rtctime();
@ -51,8 +54,11 @@ void calibrateTime(void) {
goto finish; goto finish;
} }
#endif #endif
} // fallback
// no local time source -> don't set time else
// no fallback time source available -> we can't set time
return; return;
finish: finish:
@ -82,7 +88,7 @@ void IRAM_ATTR setMyTime(uint32_t t_sec, uint16_t t_msec,
vTaskDelay(pdMS_TO_TICKS(1000 - t_msec % 1000)); vTaskDelay(pdMS_TO_TICKS(1000 - t_msec % 1000));
} }
ESP_LOGD(TAG, "[%0.3f] UTC epoch time: %d.%03d sec", millis() / 1000.0, ESP_LOGD(TAG, "[%0.3f] UTC time: %d.%03d sec", millis() / 1000.0,
time_to_set, t_msec % 1000); time_to_set, t_msec % 1000);
// if we have got an external timesource, set RTC time and shift RTC_INT pulse // if we have got an external timesource, set RTC time and shift RTC_INT pulse