WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions paho_mqtt_embedded_c/MQTTClient/src/MQTTClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,22 @@ int MQTT::Client<Network, Timer, MAX_MQTT_PACKET_SIZE, b>::readPacket(Timer& tim
}

/* 3. read the rest of the buffer using a callback to supply the rest of the data */
if (rem_len > 0 && (ipstack.read(readbuf + len, rem_len, timer.left_ms()) != rem_len))
while (rem_len > 0)
{
rc = FAILURE;
goto exit;
const int read_len = ipstack.read(readbuf + len, rem_len, timer.left_ms());
if (read_len < 0 || rem_len < read_len) // Error
{
rc = FAILURE;
goto exit;
}
if (read_len == 0) // Time out
{
rc = 0;
goto exit;
}

len += read_len;
rem_len -= read_len;
}

header.byte = readbuf[0];
Expand Down Expand Up @@ -581,7 +593,6 @@ int MQTT::Client<Network, Timer, a, b>::yield(unsigned long timeout_ms)
return rc;
}


template<class Network, class Timer, int MAX_MQTT_PACKET_SIZE, int b>
int MQTT::Client<Network, Timer, MAX_MQTT_PACKET_SIZE, b>::cycle(Timer& timer)
{
Expand Down