From 2dc81950d4f2af0b9ca43c5ce7774ca4fd7bcae0 Mon Sep 17 00:00:00 2001 From: Morgan Allen Date: Fri, 21 Sep 2018 23:22:54 -0700 Subject: [PATCH] move CONNECTING bitsetting to _connect and reset _IDLE --- main/esp32-wifi-manager.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main/esp32-wifi-manager.c b/main/esp32-wifi-manager.c index bf32474..12aaa36 100644 --- a/main/esp32-wifi-manager.c +++ b/main/esp32-wifi-manager.c @@ -106,7 +106,10 @@ void wifi_manager_connect() { } }; - ESP_LOGI(TAG, "connecting to AP %d of %d", ap_store.last, ap_store.count); + xEventGroupSetBits(wm_event_group, WIFI_CONNECTING); + xEventGroupClearBits(wm_event_group, WIFI_IDLE); + + ESP_LOGI(TAG, "connecting to AP %d of %d", ap_store.last + 1, ap_store.count); memcpy((char *)&wifi_config.sta.ssid, ap_store.aps[ap_store.last].ssid, strlen(ap_store.aps[ap_store.last].ssid) + 1); memcpy((char *)&wifi_config.sta.password, ap_store.aps[ap_store.last].password, strlen(ap_store.aps[ap_store.last].password) + 1); @@ -131,8 +134,6 @@ void wifi_manager_main_loop() { if(ev_bits & AP_AVAILABLE && (ev_bits & WIFI_CONNECTING) == 0) { ESP_LOGI(TAG, "AP Available, starting WiFi connect"); - xEventGroupSetBits(wm_event_group, WIFI_CONNECTING); - wifi_manager_connect(); }