Added a timeout of 5ms to detect current time.

This prevents false positives when a interrupt occours during the reading of the time
This commit is contained in:
Thomas Basler
2022-11-14 20:19:38 +01:00
parent 83acba323f
commit dd7babb448
2 changed files with 6 additions and 6 deletions

View File

@@ -38,7 +38,7 @@ void WebApiNtpClass::onNtpStatus(AsyncWebServerRequest* request)
root[F("ntp_timezone_descr")] = config.Ntp_TimezoneDescr;
struct tm timeinfo;
if (!getLocalTime(&timeinfo, 0)) {
if (!getLocalTime(&timeinfo, 5)) {
root[F("ntp_status")] = false;
} else {
root[F("ntp_status")] = true;
@@ -159,7 +159,7 @@ void WebApiNtpClass::onNtpTimeGet(AsyncWebServerRequest* request)
JsonObject root = response->getRoot();
struct tm timeinfo;
if (!getLocalTime(&timeinfo, 0)) {
if (!getLocalTime(&timeinfo, 5)) {
root[F("ntp_status")] = false;
} else {
root[F("ntp_status")] = true;