diff --git a/main/main.c b/main/main.c index 671c2b4..681637b 100644 --- a/main/main.c +++ b/main/main.c @@ -290,6 +290,19 @@ void gpio_loop() { for(;;) { if(xQueueReceive(gpio_evt_queue, &io_num, portMAX_DELAY)) { + EventBits_t ev_bits = xEventGroupGetBits(wm_event_group); + + if(ev_bits & (WIFI_SCANNING|WIFI_CONNECTING)) { + ESP_LOGI(TAG, "Scan or connection in progress..."); + continue; + } + + if((ev_bits & WIFI_CONNECTED) == 0) { + ESP_LOGI(TAG, "No connectiong, connecting"); + wifi_manager_scan(); + continue; + } + uint8_t level = gpio_get_level(io_num); printf("GPIO[%d] intr, val: %d\n", io_num, level);