26
26
#include " WiFiGeneric.h"
27
27
#include " WiFiSTA.h"
28
28
29
- extern " C" {
30
29
#include < stdint.h>
31
30
#include < stdbool.h>
32
31
#include < stdio.h>
@@ -42,9 +41,13 @@ extern "C" {
42
41
#include " lwip/dns.h"
43
42
#include < esp_smartconfig.h>
44
43
#include < esp_netif.h>
45
- #include " esp_wpa2.h"
46
44
#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
48
51
49
52
// -----------------------------------------------------------------------------------------------------------------------
50
53
// ---------------------------------------------------- Private functions ------------------------------------------------
@@ -193,19 +196,40 @@ wl_status_t WiFiSTAClass::begin(const char* wpa2_ssid, wpa2_auth_method_t method
193
196
}
194
197
195
198
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
196
202
esp_wifi_sta_wpa2_ent_set_ca_cert ((uint8_t *)ca_pem, strlen (ca_pem));
203
+ #endif
197
204
}
198
205
199
206
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
200
210
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
201
212
}
202
213
214
+ #if __has_include ("esp_eap_client.h")
215
+ esp_eap_client_set_identity ((uint8_t *)wpa2_identity, strlen (wpa2_identity));
216
+ #else
203
217
esp_wifi_sta_wpa2_ent_set_identity ((uint8_t *)wpa2_identity, strlen (wpa2_identity));
218
+ #endif
204
219
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
205
224
esp_wifi_sta_wpa2_ent_set_username ((uint8_t *)wpa2_username, strlen (wpa2_username));
206
225
esp_wifi_sta_wpa2_ent_set_password ((uint8_t *)wpa2_password, strlen (wpa2_password));
226
+ #endif
207
227
}
228
+ #if __has_include ("esp_eap_client.h")
229
+ esp_wifi_sta_enterprise_enable (); // set config settings to enable function
230
+ #else
208
231
esp_wifi_sta_wpa2_ent_enable (); // set config settings to enable function
232
+ #endif
209
233
WiFi.begin (wpa2_ssid); // connect to wifi
210
234
211
235
return status ();
0 commit comments