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
operation/PollingThread.h
- Committer:
- xinlei
- Date:
- 2015-04-20
- Revision:
- 94:61d44636f020
File content as of revision 94:61d44636f020:
#ifndef POLLINGTHREAD_H #define POLLINGTHREAD_H #include "SmartRestSocket.h" #include "Operation.h" #include "SmartRestConf.h" #include "ControlParser.h" class PollingThread { public: PollingThread(OperationPool& pool, MDMSerial& m, LCDDisplay& lcdDisplay, ConfigurationSynchronization& configSync): sock(m), parser(pool, lcdDisplay, configSync), thread(PollingThread::threadWrapper, this) { strncpy(uri, "/devicecontrol/notifications", sizeof(uri)); sock.set_blocking(true); } virtual ~PollingThread() { 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) { ((PollingThread*)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 /* POLLINGTHREAD_H */