From 48520f652a2106f190da3dec3772d8072a4dd15e Mon Sep 17 00:00:00 2001 From: Sims <38142618+suchmememanyskill@users.noreply.github.com> Date: Mon, 20 Nov 2023 15:57:40 +0100 Subject: [PATCH] Print wifi connect status while connecting, retry ip more times (#3) --- CYD-Klipper/src/ui/ip_setup.cpp | 4 ++-- CYD-Klipper/src/ui/wifi_setup.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CYD-Klipper/src/ui/ip_setup.cpp b/CYD-Klipper/src/ui/ip_setup.cpp index 33cc7c6..2acb3db 100644 --- a/CYD-Klipper/src/ui/ip_setup.cpp +++ b/CYD-Klipper/src/ui/ip_setup.cpp @@ -26,11 +26,11 @@ bool verify_ip(){ } bool retry_ip_verify(){ - for (int i = 0; i < 3; i++){ + for (int i = 0; i < 5; i++){ if (verify_ip()){ return true; } - delay(500); + delay(1000); } return false; diff --git a/CYD-Klipper/src/ui/wifi_setup.cpp b/CYD-Klipper/src/ui/wifi_setup.cpp index 49e19c7..a64f65d 100644 --- a/CYD-Klipper/src/ui/wifi_setup.cpp +++ b/CYD-Klipper/src/ui/wifi_setup.cpp @@ -147,11 +147,29 @@ void wifi_init_inner(){ } } +const char* errs[] = { + "Idle", + "No SSID Available", + "Scan Completed", + "Connected", + "Connection Failed", + "Connection Lost", + "Disconnected" +}; + +const int print_freq = 1000; +int print_timer = 0; + void wifi_init(){ WiFi.mode(WIFI_STA); wifi_init_inner(); while (!global_config.wifiConfigured || WiFi.status() != WL_CONNECTED){ + if (millis() - print_timer > print_freq){ + print_timer = millis(); + Serial.printf("WiFi Status: %s\n", errs[WiFi.status()]); + } + lv_timer_handler(); lv_task_handler(); }