diff --git a/src/time_man.cpp b/src/time_man.cpp index d5d76d7f..97972c8b 100644 --- a/src/time_man.cpp +++ b/src/time_man.cpp @@ -69,12 +69,13 @@ unsigned long TimeManager::loop(MicroTasks::WakeReason reason) unsigned long ret = MicroTask.Infinate; - if(_nextCheckTime > 0) + if(config_sntp_enabled() && + NULL != _timeHost && + _nextCheckTime > 0) { int64_t delay = (int64_t)_nextCheckTime - (int64_t)millis(); - if(config_sntp_enabled() && - net_is_connected() && + if(net_is_connected() && false == _fetchingTime && delay <= 0) { @@ -100,7 +101,7 @@ unsigned long TimeManager::loop(MicroTasks::WakeReason reason) struct timeval utc_time; gettimeofday(&utc_time, NULL); - if(utc_time.tv_usec >= 999500) + if(utc_time.tv_usec >= 999000) { _setTheTime = false; @@ -119,7 +120,7 @@ unsigned long TimeManager::loop(MicroTasks::WakeReason reason) { unsigned long msec = utc_time.tv_usec / 1000; DBUGVAR(msec); - unsigned long delay = msec < 999 ? 999 - msec : 0; + unsigned long delay = msec < 998 ? 998 - msec : 0; DBUGVAR(delay); if(delay < ret) { ret = delay;