main/task_wifi.c

changeset 79
332e85569339
parent 77
15dc572a7fcb
--- a/main/task_wifi.c	Tue Oct 03 19:43:22 2023 +0200
+++ b/main/task_wifi.c	Tue Oct 03 19:55:34 2023 +0200
@@ -102,6 +102,7 @@
             	/* Get the results so the memory used is freed. */
             	ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&ap_num, accessp_records));
 		ESP_LOGI(TAG, "Event wifi Scane done, %d records", ap_num);
+		_wifi_BetterAP = false;
 		for (int i = 0; i < ap_num; i++) {
 		    wifi_ap_record_t ap = accessp_records[i];
 		    ESP_LOGI(TAG, "AP:%d bssid:%02x:%02x:%02x:%02x:%02x:%02x ssid:%s ch:%d rssi:%d",
@@ -114,6 +115,10 @@
 		}
             	_wifi_Scanned = ap_num;
             	_wifi_ScanDone = true;
+		if (_wifi_BetterAP) {
+		    ESP_LOGI(TAG, "Disconnect current AP");
+		    disconnect_WiFi();
+		}
 	    	break;
 	    }
 

mercurial