From 817f7793c4b8279f321e154c3a7d5b6ebe6df347 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Wed, 9 Feb 2022 12:36:45 +0100 Subject: [PATCH] fix cyclic time sync when no timesource seen yet --- src/cyclic.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cyclic.cpp b/src/cyclic.cpp index 42556acf..33a0022d 100644 --- a/src/cyclic.cpp +++ b/src/cyclic.cpp @@ -22,6 +22,10 @@ void doHousekeeping() { if ((RTC_runmode == RUNMODE_UPDATE) || (RTC_runmode == RUNMODE_MAINTENANCE)) do_reset(true); // warmstart + // try to get time if we don't yet have a recent timesource + if (timeSource == _unsynced || timeSource == _set) + calibrateTime(); + // print heap and task storage information ESP_LOGD(TAG, "Heap: Free:%d, Min:%d, Size:%d, Alloc:%d, StackHWM:%d", ESP.getFreeHeap(), ESP.getMinFreeHeap(), ESP.getHeapSize(), @@ -49,11 +53,6 @@ void doHousekeeping() { if (GpsTask != NULL) ESP_LOGD(TAG, "Gpsloop %d bytes left | Taskstate = %d", uxTaskGetStackHighWaterMark(GpsTask), eTaskGetState(GpsTask)); - // (only) while device time is not set or unsynched, and we have a valid - // GPS time, we call calibrateTime to poll time immeditately from GPS - if ((timeSource == _unsynced || timeSource == _set) && - (gpstime.isUpdated() && gpstime.isValid() && gpstime.age() < 1000)) - calibrateTime(); #endif #ifdef HAS_SPI