Add NTP update state. Refactoring.

This commit is contained in:
2024-04-04 01:45:11 +02:00
parent f4b49dd8c4
commit 5a51707452
4 changed files with 81 additions and 32 deletions

View File

@@ -195,7 +195,7 @@ void setup()
}
// get initial time
if (tm_mgr.ntp_time_update(true))
if (tm_mgr.ntp_time_update(true) == NTP_UPDATE_OK)
{
// show the current time for short time in words
String timeMessage = time_to_string(tm_mgr.tm_hour(), tm_mgr.tm_min());
@@ -251,6 +251,9 @@ void loop()
if ((current_time_us - last_heartbeat_us) >= PERIOD_HEARTBEAT_US)
{
send_heartbeat(); // send heartbeat update
tm_mgr.log_time(); // TODO rm
last_heartbeat_us = system_get_time();
delay(10);
}
@@ -282,11 +285,11 @@ void loop()
{
if (tm_mgr.ntp_sync_successful() == true) // regular case
{
tm_mgr.ntp_time_update(); // NTP time update
(void)tm_mgr.ntp_time_update(); // NTP time update
}
else // if there was never a NTP time update before (set up failed)
{
tm_mgr.ntp_time_update(true); // NTP time update with init!
(void)tm_mgr.ntp_time_update(true); // NTP time update with init!
}
if (tm_mgr.ntp_update_failed_prolonged() == true)