Commit 11b36705 authored by Eric Duminil's avatar Eric Duminil
Browse files

WiFi callbacks

parent d0c32222
Pipeline #5799 passed with stage
in 2 minutes and 37 seconds
...@@ -56,25 +56,12 @@ ...@@ -56,25 +56,12 @@
* and define your credentials and parameters in 'config.h'. * and define your credentials and parameters in 'config.h'.
*/ */
void failedConnection() { //void failedConnection() {
Serial.println("Seriously. What???"); // Serial.println("Seriously. What???");
led_effects::showKITTWheel(color::red); // led_effects::showKITTWheel(color::red);
} //}
//
/***************************************************************** void wifiConnected() {
* Setup *
*****************************************************************/
void setup() {
led_effects::setupOnBoardLED();
led_effects::onBoardLEDOff();
Serial.begin(BAUDS);
web_config::initialize();
if (config::wifi_active) {
web_config::setWifiConnectionCallback([]() {
//TODO: Move somewhere else
led_effects::showKITTWheel(color::green); led_effects::showKITTWheel(color::green);
Serial.println(); Serial.println();
Serial.print(F("WiFi - Connected! IP address: ")); Serial.print(F("WiFi - Connected! IP address: "));
...@@ -88,19 +75,32 @@ void setup() { ...@@ -88,19 +75,32 @@ void setup() {
mqtt::initialize(ampel.sensorId); mqtt::initialize(ampel.sensorId);
} }
//TODO: If http enabled
Serial.print(F("You can access this sensor via http://")); Serial.print(F("You can access this sensor via http://"));
Serial.print(ampel.sensorId); Serial.print(ampel.sensorId);
Serial.print(F(".local (might be unstable) or http://")); Serial.print(F(".local (might be unstable) or http://"));
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
}); }
void wifiFailed() {
Serial.print(F("WiFi - Could not connect to "));
Serial.println(config::current_ssid()); //TODO: Rename
led_effects::showKITTWheel(color::red);
}
/*****************************************************************
* Setup *
*****************************************************************/
void setup() {
led_effects::setupOnBoardLED();
led_effects::onBoardLEDOff();
web_config::setWifiFailCallback(failedConnection); Serial.begin(BAUDS);
// web_config::setWifiConnectionFailedCallback([]() { web_config::initialize();
// led_effects::showKITTWheel(color::red);
// Serial.println(F("Connection to WiFi failed")); web_config::setWifiConnectionCallback(wifiConnected);
// });
} web_config::setWifiFailCallback(wifiFailed);
pinMode(0, INPUT); // Flash button (used for forced calibration) pinMode(0, INPUT); // Flash button (used for forced calibration)
...@@ -124,8 +124,6 @@ void setup() { ...@@ -124,8 +124,6 @@ void setup() {
wifi::defineCommands(); wifi::defineCommands();
# if (AMPEL_HTTP==1) # if (AMPEL_HTTP==1)
web_server::definePages(); web_server::definePages();
//TODO: Rename. Not just web_server
// web_server::initialize();
# endif # endif
} }
......
...@@ -50,6 +50,7 @@ namespace web_config { ...@@ -50,6 +50,7 @@ namespace web_config {
"[s]").build(); "[s]").build();
//TODO: Distribute to corresponding classes, possibly with callbacks? //TODO: Distribute to corresponding classes, possibly with callbacks?
//TODO: Chainedparameters?
/** /**
* CO2 sensor * CO2 sensor
*/ */
......
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