demo project

Dependencies:   AX-12A Dynamixel mbed iothub_client EthernetInterface NTPClient ConfigFile SDFileSystem iothub_amqp_transport mbed-rtos proton-c-mbed wolfSSL

Revision:
20:891b5270845a
Parent:
19:2f0ec9ac1238
--- a/Utils/IothubSerial.cpp	Sat Jan 23 00:20:27 2016 +0000
+++ b/Utils/IothubSerial.cpp	Tue Jan 26 17:34:51 2016 +0000
@@ -60,18 +60,15 @@
     return startlen - bufsize;
 }
 
-int AddTime(time_t seconds, char* buf, int bufsize)
+int AddTime(time_t seconds, int ms, char* buf, int bufsize)
 {
-    if (bufsize > 32)
+    char tbuf[32];
+    strftime(tbuf, 32, "%FT%T", localtime(&seconds));
+    int slen = sprintf_s(buf, bufsize, "\"time\": \"%s.%03d\",", tbuf, ms);
+    if (slen > 0)
     {
-        int slen = strftime(buf, 32, "\"time\": \"%FT%T\",", localtime(&seconds));
-        if (slen > 0)
-        {
-            return slen;
-        }
-        else
-            return -1;
-    }        
+        return slen;
+    }
     else
         return -1;
 }
@@ -95,7 +92,7 @@
     else
         return -1;
 
-    slen = AddTime(msnap.Created, buf, bufsize);
+    slen = AddTime(msnap.Created, msnap.CreatedMs, buf, bufsize);
     if (slen > 0)
     {
         bufsize -= slen;