Print wifi connect status while connecting, retry ip more times

This commit is contained in:
suchmememanyskill
2023-11-14 00:45:08 +01:00
parent c5d08253a7
commit dccb10cc6f
2 changed files with 20 additions and 2 deletions

View File

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

View File

@@ -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();
}