You've already forked Adafruit_MQTT_Library
mirror of
https://github.com/adafruit/Adafruit_MQTT_Library.git
synced 2025-07-27 15:01:49 +03:00
Fixes issue with client erroneously reading a byte from 0 length packets
This commit is contained in:
@ -53,6 +53,9 @@ uint16_t Adafruit_MQTT_Client::readPacket(uint8_t *buffer, uint16_t maxlen,
|
||||
uint16_t len = 0;
|
||||
int16_t t = timeout;
|
||||
|
||||
if (maxlen == 0) { // handle zero-length packets
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (client->connected() && (timeout >= 0)) {
|
||||
//DEBUG_PRINT('.');
|
||||
@ -64,10 +67,6 @@ uint16_t Adafruit_MQTT_Client::readPacket(uint8_t *buffer, uint16_t maxlen,
|
||||
//DEBUG_PRINTLN((uint8_t)c, HEX);
|
||||
len++;
|
||||
|
||||
if (maxlen == 0) { // handle zero-length packets
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (len == maxlen) { // we read all we want, bail
|
||||
DEBUG_PRINT(F("Read data:\t"));
|
||||
DEBUG_PRINTBUFFER(buffer, len);
|
||||
|
Reference in New Issue
Block a user