mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-24 15:57:14 +02:00
v2.0.0 Add support for ESP32S2 and update ESP-IDF to 4.4 (#4996)
This is very much still work in progress and much more will change before the final 2.0.0 Some APIs have changed. New libraries have been added. LittleFS included. Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Mike Dunston <m_dunston@comcast.net> Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com> Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: microDev <70126934+microDev1@users.noreply.github.com> Co-authored-by: tobozo <tobozo@users.noreply.github.com> Co-authored-by: bobobo1618 <bobobo1618@users.noreply.github.com> Co-authored-by: lorol <lorolouis@gmail.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net> Co-authored-by: Sweety <switi.mhaiske@espressif.com> Co-authored-by: Loick MAHIEUX <loick111@gmail.com> Co-authored-by: Larry Bernstone <lbernstone@gmail.com> Co-authored-by: Valerii Koval <valeros@users.noreply.github.com> Co-authored-by: 快乐的我531 <2302004040@qq.com> Co-authored-by: chegewara <imperiaonline4@gmail.com> Co-authored-by: Clemens Kirchgatterer <clemens@1541.org> Co-authored-by: Aron Rubin <aronrubin@gmail.com> Co-authored-by: Pete Lewis <601236+lewispg228@users.noreply.github.com>
This commit is contained in:
@ -31,7 +31,6 @@ WPS
|
||||
static esp_wps_config_t config;
|
||||
|
||||
void wpsInitConfig(){
|
||||
config.crypto_funcs = &g_wifi_default_wps_crypto_funcs;
|
||||
config.wps_type = ESP_WPS_MODE;
|
||||
strcpy(config.factory_info.manufacturer, ESP_MANUFACTURER);
|
||||
strcpy(config.factory_info.model_number, ESP_MODEL_NUMBER);
|
||||
@ -39,6 +38,20 @@ void wpsInitConfig(){
|
||||
strcpy(config.factory_info.device_name, ESP_DEVICE_NAME);
|
||||
}
|
||||
|
||||
void wpsStart(){
|
||||
if(esp_wifi_wps_enable(&config)){
|
||||
Serial.println("WPS Enable Failed");
|
||||
} else if(esp_wifi_wps_start(0)){
|
||||
Serial.println("WPS Start Failed");
|
||||
}
|
||||
}
|
||||
|
||||
void wpsStop(){
|
||||
if(esp_wifi_wps_disable()){
|
||||
Serial.println("WPS Disable Failed");
|
||||
}
|
||||
}
|
||||
|
||||
String wpspin2string(uint8_t a[]){
|
||||
char wps_pin[9];
|
||||
for(int i=0;i<8;i++){
|
||||
@ -48,40 +61,38 @@ String wpspin2string(uint8_t a[]){
|
||||
return (String)wps_pin;
|
||||
}
|
||||
|
||||
void WiFiEvent(WiFiEvent_t event, system_event_info_t info){
|
||||
void WiFiEvent(WiFiEvent_t event, arduino_event_info_t info){
|
||||
switch(event){
|
||||
case SYSTEM_EVENT_STA_START:
|
||||
case ARDUINO_EVENT_WIFI_STA_START:
|
||||
Serial.println("Station Mode Started");
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_GOT_IP:
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
|
||||
Serial.println("Connected to :" + String(WiFi.SSID()));
|
||||
Serial.print("Got IP: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
|
||||
Serial.println("Disconnected from station, attempting reconnection");
|
||||
WiFi.reconnect();
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_WPS_ER_SUCCESS:
|
||||
Serial.println("WPS Successful, stopping WPS and connecting to: " + String(WiFi.SSID()));
|
||||
esp_wifi_wps_disable();
|
||||
case ARDUINO_EVENT_WPS_ER_SUCCESS:
|
||||
Serial.println("WPS Successfull, stopping WPS and connecting to: " + String(WiFi.SSID()));
|
||||
wpsStop();
|
||||
delay(10);
|
||||
WiFi.begin();
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_WPS_ER_FAILED:
|
||||
case ARDUINO_EVENT_WPS_ER_FAILED:
|
||||
Serial.println("WPS Failed, retrying");
|
||||
esp_wifi_wps_disable();
|
||||
esp_wifi_wps_enable(&config);
|
||||
esp_wifi_wps_start(0);
|
||||
wpsStop();
|
||||
wpsStart();
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_WPS_ER_TIMEOUT:
|
||||
Serial.println("WPS Timeout, retrying");
|
||||
esp_wifi_wps_disable();
|
||||
esp_wifi_wps_enable(&config);
|
||||
esp_wifi_wps_start(0);
|
||||
case ARDUINO_EVENT_WPS_ER_TIMEOUT:
|
||||
Serial.println("WPS Timedout, retrying");
|
||||
wpsStop();
|
||||
wpsStart();
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_WPS_ER_PIN:
|
||||
Serial.println("WPS_PIN = " + wpspin2string(info.sta_er_pin.pin_code));
|
||||
case ARDUINO_EVENT_WPS_ER_PIN:
|
||||
Serial.println("WPS_PIN = " + wpspin2string(info.wps_er_pin.pin_code));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -91,17 +102,12 @@ void WiFiEvent(WiFiEvent_t event, system_event_info_t info){
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
delay(10);
|
||||
|
||||
Serial.println();
|
||||
|
||||
WiFi.onEvent(WiFiEvent);
|
||||
WiFi.mode(WIFI_MODE_STA);
|
||||
|
||||
Serial.println("Starting WPS");
|
||||
|
||||
wpsInitConfig();
|
||||
esp_wifi_wps_enable(&config);
|
||||
esp_wifi_wps_start(0);
|
||||
wpsStart();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
|
Reference in New Issue
Block a user