Does esp_wifi_connect() adjust threshold.authmode during scanning process?
Posted: Mon Feb 16, 2026 10:53 pm
I'd like for my ESP32-S3 to connect to any WiFi station, irrespective of its security setting. After initiating esp_wifi_start() and providing the WiFi credentials during the wifi provisioning process, I currently have to disconnect the wifi connection, scan and retrieve security setting of the WiFi station I'm using, adjust threshold.authmode setting in the wifi config object, then call esp_wifi_connect() again. But I also understand that esp_wifi_connect() itself calls esp_wifi_scan_start() at some point. Is there a way for threshold.authmode to be adjusted during this esp_wifi_connect() process so the app can avoid some unnecessary, potentially redundant steps? Here are my current steps (other application logic not included below):
Complete WiFi provisioning
ESP_ERROR_CHECK(esp_wifi_stop());
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_start());
When event WIFI_EVENT_STA_START is triggered, it calls:
ESP_ERROR_CHECK(esp_wifi_get_config(WIFI_IF_STA, &wifi_sta_config));
ESP_ERROR_CHECK(esp_wifi_scan_start(&scan_config, true));
ESP_ERROR_CHECK((esp_wifi_scan_get_ap_records(&number, &ap_record));
wifi_sta_config->sta.threshold.authmode = ap_record.authmode;
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_sta_config));
esp_wifi_connect();
The code compiles, but it would be nice if esp_wifi_connect() would, by default, adjust the threshold.authmode of the WiFi station ESP32-S3 is trying to connect to. Or if that's taken care of during the provisioning process, that would be fine too. Any other options?
Complete WiFi provisioning
ESP_ERROR_CHECK(esp_wifi_stop());
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_start());
When event WIFI_EVENT_STA_START is triggered, it calls:
ESP_ERROR_CHECK(esp_wifi_get_config(WIFI_IF_STA, &wifi_sta_config));
ESP_ERROR_CHECK(esp_wifi_scan_start(&scan_config, true));
ESP_ERROR_CHECK((esp_wifi_scan_get_ap_records(&number, &ap_record));
wifi_sta_config->sta.threshold.authmode = ap_record.authmode;
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_sta_config));
esp_wifi_connect();
The code compiles, but it would be nice if esp_wifi_connect() would, by default, adjust the threshold.authmode of the WiFi station ESP32-S3 is trying to connect to. Or if that's taken care of during the provisioning process, that would be fine too. Any other options?