better handle matching AP during scan
This commit is contained in:
parent
cdaa2e9132
commit
ccffb2229f
1 changed files with 10 additions and 4 deletions
|
@ -79,6 +79,8 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) {
|
||||||
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count));
|
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count));
|
||||||
|
|
||||||
if(ap_count > 0) {
|
if(ap_count > 0) {
|
||||||
|
ap_store.last = -1;
|
||||||
|
|
||||||
records = malloc(ap_count * sizeof(wifi_ap_record_t));
|
records = malloc(ap_count * sizeof(wifi_ap_record_t));
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Found %d APs", ap_count);
|
ESP_LOGI(TAG, "Found %d APs", ap_count);
|
||||||
|
@ -100,11 +102,15 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
found:
|
found:
|
||||||
|
if(ap_store.last != -1) {
|
||||||
ESP_LOGI(TAG, "Got matching ESSID: %s", ap_store.aps[ap_store.last].ssid);
|
ESP_LOGI(TAG, "Got matching ESSID: %s", ap_store.aps[ap_store.last].ssid);
|
||||||
xEventGroupClearBits(wm_event_group, WIFI_SCANNING);
|
xEventGroupClearBits(wm_event_group, WIFI_SCANNING);
|
||||||
xEventGroupSetBits(wm_event_group, WIFI_IDLE);
|
xEventGroupSetBits(wm_event_group, WIFI_IDLE);
|
||||||
|
|
||||||
wifi_manager_connect();
|
wifi_manager_connect();
|
||||||
|
} else {
|
||||||
|
ESP_LOGI(TAG, "No matching APs found");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGI(TAG, "No APs found");
|
ESP_LOGI(TAG, "No APs found");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue