Skip to content

Examples update, add a note for configTime() #5343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cores/esp32/esp32-hal-time.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ static void setTimeZone(long offset, int daylight)
/*
* configTime
* Source: https://github.com/esp8266/Arduino/blob/master/cores/esp8266/time.c
* Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
* see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
* */
void configTime(long gmtOffset_sec, int daylightOffset_sec, const char* server1, const char* server2, const char* server3)
{
Expand All @@ -63,6 +65,8 @@ void configTime(long gmtOffset_sec, int daylightOffset_sec, const char* server1,
/*
* configTzTime
* sntp setup using TZ environment variable
* Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
* see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
* */
void configTzTime(const char* tz, const char* server1, const char* server2, const char* server3)
{
Expand Down
4 changes: 4 additions & 0 deletions libraries/FFat/examples/FFat_time/FFat_time.ino
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ void setup(){
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("Contacting Time Server");
/*
Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
*/
configTime(3600*timezone, daysavetime*3600, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org");
struct tm tmstruct ;
delay(2000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ WiFiMulti WiFiMulti;

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

Serial.print(F("Waiting for NTP time sync: "));
Expand Down
4 changes: 4 additions & 0 deletions libraries/LittleFS/examples/LITTLEFS_time/LITTLEFS_time.ino
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ void setup(){
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("Contacting Time Server");
/*
Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
*/
configTime(3600*timezone, daysavetime*3600, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org");
struct tm tmstruct ;
delay(2000);
Expand Down
4 changes: 4 additions & 0 deletions libraries/SD/examples/SD_time/SD_time.ino
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ void setup(){
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("Contacting Time Server");
/*
Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
*/
configTime(3600*timezone, daysavetime*3600, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org");
struct tm tmstruct ;
delay(2000);
Expand Down
4 changes: 4 additions & 0 deletions libraries/SD_MMC/examples/SDMMC_time/SDMMC_time.ino
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ void setup(){
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("Contacting Time Server");
/*
Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
*/
configTime(3600*timezone, daysavetime*3600, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org");
struct tm tmstruct ;
delay(2000);
Expand Down
4 changes: 4 additions & 0 deletions libraries/SPIFFS/examples/SPIFFS_time/SPIFFS_time.ino
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ void setup(){
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("Contacting Time Server");
/*
Note: Bundled Arduino lwip supports only ONE ntp server, 2nd and 3rd options are silently ignored
see CONFIG_LWIP_DHCP_MAX_NTP_SERVERS define in ./tools/sdk/esp32/sdkconfig
*/
configTime(3600*timezone, daysavetime*3600, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org");
struct tm tmstruct ;
delay(2000);
Expand Down