Jack Hansdampf / ESP8266MQTT

Dependencies:   mbed-mqtt-GSOE1

Dependents:   mqtt_Autofaehrschiff MQTT_Nucleo_dht11 mqtt_Testprogramm_FritzBox mqtt_TestprogrammWorkshop ... more

Files at this revision

API Documentation at this revision

Comitter:
jack1930
Date:
Tue Aug 17 16:40:44 2021 +0000
Parent:
3:d8582413a5a1
Child:
5:145eff603968
Commit message:
publish mit qos und retain

Changed in this revision

PubSubClient.cpp Show annotated file Show diff for this revision Revisions of this file
PubSubClient.h Show annotated file Show diff for this revision Revisions of this file
--- a/PubSubClient.cpp	Tue Jul 13 06:14:41 2021 +0000
+++ b/PubSubClient.cpp	Tue Aug 17 16:40:44 2021 +0000
@@ -77,11 +77,32 @@
 int PubSubClient::publish(const char* topic, const char* buf)
 {
         msg.payload = (void*)buf;
+        msg.qos=QOS0;
+        msg.retained=false;
         msg.payloadlen = strlen(buf);
         int ret=client->publish(topic, msg);
         return ret;
 }
 
+int PubSubClient::publish(const char* topic, const char* buf, MQTT::QoS qos)
+{
+        msg.payload = (void*)buf;
+        msg.qos=qos;
+        msg.retained=false;
+        msg.payloadlen = strlen(buf);
+        int ret=client->publish(topic, msg);
+        return ret;
+}
+
+int PubSubClient::publish(const char* topic, const char* buf, MQTT::QoS qos, bool retain)
+{
+        msg.payload = (void*)buf;
+        msg.qos=qos;
+        msg.retained=retain;
+        msg.payloadlen = strlen(buf);
+        int ret=client->publish(topic, msg);
+        return ret;
+}
 
 int PubSubClient::subscribe(const char* topicFilter, MQTT::QoS qos, MQTTClient::messageHandler mh)
 {
--- a/PubSubClient.h	Tue Jul 13 06:14:41 2021 +0000
+++ b/PubSubClient.h	Tue Aug 17 16:40:44 2021 +0000
@@ -30,6 +30,8 @@
     PubSubClient();
     bool connect(char* clientName);
     int publish(const char* topic, const char* buf);
+    int publish(const char* topic, const char* buf, MQTT::QoS qos);
+    int publish(const char* topic, const char* buf, MQTT::QoS qos, bool retain);
     int subscribe(const char* topicFilter, MQTT::QoS qos, MQTTClient::messageHandler mh);
     //int subscribe(const char* topic,Callback< void(string)> func);
     //static void subscribeCallback(MessageData& mymessage);