Try to connect to WiFi for a longer time. Useful when your WiFi takes a bit longer to authenticate.

This commit is contained in:
Fabian Schlenz 2020-11-04 06:00:24 +01:00
parent f9e6a5ebd6
commit 1d66f9c541

View File

@ -6,10 +6,20 @@
void wifi_setup() { void wifi_setup() {
WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASS); WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.waitForConnectResult() != WL_CONNECTED) { uint8_t result;
Serial.println("WiFi * Connection Failed! Rebooting..."); uint8_t counter = 0;
delay(5000); while ((result = WiFi.waitForConnectResult()) != WL_CONNECTED) {
ESP.restart(); counter++;
if (counter > 100) {
Serial.print("WiFi * Connection Failed! Last result was: ");
Serial.print(result);
Serial.println(" Rebooting...");
delay(100);
ESP.restart();
}
Serial.print("WiFi * Still waiting for WiFi to connect. This is loop number ");
Serial.println(counter);
delay(100);
} }
Serial.println("WiFi * Ready"); Serial.println("WiFi * Ready");
Serial.print("WiFi * IP address: "); Serial.print("WiFi * IP address: ");