Skip to content

Commit d15e1b0

Browse files
committed
fix WiFi
1 parent 833e139 commit d15e1b0

File tree

18 files changed

+1087
-711
lines changed

18 files changed

+1087
-711
lines changed

cores/esp32/esp32-hal-gpio.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ extern void IRAM_ATTR __pinMode(uint8_t pin, uint8_t mode)
190190
}
191191

192192
//RTC pins PULL settings
193-
if(rtc_reg) {
193+
if(esp32_gpioMux[pin].rtc != -1) {
194194
ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_io_desc[pin].mux);
195195
if(mode & PULLUP) {
196196
ESP_REG(rtc_reg) = (ESP_REG(rtc_reg) | rtc_io_desc[pin].pullup) & ~(rtc_io_desc[pin].pulldown);

libraries/WiFi/examples/ETH_LAN8720/ETH_LAN8720.ino

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ static bool eth_connected = false;
1010
void WiFiEvent(WiFiEvent_t event)
1111
{
1212
switch (event) {
13-
case SYSTEM_EVENT_ETH_START:
13+
case ARDUINO_EVENT_ETH_START:
1414
Serial.println("ETH Started");
1515
//set eth hostname here
1616
ETH.setHostname("esp32-ethernet");
1717
break;
18-
case SYSTEM_EVENT_ETH_CONNECTED:
18+
case ARDUINO_EVENT_ETH_CONNECTED:
1919
Serial.println("ETH Connected");
2020
break;
21-
case SYSTEM_EVENT_ETH_GOT_IP:
21+
case ARDUINO_EVENT_ETH_GOT_IP:
2222
Serial.print("ETH MAC: ");
2323
Serial.print(ETH.macAddress());
2424
Serial.print(", IPv4: ");
@@ -31,11 +31,11 @@ void WiFiEvent(WiFiEvent_t event)
3131
Serial.println("Mbps");
3232
eth_connected = true;
3333
break;
34-
case SYSTEM_EVENT_ETH_DISCONNECTED:
34+
case ARDUINO_EVENT_ETH_DISCONNECTED:
3535
Serial.println("ETH Disconnected");
3636
eth_connected = false;
3737
break;
38-
case SYSTEM_EVENT_ETH_STOP:
38+
case ARDUINO_EVENT_ETH_STOP:
3939
Serial.println("ETH Stopped");
4040
eth_connected = false;
4141
break;

libraries/WiFi/examples/ETH_TLK110/ETH_TLK110.ino

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ static bool eth_connected = false;
1616
void WiFiEvent(WiFiEvent_t event)
1717
{
1818
switch (event) {
19-
case SYSTEM_EVENT_ETH_START:
19+
case ARDUINO_EVENT_ETH_START:
2020
Serial.println("ETH Started");
2121
//set eth hostname here
2222
ETH.setHostname("esp32-ethernet");
2323
break;
24-
case SYSTEM_EVENT_ETH_CONNECTED:
24+
case ARDUINO_EVENT_ETH_CONNECTED:
2525
Serial.println("ETH Connected");
2626
break;
27-
case SYSTEM_EVENT_ETH_GOT_IP:
27+
case ARDUINO_EVENT_ETH_GOT_IP:
2828
Serial.print("ETH MAC: ");
2929
Serial.print(ETH.macAddress());
3030
Serial.print(", IPv4: ");
@@ -37,11 +37,11 @@ void WiFiEvent(WiFiEvent_t event)
3737
Serial.println("Mbps");
3838
eth_connected = true;
3939
break;
40-
case SYSTEM_EVENT_ETH_DISCONNECTED:
40+
case ARDUINO_EVENT_ETH_DISCONNECTED:
4141
Serial.println("ETH Disconnected");
4242
eth_connected = false;
4343
break;
44-
case SYSTEM_EVENT_ETH_STOP:
44+
case ARDUINO_EVENT_ETH_STOP:
4545
Serial.println("ETH Stopped");
4646
eth_connected = false;
4747
break;

libraries/WiFi/examples/WPS/WPS.ino

+10-10
Original file line numberDiff line numberDiff line change
@@ -47,39 +47,39 @@ String wpspin2string(uint8_t a[]){
4747
return (String)wps_pin;
4848
}
4949

50-
void WiFiEvent(WiFiEvent_t event, system_event_info_t info){
50+
void WiFiEvent(WiFiEvent_t event, arduino_event_info_t info){
5151
switch(event){
52-
case SYSTEM_EVENT_STA_START:
52+
case ARDUINO_EVENT_WIFI_STA_START:
5353
Serial.println("Station Mode Started");
5454
break;
55-
case SYSTEM_EVENT_STA_GOT_IP:
55+
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
5656
Serial.println("Connected to :" + String(WiFi.SSID()));
5757
Serial.print("Got IP: ");
5858
Serial.println(WiFi.localIP());
5959
break;
60-
case SYSTEM_EVENT_STA_DISCONNECTED:
60+
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
6161
Serial.println("Disconnected from station, attempting reconnection");
6262
WiFi.reconnect();
6363
break;
64-
case SYSTEM_EVENT_STA_WPS_ER_SUCCESS:
65-
Serial.println("WPS Successful, stopping WPS and connecting to: " + String(WiFi.SSID()));
64+
case ARDUINO_EVENT_WPS_ER_SUCCESS:
65+
Serial.println("WPS Successfull, stopping WPS and connecting to: " + String(WiFi.SSID()));
6666
esp_wifi_wps_disable();
6767
delay(10);
6868
WiFi.begin();
6969
break;
70-
case SYSTEM_EVENT_STA_WPS_ER_FAILED:
70+
case ARDUINO_EVENT_WPS_ER_FAILED:
7171
Serial.println("WPS Failed, retrying");
7272
esp_wifi_wps_disable();
7373
esp_wifi_wps_enable(&config);
7474
esp_wifi_wps_start(0);
7575
break;
76-
case SYSTEM_EVENT_STA_WPS_ER_TIMEOUT:
77-
Serial.println("WPS Timeout, retrying");
76+
case ARDUINO_EVENT_WPS_ER_TIMEOUT:
77+
Serial.println("WPS Timedout, retrying");
7878
esp_wifi_wps_disable();
7979
esp_wifi_wps_enable(&config);
8080
esp_wifi_wps_start(0);
8181
break;
82-
case SYSTEM_EVENT_STA_WPS_ER_PIN:
82+
case ARDUINO_EVENT_WPS_ER_PIN:
8383
Serial.println("WPS_PIN = " + wpspin2string(info.sta_er_pin.pin_code));
8484
break;
8585
default:

libraries/WiFi/examples/WiFiBlueToothSwitch/WiFiBlueToothSwitch.ino

+8-8
Original file line numberDiff line numberDiff line change
@@ -75,33 +75,33 @@ void onButton(){
7575

7676
void WiFiEvent(WiFiEvent_t event){
7777
switch(event) {
78-
case SYSTEM_EVENT_AP_START:
78+
case ARDUINO_EVENT_WIFI_AP_START:
7979
Serial.println("AP Started");
8080
WiFi.softAPsetHostname(AP_SSID);
8181
break;
82-
case SYSTEM_EVENT_AP_STOP:
82+
case ARDUINO_EVENT_WIFI_AP_STOP:
8383
Serial.println("AP Stopped");
8484
break;
85-
case SYSTEM_EVENT_STA_START:
85+
case ARDUINO_EVENT_WIFI_STA_START:
8686
Serial.println("STA Started");
8787
WiFi.setHostname(AP_SSID);
8888
break;
89-
case SYSTEM_EVENT_STA_CONNECTED:
89+
case ARDUINO_EVENT_WIFI_STA_CONNECTED:
9090
Serial.println("STA Connected");
9191
WiFi.enableIpV6();
9292
break;
93-
case SYSTEM_EVENT_AP_STA_GOT_IP6:
93+
case ARDUINO_EVENT_WIFI_AP_STA_GOT_IP6:
9494
Serial.print("STA IPv6: ");
9595
Serial.println(WiFi.localIPv6());
9696
break;
97-
case SYSTEM_EVENT_STA_GOT_IP:
97+
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
9898
Serial.print("STA IPv4: ");
9999
Serial.println(WiFi.localIP());
100100
break;
101-
case SYSTEM_EVENT_STA_DISCONNECTED:
101+
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
102102
Serial.println("STA Disconnected");
103103
break;
104-
case SYSTEM_EVENT_STA_STOP:
104+
case ARDUINO_EVENT_WIFI_STA_STOP:
105105
Serial.println("STA Stopped");
106106
break;
107107
default:

libraries/WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino

+62-54
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,34 @@
66
/*
77
* WiFi Events
88
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
3537
*/
3638

3739
#include <WiFi.h>
@@ -45,80 +47,86 @@ void WiFiEvent(WiFiEvent_t event)
4547
Serial.printf("[WiFi-event] event: %d\n", event);
4648

4749
switch (event) {
48-
case SYSTEM_EVENT_WIFI_READY:
50+
case ARDUINO_EVENT_WIFI_READY:
4951
Serial.println("WiFi interface ready");
5052
break;
51-
case SYSTEM_EVENT_SCAN_DONE:
53+
case ARDUINO_EVENT_WIFI_SCAN_DONE:
5254
Serial.println("Completed scan for access points");
5355
break;
54-
case SYSTEM_EVENT_STA_START:
56+
case ARDUINO_EVENT_WIFI_STA_START:
5557
Serial.println("WiFi client started");
5658
break;
57-
case SYSTEM_EVENT_STA_STOP:
59+
case ARDUINO_EVENT_WIFI_STA_STOP:
5860
Serial.println("WiFi clients stopped");
5961
break;
60-
case SYSTEM_EVENT_STA_CONNECTED:
62+
case ARDUINO_EVENT_WIFI_STA_CONNECTED:
6163
Serial.println("Connected to access point");
6264
break;
63-
case SYSTEM_EVENT_STA_DISCONNECTED:
65+
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
6466
Serial.println("Disconnected from WiFi access point");
6567
break;
66-
case SYSTEM_EVENT_STA_AUTHMODE_CHANGE:
68+
case ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE:
6769
Serial.println("Authentication mode of access point has changed");
6870
break;
69-
case SYSTEM_EVENT_STA_GOT_IP:
71+
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
7072
Serial.print("Obtained IP address: ");
7173
Serial.println(WiFi.localIP());
7274
break;
73-
case SYSTEM_EVENT_STA_LOST_IP:
75+
case ARDUINO_EVENT_WIFI_STA_LOST_IP:
7476
Serial.println("Lost IP address and IP address is reset to 0");
7577
break;
76-
case SYSTEM_EVENT_STA_WPS_ER_SUCCESS:
78+
case ARDUINO_EVENT_WPS_ER_SUCCESS:
7779
Serial.println("WiFi Protected Setup (WPS): succeeded in enrollee mode");
7880
break;
79-
case SYSTEM_EVENT_STA_WPS_ER_FAILED:
81+
case ARDUINO_EVENT_WPS_ER_FAILED:
8082
Serial.println("WiFi Protected Setup (WPS): failed in enrollee mode");
8183
break;
82-
case SYSTEM_EVENT_STA_WPS_ER_TIMEOUT:
84+
case ARDUINO_EVENT_WPS_ER_TIMEOUT:
8385
Serial.println("WiFi Protected Setup (WPS): timeout in enrollee mode");
8486
break;
85-
case SYSTEM_EVENT_STA_WPS_ER_PIN:
87+
case ARDUINO_EVENT_WPS_ER_PIN:
8688
Serial.println("WiFi Protected Setup (WPS): pin code in enrollee mode");
8789
break;
88-
case SYSTEM_EVENT_AP_START:
90+
case ARDUINO_EVENT_WIFI_AP_START:
8991
Serial.println("WiFi access point started");
9092
break;
91-
case SYSTEM_EVENT_AP_STOP:
93+
case ARDUINO_EVENT_WIFI_AP_STOP:
9294
Serial.println("WiFi access point stopped");
9395
break;
94-
case SYSTEM_EVENT_AP_STACONNECTED:
96+
case ARDUINO_EVENT_WIFI_AP_STACONNECTED:
9597
Serial.println("Client connected");
9698
break;
97-
case SYSTEM_EVENT_AP_STADISCONNECTED:
99+
case ARDUINO_EVENT_WIFI_AP_STADISCONNECTED:
98100
Serial.println("Client disconnected");
99101
break;
100-
case SYSTEM_EVENT_AP_STAIPASSIGNED:
102+
case ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED:
101103
Serial.println("Assigned IP address to client");
102104
break;
103-
case SYSTEM_EVENT_AP_PROBEREQRECVED:
105+
case ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED:
104106
Serial.println("Received probe request");
105107
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");
108110
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:
110118
Serial.println("Ethernet started");
111119
break;
112-
case SYSTEM_EVENT_ETH_STOP:
120+
case ARDUINO_EVENT_ETH_STOP:
113121
Serial.println("Ethernet stopped");
114122
break;
115-
case SYSTEM_EVENT_ETH_CONNECTED:
123+
case ARDUINO_EVENT_ETH_CONNECTED:
116124
Serial.println("Ethernet connected");
117125
break;
118-
case SYSTEM_EVENT_ETH_DISCONNECTED:
126+
case ARDUINO_EVENT_ETH_DISCONNECTED:
119127
Serial.println("Ethernet disconnected");
120128
break;
121-
case SYSTEM_EVENT_ETH_GOT_IP:
129+
case ARDUINO_EVENT_ETH_GOT_IP:
122130
Serial.println("Obtained IP address");
123131
break;
124132
default: break;
@@ -142,11 +150,11 @@ void setup()
142150

143151
// Examples of different ways to register wifi events
144152
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);
146154
WiFiEventId_t eventID = WiFi.onEvent([](WiFiEvent_t event, WiFiEventInfo_t info){
147155
Serial.print("WiFi lost connection. Reason: ");
148156
Serial.println(info.disconnected.reason);
149-
}, WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED);
157+
}, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
150158

151159
// Remove WiFi event
152160
Serial.print("WiFi Event ID: ");

libraries/WiFi/examples/WiFiIPv6/WiFiIPv6.ino

+8-7
Original file line numberDiff line numberDiff line change
@@ -67,33 +67,34 @@ void wifiConnectedLoop(){
6767
void WiFiEvent(WiFiEvent_t event){
6868
switch(event) {
6969

70-
case SYSTEM_EVENT_AP_START:
70+
case ARDUINO_EVENT_WIFI_AP_START:
7171
//can set ap hostname here
7272
WiFi.softAPsetHostname(AP_SSID);
7373
//enable ap ipv6 here
7474
WiFi.softAPenableIpV6();
7575
break;
7676

77-
case SYSTEM_EVENT_STA_START:
77+
case ARDUINO_EVENT_WIFI_STA_START:
7878
//set sta hostname here
7979
WiFi.setHostname(AP_SSID);
8080
break;
81-
case SYSTEM_EVENT_STA_CONNECTED:
81+
case ARDUINO_EVENT_WIFI_STA_CONNECTED:
8282
//enable sta ipv6 here
8383
WiFi.enableIpV6();
8484
break;
85-
case SYSTEM_EVENT_AP_STA_GOT_IP6:
86-
//both interfaces get the same event
85+
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
8786
Serial.print("STA IPv6: ");
8887
Serial.println(WiFi.localIPv6());
88+
break;
89+
case ARDUINO_EVENT_WIFI_AP_GOT_IP6:
8990
Serial.print("AP IPv6: ");
9091
Serial.println(WiFi.softAPIPv6());
9192
break;
92-
case SYSTEM_EVENT_STA_GOT_IP:
93+
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
9394
wifiOnConnect();
9495
wifi_connected = true;
9596
break;
96-
case SYSTEM_EVENT_STA_DISCONNECTED:
97+
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
9798
wifi_connected = false;
9899
wifiOnDisconnect();
99100
break;

0 commit comments

Comments
 (0)