Skip to content

Commit a844073

Browse files
authored
Update toolchains to use the tar.gz format for IDE1 compatibility (#8757)
* Update toolchains to use the tar.gz format for IDE1 compatibility * Update WiFiSTA.cpp * Implement the new EAP API for STA
1 parent 7e0f892 commit a844073

File tree

2 files changed

+123
-99
lines changed

2 files changed

+123
-99
lines changed

Diff for: libraries/WiFi/src/WiFiSTA.cpp

+27-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "WiFiGeneric.h"
2727
#include "WiFiSTA.h"
2828

29-
extern "C" {
3029
#include <stdint.h>
3130
#include <stdbool.h>
3231
#include <stdio.h>
@@ -42,9 +41,13 @@ extern "C" {
4241
#include "lwip/dns.h"
4342
#include <esp_smartconfig.h>
4443
#include <esp_netif.h>
45-
#include "esp_wpa2.h"
4644
#include "esp_mac.h"
47-
}
45+
46+
#if __has_include ("esp_eap_client.h")
47+
#include "esp_eap_client.h"
48+
#else
49+
#include "esp_wpa2.h"
50+
#endif
4851

4952
// -----------------------------------------------------------------------------------------------------------------------
5053
// ---------------------------------------------------- Private functions ------------------------------------------------
@@ -193,19 +196,40 @@ wl_status_t WiFiSTAClass::begin(const char* wpa2_ssid, wpa2_auth_method_t method
193196
}
194197

195198
if(ca_pem) {
199+
#if __has_include ("esp_eap_client.h")
200+
esp_eap_client_set_ca_cert((uint8_t *)ca_pem, strlen(ca_pem));
201+
#else
196202
esp_wifi_sta_wpa2_ent_set_ca_cert((uint8_t *)ca_pem, strlen(ca_pem));
203+
#endif
197204
}
198205

199206
if(client_crt) {
207+
#if __has_include ("esp_eap_client.h")
208+
esp_eap_client_set_certificate_and_key((uint8_t *)client_crt, strlen(client_crt), (uint8_t *)client_key, strlen(client_key), NULL, 0);
209+
#else
200210
esp_wifi_sta_wpa2_ent_set_cert_key((uint8_t *)client_crt, strlen(client_crt), (uint8_t *)client_key, strlen(client_key), NULL, 0);
211+
#endif
201212
}
202213

214+
#if __has_include ("esp_eap_client.h")
215+
esp_eap_client_set_identity((uint8_t *)wpa2_identity, strlen(wpa2_identity));
216+
#else
203217
esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)wpa2_identity, strlen(wpa2_identity));
218+
#endif
204219
if(method == WPA2_AUTH_PEAP || method == WPA2_AUTH_TTLS) {
220+
#if __has_include ("esp_eap_client.h")
221+
esp_eap_client_set_username((uint8_t *)wpa2_username, strlen(wpa2_username));
222+
esp_eap_client_set_password((uint8_t *)wpa2_password, strlen(wpa2_password));
223+
#else
205224
esp_wifi_sta_wpa2_ent_set_username((uint8_t *)wpa2_username, strlen(wpa2_username));
206225
esp_wifi_sta_wpa2_ent_set_password((uint8_t *)wpa2_password, strlen(wpa2_password));
226+
#endif
207227
}
228+
#if __has_include ("esp_eap_client.h")
229+
esp_wifi_sta_enterprise_enable(); //set config settings to enable function
230+
#else
208231
esp_wifi_sta_wpa2_ent_enable(); //set config settings to enable function
232+
#endif
209233
WiFi.begin(wpa2_ssid); //connect to wifi
210234

211235
return status();

0 commit comments

Comments
 (0)