sta: fix reconnect ap when ap lost

Signed-off-by: YoungSoo Shin <shinys000114@gmail.com>
This commit is contained in:
2025-12-05 12:10:06 +09:00
parent 388e75864a
commit cefe34c7bc
3 changed files with 33 additions and 2 deletions

View File

@@ -81,6 +81,14 @@ void wifi_scan_aps(wifi_ap_record_t** ap_records, uint16_t* count)
*count = 0;
*ap_records = NULL;
wifi_set_auto_reconnect(false);
wifi_ap_record_t ap_info;
if (esp_wifi_sta_get_ap_info(&ap_info) != ESP_OK)
{
esp_wifi_disconnect();
}
// Start scan, this is a blocking call
if (esp_wifi_scan_start(NULL, true) == ESP_OK)
{
@@ -100,6 +108,16 @@ void wifi_scan_aps(wifi_ap_record_t** ap_records, uint16_t* count)
}
}
}
wifi_set_auto_reconnect(true);
if (esp_wifi_sta_get_ap_info(&ap_info) != ESP_OK)
{
if (!nconfig_value_is_not_set(WIFI_SSID))
{
wifi_connect();
}
}
}
esp_err_t wifi_get_current_ap_info(wifi_ap_record_t* ap_info)