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:
95:010b0f7a0a1a
Child:
101:dbcd3bc51758
--- a/util/SmartRestConf.cpp	Mon Apr 27 13:30:21 2015 +0000
+++ b/util/SmartRestConf.cpp	Thu May 07 09:57:55 2015 +0000
@@ -1,24 +1,21 @@
 #include <string.h>
 #include <stdio.h>
 #include "b64.h"
+#include "SmartRestConf.h"
 
-const char *_username = NULL;
-const char *_password = NULL;
-char _authStr[100] = {0};
-const char *_identifier = "com_cumulocity_MbedAgent_1.5.2";
-const char *_host = "developer.cumulocity.com";
+const char *srUsername = NULL;
+const char *srPassword = NULL;
+char srAuthStr[100] = {0};
+const char *srX_ID = "com_cumulocity_MbedAgent_1.5.2";
+const char *srHost = "developer.cumulocity.com";
 // const char *_host = "management.m2m-devicecloud.com"
-const int _port = 80;
+const int srPort = 80;
+long deviceID = 0;
 char fmtSmartRest[200] = {0};
 
-const char* getAuthStr()
-{
-        return _authStr;
-}
-
 void setAuthStr(const char* p1, const char* p2)
 {
-        memset(_authStr, 0, sizeof(_authStr));
+        memset(srAuthStr, 0, sizeof(srAuthStr));
         size_t ul = strlen(p1);
         size_t pl = strlen(p2);
         unsigned char input[3], output[5];
@@ -35,66 +32,41 @@
                 if ((inputOffset == 3) || (i == ul+pl)) {
                         b64_encode(input, inputOffset, output, 4);
                         output[4] = '\0';
-                        strcat(_authStr, (char*)output);
+                        strcat(srAuthStr, (char*)output);
                         inputOffset = 0;
                 }
         }
 }
 
-const char* getUsername()
-{
-        return _username;
-}
-
 void setUsername(const char* username)
 {
-        _username = username;
-}
-
-const char* getPassword()
-{
-        return _password;
+        srUsername = username;
 }
 
 void setPassword(const char* password)
 {
-        _password = password;
-}
-
-const char* getHost()
-{
-        return _host;
-}
-
-int getPort()
-{
-        return _port;
-}
-
-const char* getSmartRestFmt()
-{
-        return fmtSmartRest;
-}
-
-const char* getIdentifier()
-{
-        return _identifier;
+        srPassword = password;
 }
 
 void setSmartRestFmt()
 {
         const char fmt[] = "POST %%s HTTP/1.0\r\nHost: %s\r\nAuthorization: Basic %s\r\nX-Id: %s\r\nContent-Length: %%d\r\n\r\n%%s";
-        snprintf(fmtSmartRest, sizeof(fmtSmartRest), fmt, getHost(), getAuthStr(), getIdentifier());
+        snprintf(fmtSmartRest, sizeof(fmtSmartRest), fmt, srHost, srAuthStr, srX_ID);
 }
 
-void setIdentifier(const char* id)
+void setX_ID(const char* id)
 {
         if (id) {
-            _identifier = id;
+            srX_ID = id;
             setSmartRestFmt();
         }
 }
 
+void setDeviceID(long id)
+{
+        deviceID = id;
+}
+
 void setAuth(const char* username, const char* password)
 {
         if (username)