USE YHTANG AWS ACCOUNT TO TEST MQTT

Dependencies:   MQTTPacket FP

Dependents:   NuMaker-mbed-AWS-IoT-example

Revision:
57:3513ee54ebb4
Parent:
56:71ae1a773b64
Child:
61:20d53aa127ea
diff -r 71ae1a773b64 -r 3513ee54ebb4 MQTTClient.h
--- a/MQTTClient.h	Tue Oct 03 22:51:58 2017 +0000
+++ b/MQTTClient.h	Thu Nov 02 12:07:28 2017 +0000
@@ -382,13 +382,15 @@
     int rc = FAILURE,
         sent = 0;
 
-    do
+    while (sent < length)
     {
         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 (timer.expired()) // only check expiry after at least one attempt to write
+            break;
+    }
     if (sent == length)
     {
         if (this->keepAliveInterval > 0)