From 5e93ab661a6505e78a410b264cb4ad5454219c40 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 18 Nov 2024 12:48:42 +0100 Subject: [PATCH 1/5] Guard WPA Enterprise support --- libraries/WiFi/src/STA.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/WiFi/src/STA.cpp b/libraries/WiFi/src/STA.cpp index a7163ba0434..547a27d1c47 100644 --- a/libraries/WiFi/src/STA.cpp +++ b/libraries/WiFi/src/STA.cpp @@ -421,6 +421,7 @@ bool STAClass::connect(const char *ssid, const char *passphrase, int32_t channel return true; } +#if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT /** * Start Wifi connection with a WPA2 Enterprise AP * if passphrase is set the most secure supported mode will be automatically selected @@ -519,6 +520,7 @@ bool STAClass::connect( return connect(wpa2_ssid, NULL, channel, bssid, tryConnect); //connect to wifi } +#endif /* CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT */ bool STAClass::disconnect(bool eraseap, unsigned long timeout) { if (eraseap) { From 3706fcfc683ed5699388a8ac8737c719d779c8a8 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:16:10 +0100 Subject: [PATCH 2/5] guard `WIFI_ENTERPRISE_SUPPORT` --- libraries/WiFi/src/WiFiSTA.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/WiFi/src/WiFiSTA.h b/libraries/WiFi/src/WiFiSTA.h index 96a3aa59dbd..d404817637e 100644 --- a/libraries/WiFi/src/WiFiSTA.h +++ b/libraries/WiFi/src/WiFiSTA.h @@ -54,11 +54,13 @@ class STAClass : public NetworkInterface { bool connect(); bool connect(const char *ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t *bssid = NULL, bool connect = true); +#if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT bool connect( const char *wpa2_ssid, wpa2_auth_method_t method, const char *wpa2_identity = NULL, const char *wpa2_username = NULL, const char *wpa2_password = NULL, const char *ca_pem = NULL, const char *client_crt = NULL, const char *client_key = NULL, int ttls_phase2_type = -1, int32_t channel = 0, const uint8_t *bssid = 0, bool connect = true ); +#endif /* CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT */ bool disconnect(bool eraseap = false, unsigned long timeout = 0); bool reconnect(); bool erase(); @@ -109,11 +111,13 @@ class WiFiSTAClass { public: STAClass STA; +#if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT wl_status_t begin( const char *wpa2_ssid, wpa2_auth_method_t method, const char *wpa2_identity = NULL, const char *wpa2_username = NULL, const char *wpa2_password = NULL, const char *ca_pem = NULL, const char *client_crt = NULL, const char *client_key = NULL, int ttls_phase2_type = -1, int32_t channel = 0, const uint8_t *bssid = 0, bool connect = true ); +#endif /* CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT */ wl_status_t begin( const String &wpa2_ssid, wpa2_auth_method_t method, const String &wpa2_identity = (const char *)NULL, const String &wpa2_username = (const char *)NULL, const String &wpa2_password = (const char *)NULL, const String &ca_pem = (const char *)NULL, const String &client_crt = (const char *)NULL, From d31f2da02548c3304f44e3ea0621a74afdaa53aa Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:20:30 +0100 Subject: [PATCH 3/5] wrong part guarded --- libraries/WiFi/src/WiFiSTA.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/WiFi/src/WiFiSTA.h b/libraries/WiFi/src/WiFiSTA.h index d404817637e..fa483d3d5ee 100644 --- a/libraries/WiFi/src/WiFiSTA.h +++ b/libraries/WiFi/src/WiFiSTA.h @@ -111,18 +111,19 @@ class WiFiSTAClass { public: STAClass STA; -#if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT wl_status_t begin( const char *wpa2_ssid, wpa2_auth_method_t method, const char *wpa2_identity = NULL, const char *wpa2_username = NULL, const char *wpa2_password = NULL, const char *ca_pem = NULL, const char *client_crt = NULL, const char *client_key = NULL, int ttls_phase2_type = -1, int32_t channel = 0, const uint8_t *bssid = 0, bool connect = true ); -#endif /* CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT */ +#if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT wl_status_t begin( const String &wpa2_ssid, wpa2_auth_method_t method, const String &wpa2_identity = (const char *)NULL, const String &wpa2_username = (const char *)NULL, const String &wpa2_password = (const char *)NULL, const String &ca_pem = (const char *)NULL, const String &client_crt = (const char *)NULL, const String &client_key = (const char *)NULL, int ttls_phase2_type = -1, int32_t channel = 0, const uint8_t *bssid = 0, bool connect = true - ) { + ) +#endif /* CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT */ + { return begin( wpa2_ssid.c_str(), method, wpa2_identity.c_str(), wpa2_username.c_str(), wpa2_password.c_str(), ca_pem.c_str(), client_crt.c_str(), client_key.c_str(), ttls_phase2_type, channel, bssid, connect From 5cb6b5099a51d3be02dc9d09eb56ff94d626cd49 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:18:51 +0100 Subject: [PATCH 4/5] fix guard start and end --- libraries/WiFi/src/WiFiSTA.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/WiFi/src/WiFiSTA.h b/libraries/WiFi/src/WiFiSTA.h index fa483d3d5ee..3c8adbd8502 100644 --- a/libraries/WiFi/src/WiFiSTA.h +++ b/libraries/WiFi/src/WiFiSTA.h @@ -111,24 +111,24 @@ class WiFiSTAClass { public: STAClass STA; +#if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT wl_status_t begin( const char *wpa2_ssid, wpa2_auth_method_t method, const char *wpa2_identity = NULL, const char *wpa2_username = NULL, const char *wpa2_password = NULL, const char *ca_pem = NULL, const char *client_crt = NULL, const char *client_key = NULL, int ttls_phase2_type = -1, int32_t channel = 0, const uint8_t *bssid = 0, bool connect = true ); -#if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT wl_status_t begin( const String &wpa2_ssid, wpa2_auth_method_t method, const String &wpa2_identity = (const char *)NULL, const String &wpa2_username = (const char *)NULL, const String &wpa2_password = (const char *)NULL, const String &ca_pem = (const char *)NULL, const String &client_crt = (const char *)NULL, const String &client_key = (const char *)NULL, int ttls_phase2_type = -1, int32_t channel = 0, const uint8_t *bssid = 0, bool connect = true - ) -#endif /* CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT */ - { + ) { return begin( wpa2_ssid.c_str(), method, wpa2_identity.c_str(), wpa2_username.c_str(), wpa2_password.c_str(), ca_pem.c_str(), client_crt.c_str(), client_key.c_str(), ttls_phase2_type, channel, bssid, connect ); } +#endif /* CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT */ + wl_status_t begin(const char *ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t *bssid = NULL, bool connect = true); wl_status_t begin(const String &ssid, const String &passphrase = (const char *)NULL, int32_t channel = 0, const uint8_t *bssid = NULL, bool connect = true) { return begin(ssid.c_str(), passphrase.c_str(), channel, bssid, connect); From 1f97325ce9302813216ee5749e32841548bfc748 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:36:57 +0100 Subject: [PATCH 5/5] add guard enterprise --- libraries/WiFi/src/WiFiSTA.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/WiFi/src/WiFiSTA.cpp b/libraries/WiFi/src/WiFiSTA.cpp index b636e692a04..b956e35ba26 100644 --- a/libraries/WiFi/src/WiFiSTA.cpp +++ b/libraries/WiFi/src/WiFiSTA.cpp @@ -63,6 +63,7 @@ wl_status_t WiFiSTAClass::status() { return STA.status(); } +#if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT wl_status_t WiFiSTAClass::begin( const char *wpa2_ssid, wpa2_auth_method_t method, const char *wpa2_identity, const char *wpa2_username, const char *wpa2_password, const char *ca_pem, const char *client_crt, const char *client_key, int ttls_phase2_type, int32_t channel, const uint8_t *bssid, bool connect @@ -77,6 +78,7 @@ wl_status_t WiFiSTAClass::begin( return STA.status(); } +#endif /* CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT */ wl_status_t WiFiSTAClass::begin(const char *ssid, const char *passphrase, int32_t channel, const uint8_t *bssid, bool connect) { if (!STA.begin()) {