add connection delay between attempts

This commit is contained in:
Morgan Allen 2018-09-21 22:12:17 -07:00
parent de8f1a4e4f
commit 349b0b4ff3
2 changed files with 9 additions and 4 deletions

View File

@ -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"

View File

@ -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;