Official reference client implementation for Cumulocity SmartREST on u-blox C027.

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Vincent Wochnik

Files at this revision

API Documentation at this revision

Comitter:
xinlei
Date:
Mon Jun 01 12:56:41 2015 +0000
Parent:
125:979ab0d075de
Child:
127:871e6eb0fa76
Commit message:
added network traffic accounting

Changed in this revision

C027_Support.lib Show annotated file Show diff for this revision Revisions of this file
MbedAgent.cpp Show annotated file Show diff for this revision Revisions of this file
MbedSmartRest.lib Show annotated file Show diff for this revision Revisions of this file
operation/PollThread.cpp Show annotated file Show diff for this revision Revisions of this file
operation/ReportThread.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/C027_Support.lib	Mon Jun 01 11:24:17 2015 +0000
+++ b/C027_Support.lib	Mon Jun 01 12:56:41 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/xinlei/code/C027_Support/#b43dbe49091c
+http://developer.mbed.org/users/xinlei/code/C027_Support/#73d7bfcc1e3d
--- a/MbedAgent.cpp	Mon Jun 01 11:24:17 2015 +0000
+++ b/MbedAgent.cpp	Mon Jun 01 12:56:41 2015 +0000
@@ -103,7 +103,7 @@
     while (true) {
         int l = 0;
         for (size_t i = 0; i < N; ++i) {
-            if (reporters[i] == &ConfigSync::inst()) {
+//            if (reporters[i] == &ConfigSync::inst()) {
             int l2 = reporters[i]->read(buf2+l, sizeof(buf2)-l, status, DISPLAY_LEN);
             if (l2) { // Refresh LCD display needed
                 LCDDisplay::inst().setThirdLine(status);
@@ -114,12 +114,13 @@
             }
             lcdThirdLineBlank = !l2;
             l += l2;
-            }
+//            }
         }
         if (l) {
             l = snprintf(buf, sizeof(buf), fmtSmartRest, "/s", l, buf2);
             sock.setBlocking(3000);
             l = sock.sendOnly(buf, l);
+            aInfo("[SEND] agent: %d\n", l);
             if (l < 0)
                 aWarning("%s\n", status);
         }
--- a/MbedSmartRest.lib	Mon Jun 01 11:24:17 2015 +0000
+++ b/MbedSmartRest.lib	Mon Jun 01 12:56:41 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/xinlei/code/MbedSmartRest/#11fd6fd14c28
+http://developer.mbed.org/users/xinlei/code/MbedSmartRest/#b8a080f5e578
--- a/operation/PollThread.cpp	Mon Jun 01 11:24:17 2015 +0000
+++ b/operation/PollThread.cpp	Mon Jun 01 12:56:41 2015 +0000
@@ -3,13 +3,18 @@
 #include "PollThread.h"
 #include "logging.h"
 
+static size_t _volSend = 0;
+static size_t _volRecv = 0;
+
 bool PollThread::handshake()
 {
         int l = snprintf(buf2, sizeof(buf2), "%s", "80\r\n");
         l = snprintf(buf, sizeof(buf), fmtSmartRest, uri, l, buf2);
         sock.setBlocking(3000);
+        _volSend += l;
         l = sock.sendAndReceive(buf, l, sizeof(buf));
         if (l <= 0) return false;
+        _volRecv += l;
         const char* p = skipHTTPHeader(buf);
         if (p == NULL) return false;
         size_t i = 0;
@@ -25,8 +30,10 @@
         int l = snprintf(buf2, sizeof(buf2), "81,%s,%s\r\n", bayeuxId, chn);
         l = snprintf(buf, sizeof(buf), fmtSmartRest, uri, l, buf2);
         sock.setBlocking(3000);
+        _volSend += l;
         l = sock.sendAndReceive(buf, l, sizeof(buf));
         if (l <= 0) return false;
+        _volRecv += l;
         const char *p = skipHTTPHeader(buf);
         if (p == NULL) return false;
         for (; *p && !isgraph(*p); ++p);
@@ -38,7 +45,11 @@
         int l = snprintf(buf2, sizeof(buf2), "83,%s\r\n", bayeuxId);
         l = snprintf(buf, sizeof(buf), fmtSmartRest, uri, l, buf2);
         sock.setBlocking(300000); // Timeout after 5 minutes
+        _volSend += l;
+        aInfo("[SEND] poll: %d\n", _volSend);
         l = sock.sendAndReceive(buf, l, sizeof(buf));
+        _volRecv += l;
+        aInfo("[RECV] poll: %d\n", _volRecv);
         return l>0;
 }
 
--- a/operation/ReportThread.cpp	Mon Jun 01 11:24:17 2015 +0000
+++ b/operation/ReportThread.cpp	Mon Jun 01 12:56:41 2015 +0000
@@ -36,6 +36,7 @@
                     aError("Report: op state\n");
                     Thread::wait(3000);
                 } else
+                    aInfo("[SEND] report: %d\n", l2);
                     break;
             }
         }