Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For issue #223 #231

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion MQTTClient-C/src/MQTTClient.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ static int sendPacket(MQTTClient* c, int length, Timer* timer)
int rc = FAILURE,
sent = 0;

if(TimerLeftMS(timer) < MIN_SEND_PACKET_TIMEOUT_MS)
{
TimerInit(timer);
TimerCountdownMS(timer, MIN_SEND_PACKET_TIMEOUT_MS);
}
while (sent < length && !TimerIsExpired(timer))
{
rc = c->ipstack->mqttwrite(c->ipstack, &c->buf[sent], length, TimerLeftMS(timer));
rc = c->ipstack->mqttwrite(c->ipstack, &c->buf[sent], length - sent, TimerLeftMS(timer));
if (rc < 0) // there was an error writing the data
break;
sent += rc;
Expand Down
4 changes: 4 additions & 0 deletions MQTTClient-C/src/MQTTClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
#define MAX_MESSAGE_HANDLERS 5 /* redefinable - how many subscriptions do you want? */
#endif

#if !defined(MIN_SEND_PACKET_TIMEOUT_MS)
#define MIN_SEND_PACKET_TIMEOUT_MS 50 /* redefinable - minimal send timeout? */
#endif

enum QoS { QOS0, QOS1, QOS2, SUBFAIL=0x80 };

/* all failure return codes must be negative */
Expand Down