6
6
/*
7
7
* WiFi Events
8
8
9
- 0 SYSTEM_EVENT_WIFI_READY < ESP32 WiFi ready
10
- 1 SYSTEM_EVENT_SCAN_DONE < ESP32 finish scanning AP
11
- 2 SYSTEM_EVENT_STA_START < ESP32 station start
12
- 3 SYSTEM_EVENT_STA_STOP < ESP32 station stop
13
- 4 SYSTEM_EVENT_STA_CONNECTED < ESP32 station connected to AP
14
- 5 SYSTEM_EVENT_STA_DISCONNECTED < ESP32 station disconnected from AP
15
- 6 SYSTEM_EVENT_STA_AUTHMODE_CHANGE < the auth mode of AP connected by ESP32 station changed
16
- 7 SYSTEM_EVENT_STA_GOT_IP < ESP32 station got IP from connected AP
17
- 8 SYSTEM_EVENT_STA_LOST_IP < ESP32 station lost IP and the IP is reset to 0
18
- 9 SYSTEM_EVENT_STA_WPS_ER_SUCCESS < ESP32 station wps succeeds in enrollee mode
19
- 10 SYSTEM_EVENT_STA_WPS_ER_FAILED < ESP32 station wps fails in enrollee mode
20
- 11 SYSTEM_EVENT_STA_WPS_ER_TIMEOUT < ESP32 station wps timeout in enrollee mode
21
- 12 SYSTEM_EVENT_STA_WPS_ER_PIN < ESP32 station wps pin code in enrollee mode
22
- 13 SYSTEM_EVENT_AP_START < ESP32 soft-AP start
23
- 14 SYSTEM_EVENT_AP_STOP < ESP32 soft-AP stop
24
- 15 SYSTEM_EVENT_AP_STACONNECTED < a station connected to ESP32 soft-AP
25
- 16 SYSTEM_EVENT_AP_STADISCONNECTED < a station disconnected from ESP32 soft-AP
26
- 17 SYSTEM_EVENT_AP_STAIPASSIGNED < ESP32 soft-AP assign an IP to a connected station
27
- 18 SYSTEM_EVENT_AP_PROBEREQRECVED < Receive probe request packet in soft-AP interface
28
- 19 SYSTEM_EVENT_GOT_IP6 < ESP32 station or ap or ethernet interface v6IP addr is preferred
29
- 20 SYSTEM_EVENT_ETH_START < ESP32 ethernet start
30
- 21 SYSTEM_EVENT_ETH_STOP < ESP32 ethernet stop
31
- 22 SYSTEM_EVENT_ETH_CONNECTED < ESP32 ethernet phy link up
32
- 23 SYSTEM_EVENT_ETH_DISCONNECTED < ESP32 ethernet phy link down
33
- 24 SYSTEM_EVENT_ETH_GOT_IP < ESP32 ethernet got IP from connected AP
34
- 25 SYSTEM_EVENT_MAX
9
+ 0 ARDUINO_EVENT_WIFI_READY < ESP32 WiFi ready
10
+ 1 ARDUINO_EVENT_WIFI_SCAN_DONE < ESP32 finish scanning AP
11
+ 2 ARDUINO_EVENT_WIFI_STA_START < ESP32 station start
12
+ 3 ARDUINO_EVENT_WIFI_STA_STOP < ESP32 station stop
13
+ 4 ARDUINO_EVENT_WIFI_STA_CONNECTED < ESP32 station connected to AP
14
+ 5 ARDUINO_EVENT_WIFI_STA_DISCONNECTED < ESP32 station disconnected from AP
15
+ 6 ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE < the auth mode of AP connected by ESP32 station changed
16
+ 7 ARDUINO_EVENT_WIFI_STA_GOT_IP < ESP32 station got IP from connected AP
17
+ 8 ARDUINO_EVENT_WIFI_STA_LOST_IP < ESP32 station lost IP and the IP is reset to 0
18
+ 9 ARDUINO_EVENT_WPS_ER_SUCCESS < ESP32 station wps succeeds in enrollee mode
19
+ 10 ARDUINO_EVENT_WPS_ER_FAILED < ESP32 station wps fails in enrollee mode
20
+ 11 ARDUINO_EVENT_WPS_ER_TIMEOUT < ESP32 station wps timeout in enrollee mode
21
+ 12 ARDUINO_EVENT_WPS_ER_PIN < ESP32 station wps pin code in enrollee mode
22
+ 13 ARDUINO_EVENT_WIFI_AP_START < ESP32 soft-AP start
23
+ 14 ARDUINO_EVENT_WIFI_AP_STOP < ESP32 soft-AP stop
24
+ 15 ARDUINO_EVENT_WIFI_AP_STACONNECTED < a station connected to ESP32 soft-AP
25
+ 16 ARDUINO_EVENT_WIFI_AP_STADISCONNECTED < a station disconnected from ESP32 soft-AP
26
+ 17 ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED < ESP32 soft-AP assign an IP to a connected station
27
+ 18 ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED < Receive probe request packet in soft-AP interface
28
+ 19 ARDUINO_EVENT_WIFI_AP_GOT_IP6 < ESP32 ap interface v6IP addr is preferred
29
+ 19 ARDUINO_EVENT_WIFI_STA_GOT_IP6 < ESP32 station interface v6IP addr is preferred
30
+ 20 ARDUINO_EVENT_ETH_START < ESP32 ethernet start
31
+ 21 ARDUINO_EVENT_ETH_STOP < ESP32 ethernet stop
32
+ 22 ARDUINO_EVENT_ETH_CONNECTED < ESP32 ethernet phy link up
33
+ 23 ARDUINO_EVENT_ETH_DISCONNECTED < ESP32 ethernet phy link down
34
+ 24 ARDUINO_EVENT_ETH_GOT_IP < ESP32 ethernet got IP from connected AP
35
+ 19 ARDUINO_EVENT_ETH_GOT_IP6 < ESP32 ethernet interface v6IP addr is preferred
36
+ 25 ARDUINO_EVENT_MAX
35
37
*/
36
38
37
39
#include < WiFi.h>
@@ -45,80 +47,86 @@ void WiFiEvent(WiFiEvent_t event)
45
47
Serial.printf (" [WiFi-event] event: %d\n " , event);
46
48
47
49
switch (event) {
48
- case SYSTEM_EVENT_WIFI_READY :
50
+ case ARDUINO_EVENT_WIFI_READY :
49
51
Serial.println (" WiFi interface ready" );
50
52
break ;
51
- case SYSTEM_EVENT_SCAN_DONE :
53
+ case ARDUINO_EVENT_WIFI_SCAN_DONE :
52
54
Serial.println (" Completed scan for access points" );
53
55
break ;
54
- case SYSTEM_EVENT_STA_START :
56
+ case ARDUINO_EVENT_WIFI_STA_START :
55
57
Serial.println (" WiFi client started" );
56
58
break ;
57
- case SYSTEM_EVENT_STA_STOP :
59
+ case ARDUINO_EVENT_WIFI_STA_STOP :
58
60
Serial.println (" WiFi clients stopped" );
59
61
break ;
60
- case SYSTEM_EVENT_STA_CONNECTED :
62
+ case ARDUINO_EVENT_WIFI_STA_CONNECTED :
61
63
Serial.println (" Connected to access point" );
62
64
break ;
63
- case SYSTEM_EVENT_STA_DISCONNECTED :
65
+ case ARDUINO_EVENT_WIFI_STA_DISCONNECTED :
64
66
Serial.println (" Disconnected from WiFi access point" );
65
67
break ;
66
- case SYSTEM_EVENT_STA_AUTHMODE_CHANGE :
68
+ case ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE :
67
69
Serial.println (" Authentication mode of access point has changed" );
68
70
break ;
69
- case SYSTEM_EVENT_STA_GOT_IP :
71
+ case ARDUINO_EVENT_WIFI_STA_GOT_IP :
70
72
Serial.print (" Obtained IP address: " );
71
73
Serial.println (WiFi.localIP ());
72
74
break ;
73
- case SYSTEM_EVENT_STA_LOST_IP :
75
+ case ARDUINO_EVENT_WIFI_STA_LOST_IP :
74
76
Serial.println (" Lost IP address and IP address is reset to 0" );
75
77
break ;
76
- case SYSTEM_EVENT_STA_WPS_ER_SUCCESS :
78
+ case ARDUINO_EVENT_WPS_ER_SUCCESS :
77
79
Serial.println (" WiFi Protected Setup (WPS): succeeded in enrollee mode" );
78
80
break ;
79
- case SYSTEM_EVENT_STA_WPS_ER_FAILED :
81
+ case ARDUINO_EVENT_WPS_ER_FAILED :
80
82
Serial.println (" WiFi Protected Setup (WPS): failed in enrollee mode" );
81
83
break ;
82
- case SYSTEM_EVENT_STA_WPS_ER_TIMEOUT :
84
+ case ARDUINO_EVENT_WPS_ER_TIMEOUT :
83
85
Serial.println (" WiFi Protected Setup (WPS): timeout in enrollee mode" );
84
86
break ;
85
- case SYSTEM_EVENT_STA_WPS_ER_PIN :
87
+ case ARDUINO_EVENT_WPS_ER_PIN :
86
88
Serial.println (" WiFi Protected Setup (WPS): pin code in enrollee mode" );
87
89
break ;
88
- case SYSTEM_EVENT_AP_START :
90
+ case ARDUINO_EVENT_WIFI_AP_START :
89
91
Serial.println (" WiFi access point started" );
90
92
break ;
91
- case SYSTEM_EVENT_AP_STOP :
93
+ case ARDUINO_EVENT_WIFI_AP_STOP :
92
94
Serial.println (" WiFi access point stopped" );
93
95
break ;
94
- case SYSTEM_EVENT_AP_STACONNECTED :
96
+ case ARDUINO_EVENT_WIFI_AP_STACONNECTED :
95
97
Serial.println (" Client connected" );
96
98
break ;
97
- case SYSTEM_EVENT_AP_STADISCONNECTED :
99
+ case ARDUINO_EVENT_WIFI_AP_STADISCONNECTED :
98
100
Serial.println (" Client disconnected" );
99
101
break ;
100
- case SYSTEM_EVENT_AP_STAIPASSIGNED :
102
+ case ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED :
101
103
Serial.println (" Assigned IP address to client" );
102
104
break ;
103
- case SYSTEM_EVENT_AP_PROBEREQRECVED :
105
+ case ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED :
104
106
Serial.println (" Received probe request" );
105
107
break ;
106
- case SYSTEM_EVENT_GOT_IP6 :
107
- Serial.println (" IPv6 is preferred" );
108
+ case ARDUINO_EVENT_WIFI_AP_GOT_IP6 :
109
+ Serial.println (" AP IPv6 is preferred" );
108
110
break ;
109
- case SYSTEM_EVENT_ETH_START:
111
+ case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
112
+ Serial.println (" STA IPv6 is preferred" );
113
+ break ;
114
+ case ARDUINO_EVENT_ETH_GOT_IP6:
115
+ Serial.println (" Ethernet IPv6 is preferred" );
116
+ break ;
117
+ case ARDUINO_EVENT_ETH_START:
110
118
Serial.println (" Ethernet started" );
111
119
break ;
112
- case SYSTEM_EVENT_ETH_STOP :
120
+ case ARDUINO_EVENT_ETH_STOP :
113
121
Serial.println (" Ethernet stopped" );
114
122
break ;
115
- case SYSTEM_EVENT_ETH_CONNECTED :
123
+ case ARDUINO_EVENT_ETH_CONNECTED :
116
124
Serial.println (" Ethernet connected" );
117
125
break ;
118
- case SYSTEM_EVENT_ETH_DISCONNECTED :
126
+ case ARDUINO_EVENT_ETH_DISCONNECTED :
119
127
Serial.println (" Ethernet disconnected" );
120
128
break ;
121
- case SYSTEM_EVENT_ETH_GOT_IP :
129
+ case ARDUINO_EVENT_ETH_GOT_IP :
122
130
Serial.println (" Obtained IP address" );
123
131
break ;
124
132
default : break ;
@@ -142,11 +150,11 @@ void setup()
142
150
143
151
// Examples of different ways to register wifi events
144
152
WiFi.onEvent (WiFiEvent);
145
- WiFi.onEvent (WiFiGotIP, WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP );
153
+ WiFi.onEvent (WiFiGotIP, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP );
146
154
WiFiEventId_t eventID = WiFi.onEvent ([](WiFiEvent_t event, WiFiEventInfo_t info){
147
155
Serial.print (" WiFi lost connection. Reason: " );
148
156
Serial.println (info.disconnected .reason );
149
- }, WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED );
157
+ }, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED );
150
158
151
159
// Remove WiFi event
152
160
Serial.print (" WiFi Event ID: " );
0 commit comments