From 913cce41af99e306f2fcaf25fcada5ca49e82c19 Mon Sep 17 00:00:00 2001 From: Todd Treece Date: Fri, 2 Oct 2015 17:10:16 -0400 Subject: [PATCH] adds zero byte client id option for 3.1.1 --- Adafruit_MQTT.cpp | 6 ++++++ Adafruit_MQTT.h | 8 ++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Adafruit_MQTT.cpp b/Adafruit_MQTT.cpp index 261e464..f038ec9 100644 --- a/Adafruit_MQTT.cpp +++ b/Adafruit_MQTT.cpp @@ -294,6 +294,12 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) { } else { if (pgm_read_byte(clientid) != 0) { p = stringprint_P(p, clientid); + } else { + p[0] = 0x0; + p++; + p[0] = 0x0; + p++; + DEBUG_PRINTLN(F("SERVER GENERATING CLIENT ID")); } } diff --git a/Adafruit_MQTT.h b/Adafruit_MQTT.h index b9a4c4a..c0f68f1 100644 --- a/Adafruit_MQTT.h +++ b/Adafruit_MQTT.h @@ -45,9 +45,7 @@ #define DEBUG_PRINTBUFFER(buffer, len) {} #endif -#ifndef MQTT_PROTOCOL_LEVEL - #define MQTT_PROTOCOL_LEVEL 4 -#endif +#define MQTT_PROTOCOL_LEVEL 4 #define MQTT_CTRL_CONNECT 0x01 #define MQTT_CTRL_CONNECTACK 0x02 @@ -65,9 +63,7 @@ #define PING_TIMEOUT_MS 500 // Adjust as necessary, in seconds. Default to 5 minutes. -#ifndef MQTT_CONN_KEEPALIVE - #define MQTT_CONN_KEEPALIVE 300 -#endif +#define MQTT_CONN_KEEPALIVE 300 // Largest full packet we're able to send. // Need to be able to store at least ~90 chars for a connect packet with full