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

Revision:
99:e369fc75c000
Parent:
96:5dfdc8568e9f
Child:
101:dbcd3bc51758
--- a/operation/PollThread.cpp	Mon Apr 27 13:30:21 2015 +0000
+++ b/operation/PollThread.cpp	Thu May 07 09:57:55 2015 +0000
@@ -7,7 +7,8 @@
 bool PollThread::handshake()
 {
         int l = snprintf(buf2, SMARRESTBODY_SIZE, "%s", "80\r\n");
-        l = snprintf(buf, SMARTREST_SIZE, getSmartRestFmt(), uri, l, buf2);
+        l = snprintf(buf, SMARTREST_SIZE, fmtSmartRest, uri, l, buf2);
+        sock.set_blocking(false);
         l = sock.sendAndReceive(buf, l, SMARTREST_SIZE);
         if (l < 0)
                 return false;
@@ -22,22 +23,24 @@
 bool PollThread::subscribe()
 {
         int l = snprintf(buf2, SMARRESTBODY_SIZE, "81,%s,/%s\r\n", bayeuxId, chn);
-        l = snprintf(buf, SMARTREST_SIZE, getSmartRestFmt(), uri, l, buf2);
-        l = sock.sendAndReceive(buf, l, SMARTREST_SIZE);
+        l = snprintf(buf, SMARTREST_SIZE, fmtSmartRest, uri, l, buf2);
+        sock.set_blocking(false);
+        l = sock.sendOnly(buf, l, SMARTREST_SIZE);
         return l>=0;
 }
 
 bool PollThread::connect()
 {
         int l = snprintf(buf2, SMARRESTBODY_SIZE, "83,%s\r\n", bayeuxId);
-        l = snprintf(buf, SMARTREST_SIZE, getSmartRestFmt(), uri, l, buf2);
+        l = snprintf(buf, SMARTREST_SIZE, fmtSmartRest, uri, l, buf2);
+        sock.set_blocking(true);
         l = sock.sendAndReceive(buf, l, SMARTREST_SIZE);
         return l>=0;
 }
 
 void PollThread::threadFunc()
 {
-        uint8_t state = 1;
+        unsigned short state = 1;
         aInfo("Poll thread: %p\n", Thread::gettid());
         while (true) {
                 switch (state) {
@@ -55,7 +58,7 @@
                                 state = 1;
                                 break;
                         }
-                default: parser.handleControlMessage(buf);
+                default: parser.parse(buf);
                         if (parser.getBayeuxAdvice() == BA_HANDSHAKE)
                                 state = 1;
                         else