Commit 847f7b2e authored by Eric Duminil's avatar Eric Duminil
Browse files

Works (Password 12345678) but still blocking

parent 80a71660
Pipeline #5894 failed with stage
in 1 minute and 24 seconds
...@@ -84,29 +84,14 @@ void setup() { ...@@ -84,29 +84,14 @@ void setup() {
#endif #endif
#ifdef AMPEL_WIFI #ifdef AMPEL_WIFI
wifi::connect(ampel.sensorId); // wifi::connect(ampel.sensorId);
Serial.print(F("WiFi - Status: ")); // Serial.print(F("WiFi - Status: "));
Serial.println(WiFi.status()); // Serial.println(WiFi.status());
if (WiFi.status() == WL_CONNECTED) {
# ifdef AMPEL_HTTP # ifdef AMPEL_HTTP
web_server::initialize(); web_server::initialize();
# endif # endif
ntp::initialize();
if (MDNS.begin(ampel.sensorId)) { // Start the mDNS responder for SENSOR_ID.local
MDNS.addService("http", "tcp", 80);
Serial.println(F("mDNS responder started"));
} else {
Serial.println(F("Error setting up MDNS responder!"));
}
# ifdef AMPEL_MQTT
mqtt::initialize(ampel.sensorId);
# endif
}
#endif #endif
#if defined(AMPEL_LORAWAN) && defined(ESP32) #if defined(AMPEL_LORAWAN) && defined(ESP32)
...@@ -199,19 +184,8 @@ void checkFlashButton() { ...@@ -199,19 +184,8 @@ void checkFlashButton() {
void keepServicesAlive() { void keepServicesAlive() {
#ifdef AMPEL_WIFI #ifdef AMPEL_WIFI
if (WiFi.status() == WL_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.
MDNS.update();
# endif
ntp::update(); // NTP client has its own timer. It will connect to NTP server every 60s.
# ifdef AMPEL_HTTP # ifdef AMPEL_HTTP
web_server::update(); web_server::update();
# endif # endif
# ifdef AMPEL_MQTT
mqtt::keepConnection(); // MQTT client has its own timer. It will keep alive every 15s.
# endif
}
#endif #endif
} }
...@@ -35,8 +35,11 @@ namespace web_server { ...@@ -35,8 +35,11 @@ namespace web_server {
WebServer http(80); WebServer http(80);
#endif #endif
AutoConnect PORTAL(http);
void update() { void update() {
http.handleClient(); // Listen for HTTP requests from clients PORTAL.handleClient();
// http.handleClient(); // Listen for HTTP requests from clients
} }
void initialize() { void initialize() {
...@@ -183,7 +186,8 @@ namespace web_server { ...@@ -183,7 +186,8 @@ namespace web_server {
http.on("/delete_csv", HTTP_POST, handleDeleteCSV); http.on("/delete_csv", HTTP_POST, handleDeleteCSV);
#endif #endif
http.onNotFound(handlePageNotFound); http.onNotFound(handlePageNotFound);
http.begin(); // http.begin();
PORTAL.begin();
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);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
# include <WebServer.h> # include <WebServer.h>
#endif #endif
#include "src/lib/AutoConnect/AutoConnect.h"
#include "config.h" #include "config.h"
#include "util.h" #include "util.h"
#include "wifi_util.h" #include "wifi_util.h"
......
Supports Markdown
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