Official reference client implementation for Cumulocity SmartREST on u-blox C027.
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: operation/PollThread.h
- Revision:
- 96:5dfdc8568e9f
- Child:
- 97:ea056f6be2e8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/operation/PollThread.h Mon Apr 27 10:50:21 2015 +0000 @@ -0,0 +1,36 @@ +#ifndef POLLTHREAD_H +#define POLLTHREAD_H +#include "SmartRestSocket.h" +#include "Operation.h" +#include "SmartRestConf.h" +#include "ControlParser.h" + +class PollThread +{ +public: + PollThread(OperationPool& pool, MDMSerial& m, + ConfigurationSynchronization& configSync): + sock(m), parser(pool, configSync), + thread(PollThread::threadWrapper, this) { + strncpy(uri, "/devicecontrol/notifications", sizeof(uri)); + sock.set_blocking(true); + } + virtual ~PollThread() { sock.close(); } + bool handshake(); + bool subscribe(); + bool connect(); + void setChannel(long channel) { snprintf(chn, sizeof(chn), "/%ld", channel); } + void threadFunc(); + static void threadWrapper(const void *p) { ((PollThread*)p)->threadFunc(); } +private: + char chn[16]; + char uri[30]; + char bayeuxId[50]; + char buf[SMARTREST_SIZE]; + char buf2[SMARRESTBODY_SIZE]; + SmartRestSocket sock; + ControlParser parser; + Thread thread; +}; + +#endif /* POLLTHREAD_H */