diff --git a/src/communication.h b/src/communication.h index b631005..78204dd 100644 --- a/src/communication.h +++ b/src/communication.h @@ -1,5 +1,6 @@ #include #include "master.h" +#include #include @@ -21,14 +22,18 @@ PicoMQTT::Server mqtt; void setupMqttServer() { + // Set up the MQTT server with the desired port // Subscribe to a topic pattern and attach a callback mqtt.subscribe("#", [](const char * topic, const char * payload) { Serial.printf("Received message in topic '%s': %s\n", topic, payload); + updateStatusLED(3); // Flash LED on message received }); // Start the MQTT server mqtt.begin(); + + Serial.println("MQTT server started on port 1883"); } void loopMqttServer() { @@ -38,7 +43,7 @@ void loopMqttServer() { // Optionally, you can publish a message periodically static unsigned long lastPublish = 0; if (millis() - lastPublish > 5000) { // Publish every 5 seconds - mqtt.publish("test/topic", "Hello from ESP32!"); + mqtt.publish("heartbeat/live", "Alive!"); lastPublish = millis(); } } diff --git a/src/master.cpp b/src/master.cpp index c00f3dd..f558f44 100644 --- a/src/master.cpp +++ b/src/master.cpp @@ -297,7 +297,8 @@ String getTimerDataJSON() { void setup() { Serial.begin(115200); - + + if (!SPIFFS.begin(true)) { Serial.println("SPIFFS Mount Failed"); return; @@ -318,7 +319,7 @@ void setup() { setupOTA(&server); setupRoutes(); - + setupLED(); setupMqttServer(); // MQTT Server initialisieren diff --git a/src/statusled.h b/src/statusled.h index 751a2e5..8394d48 100644 --- a/src/statusled.h +++ b/src/statusled.h @@ -3,10 +3,15 @@ #define LED_PIN LED_BUILTIN + // Status LED unsigned long lastLedBlink = 0; bool ledState = false; +void setupLED() { + pinMode(LED_PIN, OUTPUT); + digitalWrite(LED_PIN, LOW); // LED aus +} void updateStatusLED(int blinkPattern) { unsigned long currentTime = millis(); diff --git a/src/wificlass.h b/src/wificlass.h index 24c0d2c..b40c5c5 100644 --- a/src/wificlass.h +++ b/src/wificlass.h @@ -9,7 +9,7 @@ #include "licenceing.h" const char* ssidAP = "AquaCross-Timer"; -const char* passwordAP = "aquacross123"; +const char* passwordAP = nullptr; const char* ssidSTA = "Obiwlankenobi"; const char* passwordSTA = "Delfine1!";