Skip to content

Commit

Permalink
Fixed "Invalid mbox" error in SimpleTime example (#9262)
Browse files Browse the repository at this point in the history
* fix(esp32): 🐛 Fixed "Invalid mbox" in the Wi-Fi example

* fix: changes the code to actually connect to the WiFi in roder to get time and date

* fix: removing call to WiFi.begin() at the end of the sketch. It must be called at first.

---------

Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com>
  • Loading branch information
kinoh and SuGlider committed Feb 21, 2024
1 parent 1cb2cc7 commit 72f9fe3
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ void setup()
{
Serial.begin(115200);

// 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 );

Expand All @@ -59,16 +68,6 @@ void setup()
* A list of rules for your zone could be obtained from https://github.com/esp8266/Arduino/blob/master/cores/esp8266/TZ.h
*/
//configTzTime(time_zone, ntpServer1, ntpServer2);

//connect to WiFi
Serial.printf("Connecting to %s ", ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(" CONNECTED");

}

void loop()
Expand Down

0 comments on commit 72f9fe3

Please sign in to comment.