From e9c18ad02f2f730c067372552853f9d8b7c7d40f Mon Sep 17 00:00:00 2001 From: Kapil Gupta Date: Wed, 13 Jul 2022 17:33:20 +0530 Subject: [PATCH] esp_wifi: set default authmode as wpa2 --- components/esp_wifi/include/esp_wifi_types.h | 3 ++- components/esp_wifi/lib | 2 +- .../getting_started/station/main/Kconfig.projbuild | 4 +++- .../station/main/station_example_main.c | 12 +++++++----- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 96c8e394c5..d93f0e97fb 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -197,7 +197,8 @@ typedef enum { /** @brief Structure describing parameters for a WiFi fast scan */ typedef struct { int8_t rssi; /**< The minimum rssi to accept in the fast scan mode */ - wifi_auth_mode_t authmode; /**< The weakest authmode to accept in the fast scan mode */ + wifi_auth_mode_t authmode; /**< The weakest authmode to accept in the fast scan mode + Note: Incase this value is not set and password is set as per WPA2 standards(password len >= 8), it will be defaulted to WPA2 and device won't connect to deprecated WEP/WPA networks. Please set authmode threshold as WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK to connect to WEP/WPA networks */ }wifi_scan_threshold_t; typedef enum { diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 1cf0524060..5c8283f629 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 1cf0524060df61fc67d1f5527775cc2956050791 +Subproject commit 5c8283f629dc4290921ef66837003d4a72b2ca72 diff --git a/examples/wifi/getting_started/station/main/Kconfig.projbuild b/examples/wifi/getting_started/station/main/Kconfig.projbuild index 2d127ee20e..a43c1b8f53 100644 --- a/examples/wifi/getting_started/station/main/Kconfig.projbuild +++ b/examples/wifi/getting_started/station/main/Kconfig.projbuild @@ -20,9 +20,11 @@ menu "Example Configuration" choice ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD prompt "WiFi Scan auth mode threshold" - default ESP_WIFI_AUTH_OPEN + default ESP_WIFI_AUTH_WPA2_PSK help The weakest authmode to accept in the scan mode. + This value defaults to ESP_WIFI_AUTH_WPA2_PSK incase password is present and ESP_WIFI_AUTH_OPEN is used. + Please select ESP_WIFI_AUTH_WEP/ESP_WIFI_AUTH_WPA_PSK incase AP is operating in WEP/WPA mode. config ESP_WIFI_AUTH_OPEN bool "OPEN" diff --git a/examples/wifi/getting_started/station/main/station_example_main.c b/examples/wifi/getting_started/station/main/station_example_main.c index 972bea9028..10cb7b35ce 100644 --- a/examples/wifi/getting_started/station/main/station_example_main.c +++ b/examples/wifi/getting_started/station/main/station_example_main.c @@ -111,11 +111,13 @@ void wifi_init_sta(void) .sta = { .ssid = EXAMPLE_ESP_WIFI_SSID, .password = EXAMPLE_ESP_WIFI_PASS, - /* Setting a password implies station will connect to all security modes including WEP/WPA. - * However these modes are deprecated and not advisable to be used. Incase your Access point - * doesn't support WPA2, these mode can be enabled by commenting below line */ - .threshold.authmode = ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD, - .sae_pwe_h2e = WPA3_SAE_PWE_BOTH, + /* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (pasword len => 8). + * If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value + * to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to + * WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards. + */ + .threshold.authmode = ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD, + .sae_pwe_h2e = WPA3_SAE_PWE_BOTH, }, }; ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );