A client for the SmartREST protocol from Cumulocity.

Dependencies:   SmartRest

Fork of MbedSmartRest by Vincent Wochnik

Revision:
18:f76f9ae79195
Parent:
14:dc3f8dd5c02b
--- a/MbedClient.cpp	Wed Apr 16 08:30:54 2014 +0000
+++ b/MbedClient.cpp	Mon May 26 08:25:44 2014 +0000
@@ -30,8 +30,10 @@
         (!send("\r\n")))
         return CLIENT_CONNECTION_ERROR;
     
-    if (!sendBasicAuth())
-        return CLIENT_CONNECTION_ERROR;
+    if ((strlen(_username) > 0) && (strlen(_password) > 0)) {
+        if (!sendBasicAuth())
+            return CLIENT_CONNECTION_ERROR;
+    }
 
     _state = MBED_STATE_IN_REQUEST;
     return CLIENT_OK;
@@ -42,10 +44,12 @@
     if (_state != MBED_STATE_IN_REQUEST)
         return CLIENT_INTERNAL_ERROR;
 
-    if ((!send("X-Id: ")) ||
-        (!send(identifier)) ||
-        (!send("\r\n")))
-        return CLIENT_CONNECTION_ERROR;
+    if ((identifier != NULL) && (strlen(identifier) != 0)) {
+        if ((!send("X-Id: ")) ||
+            (!send(identifier)) ||
+            (!send("\r\n")))
+            return CLIENT_CONNECTION_ERROR;
+    }
 
     _state = MBED_STATE_SENT_ID;
     return CLIENT_OK;