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

@ -14,7 +14,7 @@ HM_Abstract::HM_Abstract(uint64_t serial)
bool HM_Abstract::sendStatsRequest(HoymilesRadio* radio)
{
struct tm timeinfo;
if (!getLocalTime(&timeinfo, 0)) {
if (!getLocalTime(&timeinfo, 5)) {
return false;
}
@ -31,7 +31,7 @@ bool HM_Abstract::sendStatsRequest(HoymilesRadio* radio)
bool HM_Abstract::sendAlarmLogRequest(HoymilesRadio* radio, bool force)
{
struct tm timeinfo;
if (!getLocalTime(&timeinfo, 0)) {
if (!getLocalTime(&timeinfo, 5)) {
return false;
}
@ -59,7 +59,7 @@ bool HM_Abstract::sendAlarmLogRequest(HoymilesRadio* radio, bool force)
bool HM_Abstract::sendDevInfoRequest(HoymilesRadio* radio)
{
struct tm timeinfo;
if (!getLocalTime(&timeinfo, 0)) {
if (!getLocalTime(&timeinfo, 5)) {
return false;
}
@ -80,7 +80,7 @@ bool HM_Abstract::sendDevInfoRequest(HoymilesRadio* radio)
bool HM_Abstract::sendSystemConfigParaRequest(HoymilesRadio* radio)
{
struct tm timeinfo;
if (!getLocalTime(&timeinfo, 0)) {
if (!getLocalTime(&timeinfo, 5)) {
return false;
}

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;