[wifi] Avoid copying EAP config in three connect handlers (#16094)

This commit is contained in:
Jonathan Swoboda
2026-04-28 17:22:29 -04:00
committed by GitHub
parent ab6bda50e4
commit 7d6b9bee19
3 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -1099,9 +1099,9 @@ void WiFiComponent::start_connecting(const WiFiAP &ap) {
}
#ifdef USE_WIFI_WPA2_EAP
auto eap_opt = ap.get_eap();
const auto &eap_opt = ap.get_eap();
if (eap_opt.has_value()) {
EAPAuth eap_config = *eap_opt;
const EAPAuth &eap_config = *eap_opt;
// clang-format off
ESP_LOGV(
TAG,
@@ -313,10 +313,10 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
// setup enterprise authentication if required
#ifdef USE_WIFI_WPA2_EAP
auto eap_opt = ap.get_eap();
const auto &eap_opt = ap.get_eap();
if (eap_opt.has_value()) {
// note: all certificates and keys have to be null terminated. Lengths are appended by +1 to include \0.
EAPAuth eap = *eap_opt;
const EAPAuth &eap = *eap_opt;
ret = wifi_station_set_enterprise_identity((uint8_t *) eap.identity.c_str(), eap.identity.length());
if (ret) {
ESP_LOGV(TAG, "esp_wifi_sta_wpa2_ent_set_identity failed: %d", ret);
@@ -407,10 +407,10 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
// setup enterprise authentication if required
#ifdef USE_WIFI_WPA2_EAP
auto eap_opt = ap.get_eap();
const auto &eap_opt = ap.get_eap();
if (eap_opt.has_value()) {
// note: all certificates and keys have to be null terminated. Lengths are appended by +1 to include \0.
EAPAuth eap = *eap_opt;
const EAPAuth &eap = *eap_opt;
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
err = esp_eap_client_set_identity((uint8_t *) eap.identity.c_str(), eap.identity.length());
#else