diff --git a/src/protocols/MQTT.cpp b/src/protocols/MQTT.cpp index 15797176..cf151caf 100644 --- a/src/protocols/MQTT.cpp +++ b/src/protocols/MQTT.cpp @@ -145,6 +145,10 @@ int16_t MQTTClient::disconnect() { return(_tl->closeTransportConnection()); } +int16_t MQTTClient::publish(String& topic, String& message) { + return(MQTTClient::publish(topic.c_str(), message.c_str())); +} + int16_t MQTTClient::publish(const char* topic, const char* message) { // encode packet length size_t topicLen = strlen(topic); diff --git a/src/protocols/MQTT.h b/src/protocols/MQTT.h index 73e10a52..696ec34b 100644 --- a/src/protocols/MQTT.h +++ b/src/protocols/MQTT.h @@ -35,6 +35,7 @@ class MQTTClient { // basic methods int16_t connect(const char* host, const char* clientId, const char* userName = "", const char* password = "", uint16_t keepAlive = 60, bool cleanSession = true, const char* willTopic = "", const char* willMessage = ""); int16_t disconnect(); + int16_t publish(String& topic, String& message); int16_t publish(const char* topic, const char* message); int16_t subscribe(const char* topicFilter); int16_t unsubscribe(const char* topicFilter);