mbed.org implementation of the abstract SmartREST library for the Cumulocity Platform SmartREST protocol.

Dependents:   MbedSmartRestMain MbedSmartRestMain

Revision:
7:8159a2d12e4e
Parent:
6:cd7ba1ddb664
Child:
8:3a4dba260b71
--- a/MbedClient.cpp	Mon Jul 28 12:11:02 2014 +0200
+++ b/MbedClient.cpp	Wed Oct 22 16:17:22 2014 +0200
@@ -52,7 +52,6 @@
     _sink(_sock),
     _sock()
 {
-    _state = STATE_INIT;
 }
 
 MbedClient::~MbedClient()
@@ -120,16 +119,15 @@
 
 uint8_t MbedClient::sendData(const DataGenerator& generator)
 {
-    size_t len; char lenstr[8];
+    size_t len;
     
     if ((_state != STATE_IN_REQUEST) && (_state != STATE_SENT_ID))
         return internalError();
     
     len = generator.writtenLength();
-    snprintf(lenstr, 8, "%ld", len);
-    
+
     if ((!send("Content-Length: ")) ||
-        (!send(lenstr)) ||
+        (_sink.write((unsigned long)len) == 0) ||
         (!send("\r\n\r\n")))
         return connectionError();
 
@@ -188,9 +186,7 @@
 
 bool MbedClient::send(const char *str)
 {
-    if (_sink.write(str) != strlen(str))
-        return false;
-    return true;
+    return (_sink.write(str) == strlen(str));
 }
 
 bool MbedClient::sendBasicAuth()