fix(time): Fix SimpleTime to also use DHCP (#9886)

This commit is contained in:
Me No Dev 2024-06-19 09:55:54 +03:00 committed by GitHub
parent 96c2c71cb3
commit a992967079
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,14 +33,6 @@ void setup() {
// First step is to configure WiFi STA and connect in order to get the current time and date. // First step is to configure WiFi STA and connect in order to get the current time and date.
Serial.printf("Connecting to %s ", ssid); Serial.printf("Connecting to %s ", ssid);
WiFi.begin(ssid, password); 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, * NTP server address could be acquired via DHCP,
@ -52,6 +44,15 @@ void setup() {
*/ */
esp_sntp_servermode_dhcp(1); // (optional) 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 * 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, * should be OK if your time zone does not need to adjust daylightOffset twice a year,