Try to connect to WiFi for a longer time. Useful when your WiFi takes a bit longer to authenticate.
This commit is contained in:
parent
f9e6a5ebd6
commit
1d66f9c541
16
src/wifi.cpp
16
src/wifi.cpp
@ -6,11 +6,21 @@
|
|||||||
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) {
|
||||||
|
counter++;
|
||||||
|
if (counter > 100) {
|
||||||
|
Serial.print("WiFi * Connection Failed! Last result was: ");
|
||||||
|
Serial.print(result);
|
||||||
|
Serial.println(" Rebooting...");
|
||||||
|
delay(100);
|
||||||
ESP.restart();
|
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: ");
|
||||||
Serial.println(WiFi.localIP());
|
Serial.println(WiFi.localIP());
|
||||||
|
Loading…
Reference in New Issue
Block a user