Better timing

Dependencies:   FP MQTTPacket

Fork of MQTT by MQTT

Files at this revision

API Documentation at this revision

Comitter:
icraggs
Date:
Tue Oct 03 22:51:58 2017 +0000
Parent:
54:ff9e5c4b52d0
Commit message:
Allow acks to be sent at end of timeout

Changed in this revision

MQTTClient.h Show annotated file Show diff for this revision Revisions of this file
MQTTPacket.lib Show annotated file Show diff for this revision Revisions of this file
diff -r ff9e5c4b52d0 -r 71ae1a773b64 MQTTClient.h
--- a/MQTTClient.h	Sat Sep 30 16:46:21 2017 +0000
+++ b/MQTTClient.h	Tue Oct 03 22:51:58 2017 +0000
@@ -382,13 +382,13 @@
     int rc = FAILURE,
         sent = 0;
 
-    while (sent < length && !timer.expired())
+    do
     {
         rc = ipstack.write(&sendbuf[sent], length - sent, timer.left_ms());
         if (rc < 0)  // there was an error writing the data
             break;
         sent += rc;
-    }
+    } while (sent < length && !timer.expired());
     if (sent == length)
     {
         if (this->keepAliveInterval > 0)
@@ -400,7 +400,7 @@
 
 #if defined(MQTT_DEBUG)
     char printbuf[150];
-    DEBUG("Rc %d from sending packet %s\n", rc, 
+    DEBUG("Rc %d from sending packet %s\r\n", rc, 
         MQTTFormat_toServerString(printbuf, sizeof(printbuf), sendbuf, length));
 #endif
     return rc;
@@ -480,7 +480,7 @@
     if (rc >= 0)
     {
         char printbuf[50];
-        DEBUG("Rc %d receiving packet %s\n", rc, 
+        DEBUG("Rc %d receiving packet %s\r\n", rc, 
             MQTTFormat_toClientString(printbuf, sizeof(printbuf), readbuf, len));
     }
 #endif
@@ -688,8 +688,7 @@
         {
             rc = FAILURE; // session failure
             #if defined(MQTT_DEBUG)
-                char printbuf[150];
-                DEBUG("PINGRESP not received in keepalive interval\n");
+                DEBUG("PINGRESP not received in keepalive interval\r\n");
             #endif
         }
     }
diff -r ff9e5c4b52d0 -r 71ae1a773b64 MQTTPacket.lib
--- a/MQTTPacket.lib	Sat Sep 30 16:46:21 2017 +0000
+++ b/MQTTPacket.lib	Tue Oct 03 22:51:58 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/mqtt/code/MQTTPacket/#1af97b41bc9d
+https://os.mbed.com/users/icraggs/code/MQTTPacket/#0cfb74c5a621