Added blinking led (pin number 2) when wifi connection failed

This commit is contained in:
Blue Fox 2022-08-22 09:28:21 +02:00
parent 646aa9fce4
commit 2b56d05cb6
2 changed files with 17 additions and 0 deletions

View File

@ -18,6 +18,9 @@ const String ntpServer = "pool.ntp.org"; // address of ntp server; may also be
const long gmtOffset_sec = 3600; // for localization (gmt = greenwich mean time); in germany: 3600
const int daylightOffset_sec = 3600; // for daylight saving
// onboard LED
const int LED_ON_WIFI_ERROR = 2;
// style of the frame shown
sFONT TITLE_FONT = Font20;
char TITLE_TEXT[] = "Losung heute";

View File

@ -1,6 +1,18 @@
#include <WiFi.h>
#include "time.h"
void blinkLED(int pin) {
pinMode(pin, OUTPUT);
delay(500);
digitalWrite(pin,HIGH);
delay(500);
digitalWrite(pin,LOW);
delay(500);
digitalWrite(pin,HIGH);
delay(500);
digitalWrite(pin,LOW);
}
bool connectWiFi() { // connect to the wifi with the above defined credentials
if(WiFi.status() == WL_CONNECTED) { return true; } // return if not connected
@ -11,9 +23,11 @@ bool connectWiFi() { // connect to the wifi with the above defined credentials
delay(2000); Serial.printf(".");
if(WiFi.status() == WL_NO_SSID_AVAIL) {
Serial.println("\n[WiFi] Failed to connect to WiFi. Reason: WL_NO_SSID_AVAIL");
blinkLED(LED_ON_WIFI_ERROR);
return false;
} else if(WiFi.status() == WL_CONNECT_FAILED) {
Serial.println("\n[WiFi] Failed to connect to WiFi. Reason: WL_CONNECT_FAILED");
blinkLED(LED_ON_WIFI_ERROR);
return false;
}
}