diff --git a/Kconfig b/Kconfig index bde6f03..c39885d 100644 --- a/Kconfig +++ b/Kconfig @@ -5,6 +5,10 @@ menuconfig WIFI_MANAGER_ENABLED Select this option to enable WIFI_MANAGER driver and show the submodule with configuration if WIFI_MANAGER_ENABLED +config WIFI_MANAGER_CONNECTION_DELAY + int "# of milliseconds to wait between connection attempts" + default 1000 + config WIFI_MANAGER_TEST_AP string "ESSID for test AP" diff --git a/main/esp32-wifi-manager.c b/main/esp32-wifi-manager.c index 2dd8d2b..fee96e7 100644 --- a/main/esp32-wifi-manager.c +++ b/main/esp32-wifi-manager.c @@ -65,16 +65,17 @@ static esp_err_t wifi_event_handler(void *ctx, system_event_t *event) { break; case SYSTEM_EVENT_STA_DISCONNECTED: ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED"); + xEventGroupClearBits(wm_event_group, WIFI_CONNECTED); - // TODO: handle multiple attempt + vTaskDelay(CONFIG_WIFI_MANAGER_CONNECTION_DELAY / portTICK_PERIOD_MS); ap_store.last++; - if(ap_store.count == ap_store.last) ap_store.last = 0; + if(ap_store.count == ap_store.last) { + ap_store.last = 0; + } wifi_manager_connect(); ESP_ERROR_CHECK(esp_wifi_connect()); - - xEventGroupClearBits(wm_event_group, WIFI_CONNECTED); break; default: break;