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(); }