From 12e99ef66827a4f164af25570ffeaa3b8ea04452 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Thu, 28 Jun 2018 00:19:49 +0200 Subject: [PATCH] add wep api, restore original espressif comment (wep enabled does not prevent wpa) --- libraries/ESP8266WiFi/keywords.txt | 1 + libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp | 3 ++- libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h | 3 +++ tools/sdk/include/user_interface.h | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/ESP8266WiFi/keywords.txt b/libraries/ESP8266WiFi/keywords.txt index 0610a749b4..1e448c345f 100644 --- a/libraries/ESP8266WiFi/keywords.txt +++ b/libraries/ESP8266WiFi/keywords.txt @@ -104,6 +104,7 @@ psk KEYWORD2 BSSID KEYWORD2 BSSIDstr KEYWORD2 RSSI KEYWORD2 +enableInsecureWEP KEYWORD2 beginWPSConfig KEYWORD2 beginSmartConfig KEYWORD2 stopSmartConfig KEYWORD2 diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp index cca1c47fa2..82620e8d57 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp @@ -86,6 +86,7 @@ static bool sta_config_equal(const station_config& lhs, const station_config& rh // ----------------------------------------------------------------------------------------------------------------------- bool ESP8266WiFiSTAClass::_useStaticIp = false; +bool ESP8266WiFiSTAClass::_useInsecureWEP = false; /** * Start Wifi connection @@ -127,7 +128,7 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase, } conf.threshold.rssi = -127; - conf.open_and_wep_mode_disable = true; + conf.open_and_wep_mode_disable = !(_useInsecureWEP || *conf.password == 0); // TODO(#909): set authmode to AUTH_WPA_PSK if passphrase is provided conf.threshold.authmode = AUTH_OPEN; diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h index f08c179b5b..15283adf0b 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h @@ -82,9 +82,12 @@ class ESP8266WiFiSTAClass { int32_t RSSI(); + static void enableInsecureWEP (bool enable = true) { _useInsecureWEP = enable; } + protected: static bool _useStaticIp; + static bool _useInsecureWEP; // ---------------------------------------------------------------------------------------------- // ------------------------------------ STA remote configure ----------------------------------- diff --git a/tools/sdk/include/user_interface.h b/tools/sdk/include/user_interface.h index 767b79e03b..45768d8193 100644 --- a/tools/sdk/include/user_interface.h +++ b/tools/sdk/include/user_interface.h @@ -251,7 +251,7 @@ struct station_config { // with both ssid[] and bssid[] matched. Please check about this. uint8 bssid[6]; wifi_fast_scan_threshold_t threshold; - bool open_and_wep_mode_disable; // must be true for WPA + bool open_and_wep_mode_disable; // Can connect to open/wep router by default. }; bool wifi_station_get_config(struct station_config *config);