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:
Fri Jan 24 21:05:24 2014 +0000
Parent:
2:1038411466a6
Child:
4:0eb69392686f
Commit message:
fix

Changed in this revision

HTTPBuffer.cpp Show annotated file Show diff for this revision Revisions of this file
HTTPBuffer.h Show annotated file Show diff for this revision Revisions of this file
HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
HTTPGeneratorWrapper.h Show annotated file Show diff for this revision Revisions of this file
MbedClient.cpp Show annotated file Show diff for this revision Revisions of this file
MbedClient.h Show annotated file Show diff for this revision Revisions of this file
--- a/HTTPBuffer.cpp	Fri Jan 24 11:39:32 2014 +0000
+++ b/HTTPBuffer.cpp	Fri Jan 24 21:05:24 2014 +0000
@@ -1,5 +1,6 @@
 #include "HTTPBuffer.h"
 #include <stdlib.h>
+#include <string.h>
 
 HTTPBuffer::HTTPBuffer()
 {
@@ -41,8 +42,8 @@
             newLen += HTTPBUFFER_INCREMENT;
         bufferSize(newLen);
     }
-    memcpy(_wbuf, buf, len);
-    _wbuf += len;
+    memcpy(_wptr, buf, len);
+    _wptr += len;
 }
 
 void HTTPBuffer::setDataType(const char* type)
@@ -73,5 +74,5 @@
     _rptr = buf + (_rptr - _buf);
     _buf = buf;
 
-    _len = len;
+    _len = length;
 }
--- a/HTTPBuffer.h	Fri Jan 24 11:39:32 2014 +0000
+++ b/HTTPBuffer.h	Fri Jan 24 21:05:24 2014 +0000
@@ -8,7 +8,8 @@
 #define HTTPBUFFER_INITIAL_SIZE 128
 #define HTTPBUFFER_INCREMENT 64
 
-class HTTPBuffer : public HTTPDataIn, public AbstractDataSource {
+class HTTPBuffer : public HTTPDataIn, public AbstractDataSource
+{
 public:
     HTTPBuffer();
     ~HTTPBuffer();
--- a/HTTPClient.lib	Fri Jan 24 11:39:32 2014 +0000
+++ b/HTTPClient.lib	Fri Jan 24 21:05:24 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/donatien/code/HTTPClient/#1f743885e7de
+http://mbed.org/users/vwochnik/code/HTTPClient/#bcbf0af9fac3
--- a/HTTPGeneratorWrapper.h	Fri Jan 24 11:39:32 2014 +0000
+++ b/HTTPGeneratorWrapper.h	Fri Jan 24 21:05:24 2014 +0000
@@ -5,7 +5,8 @@
 #include "MbedDataSink.h"
 #include "IHTTPData.h"
 
-class HTTPGeneratorWrapper, public HTTPDataOut {
+class HTTPGeneratorWrapper, public HTTPDataOut
+{
 public:
     HTTPGeneratorWrapper(DataGenerator& generator);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MbedClient.cpp	Fri Jan 24 21:05:24 2014 +0000
@@ -0,0 +1,37 @@
+#include "MbedClient.h"
+
+MbedClient::MbedClient(const char* url, const char* username, const char* password)
+    : _url(url), _username(username), _password(password)
+{
+    _state = 0;
+}
+
+uint8_t MbedClient::beginRequest()
+{
+}
+
+uint8_t MbedClient::sendIdentifier(const char*)
+{
+}
+
+uint8_t MbedClient::sendData(DataGenerator& generator)
+{
+}
+
+uint8_t MbedClient::endRequest()
+{
+}
+
+uint8_t MbedClient::awaitResponse()
+{
+}
+
+AbstractDataSource& MbedClient::receiveData()
+{
+    return _buffer;
+}
+
+void MbedClient::stop()
+{
+    _buffer.writeReset();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MbedClient.h	Fri Jan 24 21:05:24 2014 +0000
@@ -0,0 +1,28 @@
+#ifndef MBEDCLIENT_H
+#define MBEDCLIENT_H
+
+#include "AbstractClient.h"
+#include "HTTPBuffer.h"
+#include "HTTPGeneratorWrapper.h"
+#include "HTTPClient.h"
+
+class MbedClient : public AbstractClient {
+public:
+    MbedClient(const char*, const char*, const char*);
+
+    uint8_t beginRequest();
+    uint8_t sendIdentifier(const char*);
+    uint8_t sendData(DataGenerator& generator);
+    uint8_t endRequest();
+    uint8_t awaitResponse();
+    AbstractDataSource& receiveData();
+    void stop();
+
+private:
+    const char *_url, *_username, *_password;
+    HTTPClient _client;
+    HTTPBuffer _buffer;
+    uint8_t _state;
+};
+
+#endif
\ No newline at end of file