|
1 | 1 | #include "wifi.h" |
| 2 | +#include <esp_eap_client.h> |
2 | 3 | #include <esp_err.h> |
3 | 4 | #include <esp_event.h> |
4 | 5 | #include <esp_log.h> |
5 | 6 | #include <esp_wifi.h> |
6 | | -#include <esp_wpa2.h> |
7 | 7 | #include <arpa/inet.h> |
8 | 8 | #include <inttypes.h> |
9 | 9 | #include <string.h> |
@@ -156,36 +156,37 @@ int wifi_connect(const char *ssid, const char *password, |
156 | 156 | { |
157 | 157 | if (ca_cert) |
158 | 158 | { |
159 | | - ESP_ERROR_CHECK(esp_wifi_sta_wpa2_ent_set_ca_cert((uint8_t *)ca_cert, |
| 159 | + ESP_ERROR_CHECK(esp_eap_client_set_ca_cert((uint8_t *)ca_cert, |
160 | 160 | strlen(ca_cert))); |
161 | 161 | } |
162 | 162 | if (client_cert) |
163 | 163 | { |
164 | | - ESP_ERROR_CHECK(esp_wifi_sta_wpa2_ent_set_cert_key((uint8_t *)client_cert, |
165 | | - strlen(client_cert), (uint8_t *)client_key, |
166 | | - client_key ? strlen(client_key) : 0, NULL, 0)); |
| 164 | + ESP_ERROR_CHECK(esp_eap_client_set_certificate_and_key( |
| 165 | + (uint8_t *)client_cert, strlen(client_cert), |
| 166 | + (uint8_t *)client_key, client_key ? strlen(client_key) : 0, |
| 167 | + NULL, 0)); |
167 | 168 | } |
168 | 169 | if (eap_identity) |
169 | 170 | { |
170 | | - ESP_ERROR_CHECK(esp_wifi_sta_wpa2_ent_set_identity((uint8_t *)eap_identity, |
| 171 | + ESP_ERROR_CHECK(esp_eap_client_set_identity((uint8_t *)eap_identity, |
171 | 172 | strlen(eap_identity))); |
172 | 173 | } |
173 | 174 | if (eap_method == EAP_PEAP || eap_method == EAP_TTLS) |
174 | 175 | { |
175 | 176 | if (eap_username || eap_password) |
176 | 177 | { |
177 | | - ESP_ERROR_CHECK(esp_wifi_sta_wpa2_ent_set_username((uint8_t *)eap_username, |
178 | | - strlen(eap_username))); |
179 | | - ESP_ERROR_CHECK(esp_wifi_sta_wpa2_ent_set_password((uint8_t *)eap_password, |
180 | | - strlen(eap_password))); |
| 178 | + ESP_ERROR_CHECK(esp_eap_client_set_username( |
| 179 | + (uint8_t *)eap_username, strlen(eap_username))); |
| 180 | + ESP_ERROR_CHECK(esp_eap_client_set_password( |
| 181 | + (uint8_t *)eap_password, strlen(eap_password))); |
181 | 182 | } |
182 | 183 | else |
183 | 184 | { |
184 | 185 | ESP_LOGE(TAG, "Username and password are required for " |
185 | 186 | "Tunneled TLS or Protected EAP"); |
186 | 187 | } |
187 | 188 | } |
188 | | - ESP_ERROR_CHECK(esp_wifi_sta_wpa2_ent_enable()); |
| 189 | + ESP_ERROR_CHECK(esp_wifi_sta_enterprise_enable()); |
189 | 190 | } |
190 | 191 | ESP_LOGI(TAG, "Connecting to SSID %s", wifi_config.sta.ssid); |
191 | 192 | ESP_ERROR_CHECK(esp_wifi_start()); |
|
0 commit comments