Skip to content

Commit

Permalink
fix(time): Fix SimpleTime to also use DHCP (#9886)
Browse files Browse the repository at this point in the history
  • Loading branch information
me-no-dev authored Jun 19, 2024
1 parent 96c2c71 commit a992967
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ void setup() {
// First step is to configure WiFi STA and connect in order to get the current time and date.
Serial.printf("Connecting to %s ", ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(" CONNECTED");

// set notification call-back function
sntp_set_time_sync_notification_cb(timeavailable);

/**
* NTP server address could be acquired via DHCP,
Expand All @@ -52,6 +44,15 @@ void setup() {
*/
esp_sntp_servermode_dhcp(1); // (optional)

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(" CONNECTED");

// set notification call-back function
sntp_set_time_sync_notification_cb(timeavailable);

/**
* This will set configured ntp servers and constant TimeZone/daylightOffset
* should be OK if your time zone does not need to adjust daylightOffset twice a year,
Expand Down

0 comments on commit a992967

Please sign in to comment.