|
1 | 1 | #include "IOT.h" |
2 | 2 | #include <IotWebConfOptionalGroup.h> |
3 | 3 | #include <IotWebConfTParameter.h> |
4 | | -#include "InlineFunctions.h" |
| 4 | +#include "HelperFunctions.h" |
5 | 5 |
|
6 | 6 | namespace SwitchNotifier |
7 | 7 | { |
@@ -367,20 +367,18 @@ void IOT::Publish(const char *topic, float value, boolean retained) { |
367 | 367 | Publish(topic, buf, retained); |
368 | 368 | } |
369 | 369 |
|
370 | | -void IOT::PublishMessage(const char* topic, JsonDocument& payload) { |
371 | | - if (_mqttClient.connected()) { |
372 | | - String s; |
373 | | - serializeJson(payload, s); |
374 | | - if (_mqttClient.publish(topic, 0, false, s.c_str(), s.length()) == 0) { |
375 | | - loge("**** Payload exceeds MAX MQTT Packet Size"); |
376 | | - } |
377 | | - } |
| 370 | +void IOT::Publish(const char* topic, JsonDocument& payload, boolean retained) { |
| 371 | + String s; |
| 372 | + serializeJson(payload, s); |
| 373 | + Publish(topic, s.c_str(), retained); |
378 | 374 | } |
379 | 375 |
|
380 | 376 | void IOT::PublishTelemetery(bool online) { |
381 | | - if (_lastTelemetery != online){ |
382 | | - _lastTelemetery = online; |
383 | | - _mqttClient.publish(_willTopic, 0, true, online ? "Online": "Offline", 7); |
| 377 | + if (_mqttClient.connected()) { |
| 378 | + if (_lastTelemetery != online){ |
| 379 | + _lastTelemetery = online; |
| 380 | + _mqttClient.publish(_willTopic, 0, true, online ? "Online": "Offline", 7); |
| 381 | + } |
384 | 382 | } |
385 | 383 | } |
386 | 384 |
|
|
0 commit comments