Fix RtcNtpServer induced exception on ESP32

Fix RtcNtpServer induced exception on ESP32 (#17338)
This commit is contained in:
Theo Arends 2022-12-11 12:19:03 +01:00
parent 4f70f4d33e
commit 062a2e3a7e
2 changed files with 5 additions and 3 deletions

View File

@ -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;

View File

@ -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);
}
}