Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mqtt_Autofaehrschiff MQTT_Nucleo_dht11 mqtt_Testprogramm_FritzBox mqtt_TestprogrammWorkshop ... more
Revision 4:1c121432898d, committed 2021-08-17
- 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);