Skip to content

Commit c3666c1

Browse files
committed
Update ESP32 WiFi events to new version
1 parent 21faead commit c3666c1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

examples/advancedExample/advancedExample.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@ double offset;
3030
double timedelay;
3131

3232
#ifdef ESP32
33-
void onWifiEvent (system_event_id_t event, system_event_info_t info) {
33+
void onWifiEvent (arduino_event_id_t event, arduino_event_info_t info) {
3434
#else
3535
void onWifiEvent (WiFiEvent_t event) {
3636
#endif
3737
Serial.printf ("[WiFi-event] event: %d\n", event);
3838

3939
switch (event) {
4040
#ifdef ESP32
41-
case SYSTEM_EVENT_STA_CONNECTED:
42-
Serial.printf ("Connected to %s. Asking for IP address.\r\n", info.connected.ssid);
41+
case ARDUINO_EVENT_WIFI_STA_CONNECTED:
42+
Serial.printf ("Connected to %s. Asking for IP address.\r\n", info.wifi_sta_connected.ssid);
4343
break;
44-
case SYSTEM_EVENT_STA_GOT_IP:
44+
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
4545
Serial.printf ("Got IP: %s\r\n", IPAddress (info.got_ip.ip_info.ip.addr).toString ().c_str ());
4646
Serial.printf ("Connected: %s\r\n", WiFi.status () == WL_CONNECTED ? "yes" : "no");
4747
digitalWrite (ONBOARDLED, LOW); // Turn on LED
4848
wifiFirstConnected = true;
4949
break;
50-
case SYSTEM_EVENT_STA_DISCONNECTED:
51-
Serial.printf ("Disconnected from SSID: %s\n", info.disconnected.ssid);
52-
Serial.printf ("Reason: %d\n", info.disconnected.reason);
50+
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
51+
Serial.printf ("Disconnected from SSID: %s\n", info.wifi_sta_disconnected.ssid);
52+
Serial.printf ("Reason: %d\n", info.wifi_sta_disconnected.reason);
5353
digitalWrite (ONBOARDLED, HIGH); // Turn off LED
5454
//NTP.stop(); // NTP sync can be disabled to avoid sync errors
5555
WiFi.reconnect ();
@@ -125,7 +125,7 @@ void loop() {
125125
processSyncEvent (ntpEvent);
126126
}
127127

128-
if ((millis () - last) >= SHOW_TIME_PERIOD) {
128+
if ((millis () - last) > SHOW_TIME_PERIOD) {
129129
last = millis ();
130130
Serial.print (i); Serial.print (" ");
131131
Serial.print (NTP.getTimeDateStringUs ()); Serial.print (" ");

0 commit comments

Comments
 (0)