From c783ce445bd0604e49abb5cc12b829c02f3577a0 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 27 Nov 2020 18:22:44 +0100 Subject: [PATCH] Add NTP fallback servers x.pool.ntp.org --- tasmota/support_wifi.ino | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tasmota/support_wifi.ino b/tasmota/support_wifi.ino index aaa6e4757..87d0110f1 100644 --- a/tasmota/support_wifi.ino +++ b/tasmota/support_wifi.ino @@ -734,10 +734,17 @@ uint32_t WifiGetNtp(void) { IPAddress time_server_ip; + char fallback_ntp_server[16]; + snprintf_P(fallback_ntp_server, sizeof(fallback_ntp_server), PSTR("%d.pool.ntp.org"), random(0,3)); + char* ntp_server; bool resolved_ip = false; - for (uint32_t i = 0; i < MAX_NTP_SERVERS; i++) { - ntp_server = SettingsText(SET_NTPSERVER1 + ntp_server_id); + for (uint32_t i = 0; i <= MAX_NTP_SERVERS; i++) { + if (i < MAX_NTP_SERVERS) { + ntp_server = SettingsText(SET_NTPSERVER1 + ntp_server_id); + } else { + ntp_server = fallback_ntp_server; + } if (strlen(ntp_server)) { resolved_ip = (WiFi.hostByName(ntp_server, time_server_ip) == 1); if (255 == time_server_ip[0]) { resolved_ip = false; }