From 0d8c841af589f2d292142491dc3d7eae86331466 Mon Sep 17 00:00:00 2001 From: Stuart Feichtinger Date: Sun, 31 Jan 2016 15:33:58 -0600 Subject: [PATCH] Clean up duplicate functions --- .gitignore.bts | 0 Adafruit_MQTT.cpp | 34 +--------------------------------- Adafruit_MQTT.h | 1 - 3 files changed, 1 insertion(+), 34 deletions(-) create mode 100644 .gitignore.bts diff --git a/.gitignore.bts b/.gitignore.bts new file mode 100644 index 0000000..e69de29 diff --git a/Adafruit_MQTT.cpp b/Adafruit_MQTT.cpp index 990e2ac..0120212 100644 --- a/Adafruit_MQTT.cpp +++ b/Adafruit_MQTT.cpp @@ -230,31 +230,7 @@ bool Adafruit_MQTT::disconnect() { bool Adafruit_MQTT::publish(const char *topic, const char *data, uint8_t qos) { - // Construct and send publish packet. - uint8_t len = publishPacket(buffer, topic, data, qos); - if (!sendPacket(buffer, len)) - return false; - - // If QOS level is high enough verify the response packet. - if (qos > 0) { - len = readPacket(buffer, 4, PUBLISH_TIMEOUT_MS); - DEBUG_PRINT(F("Publish QOS1+ reply:\t")); - DEBUG_PRINTBUFFER(buffer, len); - if (len != 4) - return false; - if ((buffer[0] >> 4) != MQTT_CTRL_PUBACK) - return false; - uint16_t packnum = buffer[2]; - packnum <<= 8; - packnum |= buffer[3]; - - // we increment the packet_id_counter right after publishing so inc here too to match - packnum++; - if (packnum != packet_id_counter) - return false; - } - - return true; + return publish(topic, (uint8_t*)(data), strlen(data), qos); } bool Adafruit_MQTT::publish(const char *topic, uint8_t *sData, uint8_t bLen, uint8_t qos) { @@ -529,14 +505,6 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) { return len; } -// as per http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718040 -uint8_t Adafruit_MQTT::publishPacket(uint8_t *packet, const char *topic, - const char *data, uint8_t qos) { - - return publishPacket(packet, topic, (uint8_t*)(data), strlen(data), qos); - -} - // as per http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718040 uint8_t Adafruit_MQTT::publishPacket(uint8_t *packet, const char *topic, diff --git a/Adafruit_MQTT.h b/Adafruit_MQTT.h index 3dbbac5..6940947 100644 --- a/Adafruit_MQTT.h +++ b/Adafruit_MQTT.h @@ -223,7 +223,6 @@ class Adafruit_MQTT { // Functions to generate MQTT packets. uint8_t connectPacket(uint8_t *packet); uint8_t disconnectPacket(uint8_t *packet); - uint8_t publishPacket(uint8_t *packet, const char *topic, const char *payload, uint8_t qos); uint8_t publishPacket(uint8_t *packet, const char *topic, uint8_t *payload, uint8_t bLen, uint8_t qos); uint8_t subscribePacket(uint8_t *packet, const char *topic, uint8_t qos); uint8_t unsubscribePacket(uint8_t *packet, const char *topic);