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

Cool. Rainbow wheel is back!

parent ab35a3ff
Pipeline #5804 passed with stage
in 2 minutes and 48 seconds
......@@ -21,4 +21,10 @@
#include "co2_sensor.h"
#include "led_effects.h"
void wifiConnected();
void wifiFailed();
void keepServicesAlive();
void checkFlashButton();
void checkSerialInput();
#endif
......@@ -56,36 +56,6 @@
* and define your credentials and parameters in 'config.h'.
*/
//void failedConnection() {
// Serial.println("Seriously. What???");
// led_effects::showKITTWheel(color::red);
//}
//
void wifiConnected() {
led_effects::showKITTWheel(color::green);
Serial.println();
Serial.print(F("WiFi - Connected! IP address: "));
IPAddress address = WiFi.localIP();
snprintf(wifi::local_ip, sizeof(wifi::local_ip), "%d.%d.%d.%d", address[0], address[1], address[2], address[3]);
Serial.println(wifi::local_ip);
ntp::initialize();
if (config::mqtt_active()) {
mqtt::initialize(ampel.sensorId);
}
Serial.print(F("You can access this sensor via http://"));
Serial.print(ampel.sensorId);
Serial.print(F(".local (might be unstable) or http://"));
Serial.println(WiFi.localIP());
}
void wifiFailed() {
Serial.print(F("WiFi - Could not connect to "));
Serial.println(config::selected_ssid()); //TODO: Rename
led_effects::showKITTWheel(color::red);
}
/*****************************************************************
* Setup *
*****************************************************************/
......@@ -122,6 +92,7 @@ void setup() {
if (config::wifi_active) {
wifi::defineCommands();
web_server::definePages();
wifi::tryConnection();
}
#if defined(ESP32)
......@@ -131,13 +102,6 @@ void setup() {
#endif
}
/*****************************************************************
* Helper functions *
*****************************************************************/
void keepServicesAlive();
void checkFlashButton();
void checkSerialInput();
/*****************************************************************
* Main loop *
*****************************************************************/
......@@ -189,6 +153,39 @@ void loop() {
}
}
/*****************************************************************
* Callbacks *
*****************************************************************/
void wifiConnected() {
led_effects::showKITTWheel(color::green);
Serial.println();
Serial.print(F("WiFi - Connected! IP address: "));
IPAddress address = WiFi.localIP();
snprintf(wifi::local_ip, sizeof(wifi::local_ip), "%d.%d.%d.%d", address[0], address[1], address[2], address[3]);
Serial.println(wifi::local_ip);
ntp::initialize();
if (config::mqtt_active()) {
mqtt::initialize(ampel.sensorId);
}
Serial.print(F("You can access this sensor via http://"));
Serial.print(ampel.sensorId);
Serial.print(F(".local (might be unstable) or http://"));
Serial.println(WiFi.localIP());
}
void wifiFailed() {
Serial.print(F("WiFi - Could not connect to "));
Serial.println(config::selected_ssid()); //TODO: Rename
led_effects::showKITTWheel(color::red);
}
/*****************************************************************
* Helper functions *
*****************************************************************/
void checkSerialInput() {
while (Serial.available() > 0) {
sensor_console::processSerialInput(Serial.read());
......
......@@ -19,6 +19,14 @@ namespace wifi {
return WiFi.status() == WL_CONNECTED;
}
void tryConnection() {
for (int i = 0; i <= 30 && !connected(); i++) {
led_effects::showRainbowWheel();
web_config::update();
Serial.print(".");
}
}
void scanNetworks() {
Serial.println();
Serial.println(F("WiFi - Scanning..."));
......
......@@ -5,6 +5,7 @@ namespace wifi {
extern char local_ip[16];
void defineCommands();
bool connected();
void tryConnection();
}
#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