From 062a2e3a7e26d789086f56330aeaff2a4a70185f Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 11 Dec 2022 12:19:03 +0100 Subject: [PATCH] Fix RtcNtpServer induced exception on ESP32 Fix RtcNtpServer induced exception on ESP32 (#17338) --- tasmota/tasmota_xdrv_driver/xdrv_56_rtc_chips.ino | 4 +++- tasmota/tasmota_xsns_sensor/xsns_60_GPS.ino | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_56_rtc_chips.ino b/tasmota/tasmota_xdrv_driver/xdrv_56_rtc_chips.ino index 01de30b39..a8f58ba40 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_56_rtc_chips.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_56_rtc_chips.ino @@ -404,6 +404,8 @@ NtpServer RtcChipTimeServer(PortUdp); void RtcChipEverySecond(void) { static bool ntp_server_started = false; + if (TasmotaGlobal.global_state.network_down) { return; } // Exception on ESP32 if network is down (#17338) + if (Settings->sbflag1.local_ntp_server && (Rtc.utc_time > START_VALID_TIME)) { if (!ntp_server_started) { if (RtcChipTimeServer.beginListening()) { @@ -418,7 +420,7 @@ void RtcChipEverySecond(void) { void CmndRtcNtpServer(void) { // RtcChipNtpServer 0 or 1 - if (XdrvMailbox.payload >= 0) { + if ((XdrvMailbox.payload >= 0) && !TasmotaGlobal.global_state.network_down) { Settings->sbflag1.local_ntp_server = 0; if ((XdrvMailbox.payload &1) && RtcChipTimeServer.beginListening()) { Settings->sbflag1.local_ntp_server = 1; diff --git a/tasmota/tasmota_xsns_sensor/xsns_60_GPS.ino b/tasmota/tasmota_xsns_sensor/xsns_60_GPS.ino index 0bf0b5e9e..b128af960 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_60_GPS.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_60_GPS.ino @@ -584,7 +584,7 @@ void UBXSelectMode(uint16_t mode) UBX.mode.send_when_new = 0; // only TELE break; case 9: - if (timeServer.beginListening()) { + if (!TasmotaGlobal.global_state.network_down && timeServer.beginListening()) { UBX.mode.runningNTP = true; } break; @@ -722,7 +722,7 @@ void UBXLoop50msec(void) } } // handle NTP-server - if(UBX.mode.runningNTP){ + if(!TasmotaGlobal.global_state.network_down && UBX.mode.runningNTP){ timeServer.processOneRequest(UBX.rec_buffer.values.time, UBX.state.timeOffset - NTP_MILLIS_OFFSET); } }