You've already forked Adafruit_MQTT_Library
							
							
				mirror of
				https://github.com/adafruit/Adafruit_MQTT_Library.git
				synced 2025-11-03 11:53:11 +03:00 
			
		
		
		
	Merge pull request #227 from brentru/fix-msg-i2c-decode-err
Fix how subscription packet length is calculated
This commit is contained in:
		@@ -563,9 +563,12 @@ Adafruit_MQTT_Subscribe *Adafruit_MQTT::handleSubscriptionPacket(uint16_t len) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Parse out length of packet.
 | 
					  // 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;
 | 
					  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_PRINT(F("Looking for subscription len "));
 | 
				
			||||||
  DEBUG_PRINTLN(topiclen);
 | 
					  DEBUG_PRINTLN(topiclen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -107,7 +107,14 @@
 | 
				
			|||||||
// Largest full packet we're able to send.
 | 
					// Largest full packet we're able to send.
 | 
				
			||||||
// Need to be able to store at least ~90 chars for a connect packet with full
 | 
					// Need to be able to store at least ~90 chars for a connect packet with full
 | 
				
			||||||
// 23 char client ID.
 | 
					// 23 char client ID.
 | 
				
			||||||
 | 
					// 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)
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
#define MAXBUFFERSIZE (150)
 | 
					#define MAXBUFFERSIZE (150)
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define MQTT_CONN_USERNAMEFLAG 0x80
 | 
					#define MQTT_CONN_USERNAMEFLAG 0x80
 | 
				
			||||||
#define MQTT_CONN_PASSWORDFLAG 0x40
 | 
					#define MQTT_CONN_PASSWORDFLAG 0x40
 | 
				
			||||||
@@ -124,7 +131,7 @@
 | 
				
			|||||||
#define SUBSCRIPTIONDATALEN 20
 | 
					#define SUBSCRIPTIONDATALEN 20
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#define MAXSUBSCRIPTIONS 15
 | 
					#define MAXSUBSCRIPTIONS 15
 | 
				
			||||||
#define SUBSCRIPTIONDATALEN 100
 | 
					#define SUBSCRIPTIONDATALEN MAXBUFFERSIZE
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AdafruitIO_MQTT; // forward decl
 | 
					class AdafruitIO_MQTT; // forward decl
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
name=Adafruit MQTT Library
 | 
					name=Adafruit MQTT Library
 | 
				
			||||||
version=2.5.7
 | 
					version=2.5.8
 | 
				
			||||||
author=Adafruit
 | 
					author=Adafruit
 | 
				
			||||||
maintainer=Adafruit <info@adafruit.com>
 | 
					maintainer=Adafruit <info@adafruit.com>
 | 
				
			||||||
sentence=MQTT library that supports the FONA, ESP8266, ESP32, Yun, and generic Arduino Client hardware.
 | 
					sentence=MQTT library that supports the FONA, ESP8266, ESP32, Yun, and generic Arduino Client hardware.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user