# HG changeset patch # User Michiel Broek # Date 1696355734 -7200 # Node ID 332e855693397bbc5be34a266ab13c2da683e154 # Parent e03d729aecb83bc1c4ba17d02827a9499aec4792 A dirty hack to reconnect to a better AP diff -r e03d729aecb8 -r 332e85569339 main/co2meter.c --- a/main/co2meter.c Tue Oct 03 19:43:22 2023 +0200 +++ b/main/co2meter.c Tue Oct 03 19:55:34 2023 +0200 @@ -186,8 +186,8 @@ user_refresh(); if (! ready_mqtt()) connect_mqtt(true); + ESP_LOGI(TAG, "Loop => ML1_MQTT_CONNECT"); } - ESP_LOGI(TAG, "Loop => ML1_MQTT_CONNECT"); break; case ML1_MQTT_CONNECT: diff -r e03d729aecb8 -r 332e85569339 main/task_wifi.c --- 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; }