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 @@ ...@@ -21,4 +21,10 @@
#include "co2_sensor.h" #include "co2_sensor.h"
#include "led_effects.h" #include "led_effects.h"
void wifiConnected();
void wifiFailed();
void keepServicesAlive();
void checkFlashButton();
void checkSerialInput();
#endif #endif
...@@ -56,36 +56,6 @@ ...@@ -56,36 +56,6 @@
* and define your credentials and parameters in 'config.h'. * 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 * * Setup *
*****************************************************************/ *****************************************************************/
...@@ -122,6 +92,7 @@ void setup() { ...@@ -122,6 +92,7 @@ void setup() {
if (config::wifi_active) { if (config::wifi_active) {
wifi::defineCommands(); wifi::defineCommands();
web_server::definePages(); web_server::definePages();
wifi::tryConnection();
} }
#if defined(ESP32) #if defined(ESP32)
...@@ -131,13 +102,6 @@ void setup() { ...@@ -131,13 +102,6 @@ void setup() {
#endif #endif
} }
/*****************************************************************
* Helper functions *
*****************************************************************/
void keepServicesAlive();
void checkFlashButton();
void checkSerialInput();
/***************************************************************** /*****************************************************************
* Main loop * * Main loop *
*****************************************************************/ *****************************************************************/
...@@ -189,6 +153,39 @@ void 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() { void checkSerialInput() {
while (Serial.available() > 0) { while (Serial.available() > 0) {
sensor_console::processSerialInput(Serial.read()); sensor_console::processSerialInput(Serial.read());
......
...@@ -19,6 +19,14 @@ namespace wifi { ...@@ -19,6 +19,14 @@ namespace wifi {
return WiFi.status() == WL_CONNECTED; 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() { void scanNetworks() {
Serial.println(); Serial.println();
Serial.println(F("WiFi - Scanning...")); Serial.println(F("WiFi - Scanning..."));
......
...@@ -5,6 +5,7 @@ namespace wifi { ...@@ -5,6 +5,7 @@ namespace wifi {
extern char local_ip[16]; extern char local_ip[16];
void defineCommands(); void defineCommands();
bool connected(); bool connected();
void tryConnection();
} }
#endif #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