#include #include "master.h" #include #include #include "timesync.h" // Datenstruktur für ESP-NOW Nachrichten // Datenstruktur für ESP-NOW Nachrichten typedef struct { uint8_t messageType; uint8_t buttonId; int buttonPressed; uint32_t timestamp; char messageId[33]; // 32 hex chars + null terminator for 128-bit ID } ButtonMessage; 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); }); // Start the MQTT server mqtt.begin(); } void loopMqttServer() { // Handle incoming MQTT messages mqtt.loop(); // 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!"); lastPublish = millis(); } }