Skip to content

Commit 34125ce

Browse files
authored
Examples update, add a note for configTime() that only one ntp server is supported by lwip (#5343)
lwip lib bundled with esp32 Arduino supports only one ntp server. Any additional servers set are just silently ignored. This default is different from esp8266 Arduino core and very confusing. Most of the examples provided uses 3 different ntp servers for redundancy while only the first one is used actually. Addressing issue #4964
1 parent ee24736 commit 34125ce

File tree

7 files changed

+28
-0
lines changed

7 files changed

+28
-0
lines changed

Diff for: cores/esp32/esp32-hal-time.c

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ static void setTimeZone(long offset, int daylight)
4444
/*
4545
* configTime
4646
* Source: https://github.com/esp8266/Arduino/blob/master/cores/esp8266/time.c
47+
* Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
48+
* see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
4749
* */
4850
void configTime(long gmtOffset_sec, int daylightOffset_sec, const char* server1, const char* server2, const char* server3)
4951
{
@@ -63,6 +65,8 @@ void configTime(long gmtOffset_sec, int daylightOffset_sec, const char* server1,
6365
/*
6466
* configTzTime
6567
* sntp setup using TZ environment variable
68+
* Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
69+
* see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
6670
* */
6771
void configTzTime(const char* tz, const char* server1, const char* server2, const char* server3)
6872
{

Diff for: libraries/FFat/examples/FFat_time/FFat_time.ino

+4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ void setup(){
148148
Serial.println("IP address: ");
149149
Serial.println(WiFi.localIP());
150150
Serial.println("Contacting Time Server");
151+
/*
152+
Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
153+
see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
154+
*/
151155
configTime(3600*timezone, daysavetime*3600, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org");
152156
struct tm tmstruct ;
153157
delay(2000);

Diff for: libraries/HTTPUpdate/examples/httpUpdateSecure/httpUpdateSecure.ino

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ WiFiMulti WiFiMulti;
1717

1818
// Set time via NTP, as required for x.509 validation
1919
void setClock() {
20+
/*
21+
Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
22+
see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
23+
*/
2024
configTime(0, 0, "pool.ntp.org", "time.nist.gov"); // UTC
2125

2226
Serial.print(F("Waiting for NTP time sync: "));

Diff for: libraries/LittleFS/examples/LITTLEFS_time/LITTLEFS_time.ino

+4
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ void setup(){
160160
Serial.println("IP address: ");
161161
Serial.println(WiFi.localIP());
162162
Serial.println("Contacting Time Server");
163+
/*
164+
Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
165+
see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
166+
*/
163167
configTime(3600*timezone, daysavetime*3600, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org");
164168
struct tm tmstruct ;
165169
delay(2000);

Diff for: libraries/SD/examples/SD_time/SD_time.ino

+4
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ void setup(){
164164
Serial.println("IP address: ");
165165
Serial.println(WiFi.localIP());
166166
Serial.println("Contacting Time Server");
167+
/*
168+
Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
169+
see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
170+
*/
167171
configTime(3600*timezone, daysavetime*3600, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org");
168172
struct tm tmstruct ;
169173
delay(2000);

Diff for: libraries/SD_MMC/examples/SDMMC_time/SDMMC_time.ino

+4
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ void setup(){
164164
Serial.println("IP address: ");
165165
Serial.println(WiFi.localIP());
166166
Serial.println("Contacting Time Server");
167+
/*
168+
Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
169+
see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
170+
*/
167171
configTime(3600*timezone, daysavetime*3600, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org");
168172
struct tm tmstruct ;
169173
delay(2000);

Diff for: libraries/SPIFFS/examples/SPIFFS_time/SPIFFS_time.ino

+4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ void setup(){
148148
Serial.println("IP address: ");
149149
Serial.println(WiFi.localIP());
150150
Serial.println("Contacting Time Server");
151+
/*
152+
Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
153+
see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
154+
*/
151155
configTime(3600*timezone, daysavetime*3600, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org");
152156
struct tm tmstruct ;
153157
delay(2000);

0 commit comments

Comments
 (0)