@@ -27,7 +27,7 @@ static void parseMQTTBriPayload(char* payload)
2727static void onMqttConnect (bool sessionPresent)
2828{
2929 // (re)subscribe to required topics
30- char subuf[MQTT_MAX_TOPIC_LEN + 6 ];
30+ char subuf[MQTT_MAX_TOPIC_LEN + 9 ];
3131
3232 if (mqttDeviceTopic[0 ] != 0 ) {
3333 strlcpy (subuf, mqttDeviceTopic, MQTT_MAX_TOPIC_LEN + 1 );
@@ -52,6 +52,13 @@ static void onMqttConnect(bool sessionPresent)
5252 UsermodManager::onMqttConnect (sessionPresent);
5353
5454 DEBUG_PRINTLN (F (" MQTT ready" ));
55+
56+ #ifndef USERMOD_SMARTNEST
57+ strlcpy (subuf, mqttDeviceTopic, MQTT_MAX_TOPIC_LEN + 1 );
58+ strcat_P (subuf, PSTR (" /status" ));
59+ mqtt->publish (subuf, 0 , true , " online" ); // retain message for a LWT
60+ #endif
61+
5562 publishMqtt ();
5663}
5764
@@ -174,10 +181,6 @@ void publishMqtt()
174181 strcat_P (subuf, PSTR (" /c" ));
175182 mqtt->publish (subuf, 0 , retainMqttMsg, s); // optionally retain message (#2263)
176183
177- strlcpy (subuf, mqttDeviceTopic, MQTT_MAX_TOPIC_LEN + 1 );
178- strcat_P (subuf, PSTR (" /status" ));
179- mqtt->publish (subuf, 0 , true , " online" ); // retain message for a LWT
180-
181184 // TODO: use a DynamicBufferList. Requires a list-read-capable MQTT client API.
182185 DynamicBuffer buf (1024 );
183186 bufferPrint pbuf (buf.data (), buf.size ());
0 commit comments