Skip to content

Commit 72f9fe3

Browse files
kinohSuGlider
andauthored
Fixed "Invalid mbox" error in SimpleTime example (#9262)
* 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 <[email protected]>
1 parent 1cb2cc7 commit 72f9fe3

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

Diff for: libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino

+9-10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ void setup()
3333
{
3434
Serial.begin(115200);
3535

36+
// First step is to configure WiFi STA and connect in order to get the current time and date.
37+
Serial.printf("Connecting to %s ", ssid);
38+
WiFi.begin(ssid, password);
39+
while (WiFi.status() != WL_CONNECTED) {
40+
delay(500);
41+
Serial.print(".");
42+
}
43+
Serial.println(" CONNECTED");
44+
3645
// set notification call-back function
3746
sntp_set_time_sync_notification_cb( timeavailable );
3847

@@ -59,16 +68,6 @@ void setup()
5968
* A list of rules for your zone could be obtained from https://github.com/esp8266/Arduino/blob/master/cores/esp8266/TZ.h
6069
*/
6170
//configTzTime(time_zone, ntpServer1, ntpServer2);
62-
63-
//connect to WiFi
64-
Serial.printf("Connecting to %s ", ssid);
65-
WiFi.begin(ssid, password);
66-
while (WiFi.status() != WL_CONNECTED) {
67-
delay(500);
68-
Serial.print(".");
69-
}
70-
Serial.println(" CONNECTED");
71-
7271
}
7372

7473
void loop()

0 commit comments

Comments
 (0)