|
@ -640,25 +640,34 @@ String mqttTopic(const char * magnitude, unsigned int index, bool is_set) { |
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
void mqttSendRaw(const char * topic, const char * message, bool retain) { |
|
|
|
|
|
|
|
|
bool mqttSendRaw(const char * topic, const char * message, bool retain) { |
|
|
|
|
|
|
|
|
if (_mqtt.connected()) { |
|
|
|
|
|
|
|
|
if (!_mqtt.connected()) return false; |
|
|
|
|
|
|
|
|
|
|
|
const unsigned int packetId( |
|
|
#if MQTT_LIBRARY == MQTT_LIBRARY_ASYNCMQTTCLIENT
|
|
|
#if MQTT_LIBRARY == MQTT_LIBRARY_ASYNCMQTTCLIENT
|
|
|
unsigned int packetId = _mqtt.publish(topic, _mqtt_qos, retain, message); |
|
|
|
|
|
DEBUG_MSG_P(PSTR("[MQTT] Sending %s => %s (PID %d)\n"), topic, message, packetId); |
|
|
|
|
|
|
|
|
_mqtt.publish(topic, _mqtt_qos, retain, message) |
|
|
#elif MQTT_LIBRARY == MQTT_LIBRARY_ARDUINOMQTT
|
|
|
#elif MQTT_LIBRARY == MQTT_LIBRARY_ARDUINOMQTT
|
|
|
_mqtt.publish(topic, message, retain, _mqtt_qos); |
|
|
|
|
|
DEBUG_MSG_P(PSTR("[MQTT] Sending %s => %s\n"), topic, message); |
|
|
|
|
|
|
|
|
_mqtt.publish(topic, message, retain, _mqtt_qos) |
|
|
#elif MQTT_LIBRARY == MQTT_LIBRARY_PUBSUBCLIENT
|
|
|
#elif MQTT_LIBRARY == MQTT_LIBRARY_PUBSUBCLIENT
|
|
|
_mqtt.publish(topic, message, retain); |
|
|
|
|
|
DEBUG_MSG_P(PSTR("[MQTT] Sending %s => %s\n"), topic, message); |
|
|
|
|
|
|
|
|
_mqtt.publish(topic, message, retain) |
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const size_t message_len = strlen(message); |
|
|
|
|
|
if (message_len > 128) { |
|
|
|
|
|
DEBUG_MSG_P(PSTR("[MQTT] Sending %s => (%u bytes) (PID %u)\n"), topic, message_len, packetId); |
|
|
|
|
|
} else { |
|
|
|
|
|
DEBUG_MSG_P(PSTR("[MQTT] Sending %s => %s (PID %u)\n"), topic, message, packetId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return (packetId > 0); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void mqttSendRaw(const char * topic, const char * message) { |
|
|
|
|
|
mqttSendRaw (topic, message, _mqtt_retain); |
|
|
|
|
|
|
|
|
bool mqttSendRaw(const char * topic, const char * message) { |
|
|
|
|
|
return mqttSendRaw (topic, message, _mqtt_retain); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void mqttSend(const char * topic, const char * message, bool force, bool retain) { |
|
|
void mqttSend(const char * topic, const char * message, bool force, bool retain) { |
|
|