A client for the SmartREST protocol from Cumulocity.
Fork of MbedSmartRest by
Diff: MbedClient.h
- Revision:
- 13:e76920d5e1ec
- Parent:
- 5:ab909221d22d
- Child:
- 14:dc3f8dd5c02b
--- a/MbedClient.h Wed Apr 02 12:23:46 2014 +0000 +++ b/MbedClient.h Fri Apr 11 09:33:45 2014 +0000 @@ -1,14 +1,23 @@ #ifndef MBEDCLIENT_H #define MBEDCLIENT_H +#include <stdint.h> #include "AbstractClient.h" -#include "HTTPBuffer.h" -#include "HTTPGeneratorWrapper.h" -#include "HTTPClient.h" +#include "TCPSocketConnection.h" +#include "MbedDataSource.h" +#include "MbedDataSink.h" + +#define MBED_STATE_INIT 0 +#define MBED_STATE_IN_REQUEST 1 +#define MBED_STATE_SENT_ID 2 +#define MBED_STATE_SENT_DATA 3 +#define MBED_STATE_REQ_COMPLETE 4 +#define MBED_STATE_RECVD_RESPONSE 5 +#define MBED_STATE_RECV_DATA 6 class MbedClient : public AbstractClient { public: - MbedClient(const char*, const char*, const char*); + MbedClient(const char*, uint16_t, const char*, const char*); ~MbedClient(); uint8_t beginRequest(); @@ -19,13 +28,16 @@ AbstractDataSource& receiveData(); void stop(); +protected: + bool send(const char *str); + bool sendBasicAuth(); + private: - const char *_url, *_username, *_password; - HTTPClient _client; - HTTPGeneratorWrapper *_generator; - HTTPBuffer _buffer; - uint8_t _state; - const char *_headers[2]; + const char *_host, *_username, *_password; + uint16_t _port, _state; + TCPSocketConnection _sock; + MbedDataSource _source; + MbedDataSink _sink; }; #endif \ No newline at end of file