mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-05-02 14:30:57 +00:00
MQTT LWT
This commit is contained in:
@@ -101,6 +101,8 @@ bool AmsMqttHandler::connect() {
|
|||||||
|
|
||||||
mqttConfigChanged = false;
|
mqttConfigChanged = false;
|
||||||
mqtt.begin(mqttConfig.host, mqttConfig.port, *actualClient);
|
mqtt.begin(mqttConfig.host, mqttConfig.port, *actualClient);
|
||||||
|
String statusTopic = String(mqttConfig.publishTopic) + "/status";
|
||||||
|
mqtt.setWill(statusTopic.c_str(), "offline", true, 0);
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
if(mqttSecureClient) {
|
if(mqttSecureClient) {
|
||||||
@@ -120,6 +122,7 @@ bool AmsMqttHandler::connect() {
|
|||||||
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR(" Unable to subscribe to to [%s]\n"), mqttConfig.subscribeTopic);
|
if(debugger->isActive(RemoteDebug::ERROR)) debugger->printf_P(PSTR(" Unable to subscribe to to [%s]\n"), mqttConfig.subscribeTopic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mqtt.publish(statusTopic, "online", true, 0);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (debugger->isActive(RemoteDebug::ERROR)) {
|
if (debugger->isActive(RemoteDebug::ERROR)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user