Skip to content

Commit a78c24c

Browse files
committed
For issue eclipse-paho#223
- In the sendPacket() function, when timer is expired mqttwrite() function is not excute. So to give it a change to send ack packet (issue eclipse-paho#223), we need to define a minimal timeout - The send packet timeout is defined by MIN_SEND_PACKET_TIMEOUT_MS macro
1 parent 29ab2aa commit a78c24c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

MQTTClient-C/src/MQTTClient.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ static int sendPacket(MQTTClient* c, int length, Timer* timer)
3636
int rc = FAILURE,
3737
sent = 0;
3838

39+
if(TimerLeftMS(timer) < MIN_SEND_PACKET_TIMEOUT_MS)
40+
{
41+
TimerInit(timer);
42+
TimerCountdownMS(timer, MIN_SEND_PACKET_TIMEOUT_MS);
43+
}
3944
while (sent < length && !TimerIsExpired(timer))
4045
{
4146
rc = c->ipstack->mqttwrite(c->ipstack, &c->buf[sent], length, TimerLeftMS(timer));

MQTTClient-C/src/MQTTClient.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
#define MAX_MESSAGE_HANDLERS 5 /* redefinable - how many subscriptions do you want? */
5252
#endif
5353

54+
#if !defined(MIN_SEND_PACKET_TIMEOUT_MS)
55+
#define MIN_SEND_PACKET_TIMEOUT_MS 50 /* redefinable - minimal send timeout? */
56+
#endif
57+
5458
enum QoS { QOS0, QOS1, QOS2, SUBFAIL=0x80 };
5559

5660
/* all failure return codes must be negative */

0 commit comments

Comments
 (0)