The same here.
If I try to perform AP scan while in STA mode and already connected to an AP, the esp_wifi_scan_get_ap_num() returns 0.
This is a snippet of my code
Code: Select all
// blocking scan
err_code = esp_wifi_scan_start(NULL, true);
if (err_code != ESP_OK)
{
LOGE("esp_wifi_scan_start() failed, error: %d", err_code);
goto _exit;
}
// scan done
uint16_t ap_count = 0;
err_code = esp_wifi_scan_get_ap_num(&ap_count);
if (err_code != ESP_OK)
{
LOGE("esp_wifi_scan_get_ap_num() failed, error: %d", err_code);
goto _exit;
}
if (ap_count > 0)
{
ap_list = (wifi_ap_record_t *)malloc(ap_count * sizeof(wifi_ap_record_t));
if (ap_list == NULL)
{
goto _exit;
}
memset(ap_list, 0, ap_count * sizeof(wifi_ap_record_t));
err_code = esp_wifi_scan_get_ap_records(&ap_count, ap_list);
if (err_code != ESP_OK)
{
LOGE("esp_wifi_scan_get_ap_records() failed, error: %d", err_code);
goto _exit;
}
for (int i = 0; i < ap_count; i++)
{
// force last character of country code
ap_list[i].country.cc[2] = '\0';
LOGI("%d - %s [%d] (%d) %s", i, ap_list[i].ssid, ap_list[i].primary, ap_list[i].rssi, ap_list[i].country.cc);
}
}
When the device is in APSTA mode it works correctly.
I'm developing on eSP32-S3-DevKitC, using esp-idf v4.4.2 on Linux.