From 4ac795dfe79ad9886613b9427bd2f97df9970ac1 Mon Sep 17 00:00:00 2001 From: Tobias Schneider Date: Sun, 21 Mar 2021 13:14:19 +0100 Subject: [PATCH] Preventing Wi-Fi from disconnecting --- src/frame/frame_factorytest.cpp | 2 +- src/frame/frame_main.cpp | 38 +++++++++++++++++-------------- src/frame/frame_settings_wifi.cpp | 2 +- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/frame/frame_factorytest.cpp b/src/frame/frame_factorytest.cpp index 9070bea..dc568eb 100644 --- a/src/frame/frame_factorytest.cpp +++ b/src/frame/frame_factorytest.cpp @@ -153,7 +153,7 @@ void Frame_FactoryTest::drawPassCount(m5epd_update_mode_t mode) { void Frame_FactoryTest::scan(String *ssid, int32_t *rssi) { WiFi.mode(WIFI_STA); - WiFi.disconnect(); + // WiFi.disconnect(); WiFi.scanNetworks(true); int wifi_num; diff --git a/src/frame/frame_main.cpp b/src/frame/frame_main.cpp index 33ce0c0..06ec553 100644 --- a/src/frame/frame_main.cpp +++ b/src/frame/frame_main.cpp @@ -210,23 +210,27 @@ void Frame_Main::StatusBar(m5epd_update_mode_t mode) { _bar->drawString("M5Paper", 10, 27); // Wi-Fi - const uint8_t *kIMGWifiLevel[4] = { - NULL, - ImageResource_item_icon_wifi_1_32x32, - ImageResource_item_icon_wifi_2_32x32, - ImageResource_item_icon_wifi_3_32x32 - }; - if (WiFi.status() == WL_CONNECTED) { - int rssi = WiFi.RSSI(); - int level = 0; - if (rssi > -55) { - level = 3; - } else if (rssi > -88) { - level = 2; - } else { - level = 1; - } - _bar->pushImage(134, 8, 32, 32, kIMGWifiLevel[level]); + if (isWiFiConfiged()) { + const uint8_t *kIMGWifiLevel[4] = { + NULL, + ImageResource_item_icon_wifi_1_32x32, + ImageResource_item_icon_wifi_2_32x32, + ImageResource_item_icon_wifi_3_32x32 + }; + if (WiFi.status() == WL_CONNECTED) { + int rssi = WiFi.RSSI(); + int level = 0; + if (rssi > -55) { + level = 3; + } else if (rssi > -88) { + level = 2; + } else { + level = 1; + } + _bar->pushImage(134, 8, 32, 32, kIMGWifiLevel[level]); + } /* else { + WiFi.begin(GetWifiSSID(), GetWifiPassword()) + } */ } // Battery diff --git a/src/frame/frame_settings_wifi.cpp b/src/frame/frame_settings_wifi.cpp index a7756ce..b4ce416 100644 --- a/src/frame/frame_settings_wifi.cpp +++ b/src/frame/frame_settings_wifi.cpp @@ -127,7 +127,7 @@ int Frame_Settings_Wifi::scan() { } } if (connect_wifi_idx == -1) { - WiFi.disconnect(); + // WiFi.disconnect(); _key_wifi[0]->SetEnable(true); _connected = 0; for (int i = 1; i < MAX_BTN_NUM; i++) {