From 29dc7460e9dfac976de6dcc639b35884bb3cc7e0 Mon Sep 17 00:00:00 2001 From: "Morgan 'ARR\\!' Allen" Date: Sat, 14 Sep 2019 18:52:29 -0700 Subject: [PATCH] button press to initiate wifi connection --- main/main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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);