From 34c28094f17323f8d2736684ae683bffc4049a99 Mon Sep 17 00:00:00 2001 From: brentru Date: Thu, 31 Aug 2023 13:25:58 -0400 Subject: [PATCH 1/4] fix i2c decode issue --- Adafruit_MQTT.cpp | 7 +++++-- Adafruit_MQTT.h | 6 ++++++ library.properties | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Adafruit_MQTT.cpp b/Adafruit_MQTT.cpp index 0545a56..f89efd6 100644 --- a/Adafruit_MQTT.cpp +++ b/Adafruit_MQTT.cpp @@ -563,9 +563,12 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::handleSubscriptionPacket(uint16_t len) { } // Parse out length of packet. - uint16_t const topicoffset = packetAdditionalLen(len); + // NOTE: This includes data in the variable header and the payload. + uint16_t remainingLen = len - 4; // subtract the 4 header bytes + uint16_t const topicoffset = packetAdditionalLen(remainingLen); uint16_t const topicstart = topicoffset + 4; - topiclen = buffer[3 + topicoffset]; + + topiclen = int((buffer[2 + topicoffset]) << 8 | buffer[3 + topicoffset]); DEBUG_PRINT(F("Looking for subscription len ")); DEBUG_PRINTLN(topiclen); diff --git a/Adafruit_MQTT.h b/Adafruit_MQTT.h index 01b373b..71cfdd0 100644 --- a/Adafruit_MQTT.h +++ b/Adafruit_MQTT.h @@ -107,7 +107,13 @@ // Largest full packet we're able to send. // Need to be able to store at least ~90 chars for a connect packet with full // 23 char client ID. +// Future TODO: This should be replaced by the ability to +#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) || \ + defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_SAMD) +#define MAXBUFFERSIZE (512) +#else #define MAXBUFFERSIZE (150) +#endif #define MQTT_CONN_USERNAMEFLAG 0x80 #define MQTT_CONN_PASSWORDFLAG 0x40 diff --git a/library.properties b/library.properties index 24f4817..60f6d1f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Adafruit MQTT Library -version=2.5.7 +version=2.5.8 author=Adafruit maintainer=Adafruit sentence=MQTT library that supports the FONA, ESP8266, ESP32, Yun, and generic Arduino Client hardware. From 1091b17df74f9f69b2961cc69fa6289da7181d3e Mon Sep 17 00:00:00 2001 From: brentru Date: Thu, 31 Aug 2023 13:34:29 -0400 Subject: [PATCH 2/4] make more informative --- Adafruit_MQTT.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adafruit_MQTT.h b/Adafruit_MQTT.h index 71cfdd0..894104d 100644 --- a/Adafruit_MQTT.h +++ b/Adafruit_MQTT.h @@ -107,7 +107,7 @@ // Largest full packet we're able to send. // Need to be able to store at least ~90 chars for a connect packet with full // 23 char client ID. -// Future TODO: This should be replaced by the ability to +// Future TODO: This should be replaced by the ability to dynamically allocate a buffer as needed. #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) || \ defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_SAMD) #define MAXBUFFERSIZE (512) From c3d72a5a540428f5517aeac79603019a395c0b88 Mon Sep 17 00:00:00 2001 From: brentru Date: Thu, 31 Aug 2023 13:34:53 -0400 Subject: [PATCH 3/4] clang --- Adafruit_MQTT.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Adafruit_MQTT.h b/Adafruit_MQTT.h index 894104d..b440b42 100644 --- a/Adafruit_MQTT.h +++ b/Adafruit_MQTT.h @@ -107,7 +107,8 @@ // Largest full packet we're able to send. // Need to be able to store at least ~90 chars for a connect packet with full // 23 char client ID. -// Future TODO: This should be replaced by the ability to dynamically allocate a buffer as needed. +// Future TODO: This should be replaced by the ability to dynamically allocate a +// buffer as needed. #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) || \ defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_SAMD) #define MAXBUFFERSIZE (512) From 4ba2fee0e06d0921bd34cf78a921b3bc1686d8b4 Mon Sep 17 00:00:00 2001 From: brentru Date: Thu, 31 Aug 2023 13:36:49 -0400 Subject: [PATCH 4/4] increase sub data len to MAXBUFFERSIZE --- Adafruit_MQTT.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adafruit_MQTT.h b/Adafruit_MQTT.h index b440b42..6e0e132 100644 --- a/Adafruit_MQTT.h +++ b/Adafruit_MQTT.h @@ -131,7 +131,7 @@ #define SUBSCRIPTIONDATALEN 20 #else #define MAXSUBSCRIPTIONS 15 -#define SUBSCRIPTIONDATALEN 100 +#define SUBSCRIPTIONDATALEN MAXBUFFERSIZE #endif class AdafruitIO_MQTT; // forward decl