forked from espressif/arduino-esp32
Update IDF to aaf1239 (#1539)
* fix sdmmc config * Fix warnings in EEPROM from @Curclamas * remove leftover TAG in EEPROM * Initial add of @stickbreaker i2c * Add log_n * fix warnings when log is off * i2c code clean up and reorganization * add flags to interrupt allocator * fix sdmmc config * Fix warnings in EEPROM from @Curclamas * remove leftover TAG in EEPROM * fix errors with latest IDF * fix debug optimization (#1365) incorrect optimization for debugging tick markers. * Fix some missing BT header * Change BTSerial log calls * Update BLE lib * Arduino-ESP32 release management scripted (#1515) * Calculate an absolute path for a custom partitions table (#1452) * * Arduino-ESP32 release management scripted (ready-to-merge) * * secure env for espressif/arduino-esp32 * * build tests enabled * gitter webhook enabled * * gitter room link fixed * better comment * * filepaths fixed * BT Serial adjustments * * don't run sketch builds & tests for tagged builds * Return false from WiFi.hostByName() if hostname is not resolved * Free BT Memory when BT is not used * WIFI_MODE_NULL is not supported anymore * Select some key examples to build with PlatformIO to save some time * Update BLE lib * Fixed BLE lib * Major WiFi overhaul - auto reconnect on connection loss now works - moved to event groups - some code clean up and procedure optimizations - new methods to get a more elaborate system ststus * Add cmake tests to travis * Add initial AsyncUDP * Add NetBIOS lib and fix CMake includes * Add Initial WebServer * Fix WebServer and examples * travis not quiting on build fail * Try different travis build * Update IDF to aaf1239 * Fix WPS Example * fix script permission and add some fail tests to sketch builder * Add missing space in WiFiClient::write(Stream &stream)
This commit is contained in:
@ -16,16 +16,28 @@ Pranav Cherukupalli <cherukupallip@gmail.com>
|
||||
|
||||
#include "WiFi.h"
|
||||
#include "esp_wps.h"
|
||||
|
||||
/*
|
||||
Change the definition of the WPS mode
|
||||
from WPS_TYPE_PBC to WPS_TYPE_PIN in
|
||||
the case that you are using pin type
|
||||
WPS
|
||||
*/
|
||||
#define ESP_WPS_MODE WPS_TYPE_PBC
|
||||
#define ESP_WPS_MODE WPS_TYPE_PBC
|
||||
#define ESP_MANUFACTURER "ESPRESSIF"
|
||||
#define ESP_MODEL_NUMBER "ESP32"
|
||||
#define ESP_MODEL_NAME "ESPRESSIF IOT"
|
||||
#define ESP_DEVICE_NAME "ESP STATION"
|
||||
|
||||
esp_wps_config_t config = WPS_CONFIG_INIT_DEFAULT(ESP_WPS_MODE);
|
||||
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);
|
||||
strcpy(config.factory_info.model_name, ESP_MODEL_NAME);
|
||||
strcpy(config.factory_info.device_name, ESP_DEVICE_NAME);
|
||||
}
|
||||
|
||||
String wpspin2string(uint8_t a[]){
|
||||
char wps_pin[9];
|
||||
@ -39,40 +51,40 @@ String wpspin2string(uint8_t a[]){
|
||||
void WiFiEvent(WiFiEvent_t event, system_event_info_t info){
|
||||
switch(event){
|
||||
case SYSTEM_EVENT_STA_START:
|
||||
Serial.println("Station Mode Started");
|
||||
break;
|
||||
Serial.println("Station Mode Started");
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_GOT_IP:
|
||||
Serial.println("Connected to :" + String(WiFi.SSID()));
|
||||
Serial.print("Got IP: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
break;
|
||||
Serial.println("Connected to :" + String(WiFi.SSID()));
|
||||
Serial.print("Got IP: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_DISCONNECTED:
|
||||
Serial.println("Disconnected from station, attempting reconnection");
|
||||
WiFi.reconnect();
|
||||
break;
|
||||
Serial.println("Disconnected from station, attempting reconnection");
|
||||
WiFi.reconnect();
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_WPS_ER_SUCCESS:
|
||||
Serial.println("WPS Successfull, stopping WPS and connecting to: " + String(WiFi.SSID()));
|
||||
esp_wifi_wps_disable();
|
||||
delay(10);
|
||||
WiFi.begin();
|
||||
break;
|
||||
Serial.println("WPS Successfull, stopping WPS and connecting to: " + String(WiFi.SSID()));
|
||||
esp_wifi_wps_disable();
|
||||
delay(10);
|
||||
WiFi.begin();
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_WPS_ER_FAILED:
|
||||
Serial.println("WPS Failed, retrying");
|
||||
esp_wifi_wps_disable();
|
||||
esp_wifi_wps_enable(&config);
|
||||
esp_wifi_wps_start(0);
|
||||
break;
|
||||
Serial.println("WPS Failed, retrying");
|
||||
esp_wifi_wps_disable();
|
||||
esp_wifi_wps_enable(&config);
|
||||
esp_wifi_wps_start(0);
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_WPS_ER_TIMEOUT:
|
||||
Serial.println("WPS Timedout, retrying");
|
||||
esp_wifi_wps_disable();
|
||||
esp_wifi_wps_enable(&config);
|
||||
esp_wifi_wps_start(0);
|
||||
break;
|
||||
Serial.println("WPS Timedout, retrying");
|
||||
esp_wifi_wps_disable();
|
||||
esp_wifi_wps_enable(&config);
|
||||
esp_wifi_wps_start(0);
|
||||
break;
|
||||
case SYSTEM_EVENT_STA_WPS_ER_PIN:
|
||||
Serial.println("WPS_PIN = " + wpspin2string(info.sta_er_pin.pin_code));
|
||||
break;
|
||||
Serial.println("WPS_PIN = " + wpspin2string(info.sta_er_pin.pin_code));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,10 +99,11 @@ void setup(){
|
||||
|
||||
Serial.println("Starting WPS");
|
||||
|
||||
wpsInitConfig();
|
||||
esp_wifi_wps_enable(&config);
|
||||
esp_wifi_wps_start(0);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
//nothing to do here
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user