Guard WPA Enterprise support (#10616)

* Guard WPA Enterprise support

* guard `WIFI_ENTERPRISE_SUPPORT`

* wrong part guarded

* fix guard start and end

* add guard enterprise
This commit is contained in:
Jason2866 2024-11-20 09:42:43 +01:00 committed by GitHub
parent f5ce3f7675
commit d7b5bb111e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 0 deletions

View file

@ -421,6 +421,7 @@ bool STAClass::connect(const char *ssid, const char *passphrase, int32_t channel
return true; return true;
} }
#if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT
/** /**
* Start Wifi connection with a WPA2 Enterprise AP * Start Wifi connection with a WPA2 Enterprise AP
* if passphrase is set the most secure supported mode will be automatically selected * 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 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) { bool STAClass::disconnect(bool eraseap, unsigned long timeout) {
if (eraseap) { if (eraseap) {

View file

@ -63,6 +63,7 @@ wl_status_t WiFiSTAClass::status() {
return STA.status(); return STA.status();
} }
#if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT
wl_status_t WiFiSTAClass::begin( 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 *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 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(); 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) { wl_status_t WiFiSTAClass::begin(const char *ssid, const char *passphrase, int32_t channel, const uint8_t *bssid, bool connect) {
if (!STA.begin()) { if (!STA.begin()) {

View file

@ -54,11 +54,13 @@ public:
bool connect(); bool connect();
bool connect(const char *ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t *bssid = NULL, bool connect = true); 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( 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 *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 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 const uint8_t *bssid = 0, bool connect = true
); );
#endif /* CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT */
bool disconnect(bool eraseap = false, unsigned long timeout = 0); bool disconnect(bool eraseap = false, unsigned long timeout = 0);
bool reconnect(); bool reconnect();
bool erase(); bool erase();
@ -109,6 +111,7 @@ class WiFiSTAClass {
public: public:
STAClass STA; STAClass STA;
#if CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT
wl_status_t begin( 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 *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 char *ca_pem = NULL, const char *client_crt = NULL, const char *client_key = NULL, int ttls_phase2_type = -1, int32_t channel = 0,
@ -124,6 +127,8 @@ public:
ttls_phase2_type, channel, bssid, connect 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 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) { 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); return begin(ssid.c_str(), passphrase.c_str(), channel, bssid, connect);