Skip to content

Commit cb1b5b5

Browse files
committed
fix(time): Fix SimpleTime to also use DHCP
1 parent 76b6ff6 commit cb1b5b5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino

+9-8
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ void setup() {
3333
// First step is to configure WiFi STA and connect in order to get the current time and date.
3434
Serial.printf("Connecting to %s ", ssid);
3535
WiFi.begin(ssid, password);
36-
while (WiFi.status() != WL_CONNECTED) {
37-
delay(500);
38-
Serial.print(".");
39-
}
40-
Serial.println(" CONNECTED");
41-
42-
// set notification call-back function
43-
sntp_set_time_sync_notification_cb(timeavailable);
4436

4537
/**
4638
* NTP server address could be acquired via DHCP,
@@ -52,6 +44,15 @@ void setup() {
5244
*/
5345
esp_sntp_servermode_dhcp(1); // (optional)
5446

47+
while (WiFi.status() != WL_CONNECTED) {
48+
delay(500);
49+
Serial.print(".");
50+
}
51+
Serial.println(" CONNECTED");
52+
53+
// set notification call-back function
54+
sntp_set_time_sync_notification_cb(timeavailable);
55+
5556
/**
5657
* This will set configured ntp servers and constant TimeZone/daylightOffset
5758
* should be OK if your time zone does not need to adjust daylightOffset twice a year,

0 commit comments

Comments
 (0)