add exception handling for iperf example's scan when no ap was found

This commit is contained in:
dongyou 2021-02-04 17:59:13 +08:00
parent d8082b7f39
commit 44f22150f2

View File

@ -60,6 +60,11 @@ static void scan_done_handler(void)
wifi_ap_record_t *ap_list_buffer;
esp_wifi_scan_get_ap_num(&sta_number);
if (!sta_number) {
ESP_LOGE(TAG, "No AP found");
return;
}
ap_list_buffer = malloc(sta_number * sizeof(wifi_ap_record_t));
if (ap_list_buffer == NULL) {
ESP_LOGE(TAG, "Failed to malloc buffer to print scan results");