From 83fc1e357ffcd63e095130b8f7b10fb88cb82493 Mon Sep 17 00:00:00 2001 From: Dirk Jahnke Date: Mon, 28 Dec 2020 17:18:19 +0100 Subject: [PATCH] Added MQTT last will and testament --- src/main.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1c2fd43..1d8eefe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,6 +40,12 @@ IPAddress mqttServerIP(192, 168, 89, 95); const char *mqttUser = "default"; const char *mqttPassword = "12345678"; +const char *lwtTopic = "doorBellGW/LWT"; +const char *lwtMessage = "Offline"; +const char *onlineMessage = "Online"; +const bool lwtRetain = true; +const int lwtQos = 2; + const char *doorBellTopic = "doorBellGW/doorbell"; const char *postboxFlapTopic = "doorBellGW/mailboxFlap"; const char *postboxDoorTopic = "doorBellGW/mailboxDoor"; @@ -91,6 +97,11 @@ struct { }; #define NUM_OUTPUTS (sizeof(myOutputs) / sizeof(myOutputs[0])) + +// Forward function declarations: +void reconnect(); +void sendMqttMessage(const char *topic, const char *message); + uint8_t getOutputIndexByPin(uint8_t pin) { for (unsigned int i=0; i