Commit b1475814 authored by Eric Duminil's avatar Eric Duminil
Browse files

wifi::connected

parent 6c4ef5bf
Pipeline #5744 canceled with stage
......@@ -88,10 +88,7 @@ void setup() {
#ifdef AMPEL_WIFI
wifi::connect(ampel.sensorId);
Serial.print(F("WiFi - Status: "));
Serial.println(WiFi.status());
if (WiFi.status() == WL_CONNECTED) {
if (wifi::connected()) {
# ifdef AMPEL_HTTP
web_server::initialize();
# endif
......@@ -203,7 +200,7 @@ void checkFlashButton() {
void keepServicesAlive() {
#ifdef AMPEL_WIFI
if (WiFi.status() == WL_CONNECTED) {
if (wifi::connected()) {
# if defined(ESP8266)
//NOTE: Sadly, there seems to be a bug in the current MDNS implementation.
// It stops working after 2 minutes. And forcing a restart leads to a memory leak.
......
......@@ -51,6 +51,10 @@ namespace wifi {
Serial.println(WIFI_SSID);
}
bool connected() {
return WiFi.status() == WL_CONNECTED;
}
// Initialize Wi-Fi
void connect(const char *hostname) {
......@@ -75,7 +79,7 @@ namespace wifi {
led_effects::showRainbowWheel();
Serial.print(".");
}
if (WiFi.status() == WL_CONNECTED) {
if (connected()) {
led_effects::showKITTWheel(color::green);
Serial.println();
Serial.print(F("WiFi - Connected! IP address: "));
......@@ -85,7 +89,8 @@ namespace wifi {
} else {
//TODO: Allow sensor to work as an Access Point, in order to define SSID & password?
led_effects::showKITTWheel(color::red);
Serial.println(F("Connection to WiFi failed"));
Serial.print(F("Connection to WiFi failed! Status : "));
Serial.println(WiFi.status());
}
}
}
......@@ -4,6 +4,7 @@
namespace wifi {
extern char local_ip[];
void connect(const char *hostname);
bool connected();
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment