A client for the SmartREST protocol from Cumulocity.

Dependencies:   SmartRest

Fork of MbedSmartRest by Vincent Wochnik

Files at this revision

API Documentation at this revision

Comitter:
vwochnik
Date:
Mon May 26 08:25:44 2014 +0000
Parent:
17:57dd24cb6620
Commit message:
fix for bootstrapping

Changed in this revision

MbedClient.cpp Show annotated file Show diff for this revision Revisions of this file
--- 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;