From 4f4157732cc940493c0db3b3ac5d7aecb938433f Mon Sep 17 00:00:00 2001
From: Kino
Date: Sun, 18 Feb 2024 00:39:43 +0900
Subject: [PATCH 1/3] fix(esp32): :bug: Fixed "Invalid mbox" in the Wi-Fi
example
---
libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino b/libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino
index f8b2e4391f6..3a8aa50c98d 100644
--- a/libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino
+++ b/libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino
@@ -33,6 +33,9 @@ void setup()
{
Serial.begin(115200);
+ // configure WiFi
+ WiFi.mode(WIFI_STA);
+
// set notification call-back function
sntp_set_time_sync_notification_cb( timeavailable );
From cd509c88d372e646ac019516b66ac2100def776f Mon Sep 17 00:00:00 2001
From: Rodrigo Garcia
Date: Sat, 17 Feb 2024 19:30:55 -0300
Subject: [PATCH 2/3] fix: changes the code to actually connect to the WiFi in
roder to get time and date
---
libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino b/libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino
index 3a8aa50c98d..fcba9d37200 100644
--- a/libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino
+++ b/libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino
@@ -33,8 +33,8 @@ void setup()
{
Serial.begin(115200);
- // configure WiFi
- WiFi.mode(WIFI_STA);
+ // configure WiFi STA and connect in order to get the current time and date.
+ WiFi.begin(ssid, password);
// set notification call-back function
sntp_set_time_sync_notification_cb( timeavailable );
From 66e39699a03b5816e1e98a89ac9547a9b1532787 Mon Sep 17 00:00:00 2001
From: Rodrigo Garcia
Date: Mon, 19 Feb 2024 09:50:15 -0300
Subject: [PATCH 3/3] fix: removing call to WiFi.begin() at the end of the
sketch. It must be called at first.
---
.../examples/Time/SimpleTime/SimpleTime.ino | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino b/libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino
index fcba9d37200..e7e3fc3f1fd 100644
--- a/libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino
+++ b/libraries/ESP32/examples/Time/SimpleTime/SimpleTime.ino
@@ -33,8 +33,14 @@ void setup()
{
Serial.begin(115200);
- // 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);
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 );
@@ -62,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()