From e6ab3a9631623d9e2f14092339fc3225be71b706 Mon Sep 17 00:00:00 2001 From: Ben Willmore Date: Wed, 2 Nov 2022 11:37:01 +0000 Subject: [PATCH] Tidy code --- Adafruit_MQTT.cpp | 13 +++++++------ Adafruit_MQTT.h | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Adafruit_MQTT.cpp b/Adafruit_MQTT.cpp index e8336db..e21653c 100644 --- a/Adafruit_MQTT.cpp +++ b/Adafruit_MQTT.cpp @@ -369,20 +369,21 @@ bool Adafruit_MQTT::publish(const char *topic, const char *data, uint8_t qos) { return publish(topic, (uint8_t*)(data), strlen(data), false, qos); } -bool Adafruit_MQTT::publish(const char *topic, uint8_t *data, uint16_t bLen, - uint8_t qos) { - return publish(topic, data, bLen, false, qos); -} - bool Adafruit_MQTT::publish(const char *topic, const char *data, bool retain, uint8_t qos) { return publish(topic, (uint8_t*)(data), strlen(data), retain, qos); } +bool Adafruit_MQTT::publish(const char *topic, uint8_t *data, uint16_t bLen, + uint8_t qos) { + return publish(topic, data, bLen, false, qos); +} + bool Adafruit_MQTT::publish(const char *topic, uint8_t *data, uint16_t bLen, bool retain, uint8_t qos) { // Construct and send publish packet. - uint16_t len = publishPacket(buffer, topic, data, bLen, retain, qos, (uint16_t)sizeof(buffer)); + uint16_t len = publishPacket(buffer, topic, data, bLen, retain, qos, + (uint16_t)sizeof(buffer)); if (!sendPacket(buffer, len)) return false; diff --git a/Adafruit_MQTT.h b/Adafruit_MQTT.h index 7ab48d7..409d1b8 100644 --- a/Adafruit_MQTT.h +++ b/Adafruit_MQTT.h @@ -190,10 +190,11 @@ public: // Publish a message to a topic using the specified QoS level. Returns true // if the message was published, false otherwise. bool publish(const char *topic, const char *payload, uint8_t qos = 0); + bool publish(const char *topic, const char *payload, bool retain, uint8_t qos = 0); bool publish(const char *topic, uint8_t *payload, uint16_t bLen, uint8_t qos = 0); - bool publish(const char *topic, const char *payload, bool retain, uint8_t qos = 0); - bool publish(const char *topic, uint8_t *payload, uint16_t bLen, bool retain, uint8_t qos = 0); + bool publish(const char *topic, uint8_t *payload, uint16_t bLen, + bool retain, uint8_t qos = 0); // Add a subscription to receive messages for a topic. Returns true if the // subscription could be added or was already present, false otherwise.