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 Vincent Wochnik

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PollThread.h Source File

PollThread.h

00001 #ifndef POLLTHREAD_H
00002 #define POLLTHREAD_H
00003 #include "SmartRestSocket.h"
00004 #include "Operation.h"
00005 #include "SmartRestConf.h"
00006 #include "ControlParser.h"
00007 
00008 class PollThread
00009 {
00010 public:
00011         PollThread(OperationPool& pool): sock(), parser(pool),
00012                 thread(PollThread::threadWrapper, this) {
00013                 strncpy(uri, "/devicecontrol/notifications", sizeof(uri));
00014         }
00015         virtual ~PollThread() {}
00016         bool handshake();
00017         bool subscribe();
00018         bool connect();
00019         void setChannel(long channel) { snprintf(chn, sizeof(chn), "/%ld", channel); }
00020         void threadFunc();
00021         static void threadWrapper(const void *p) { ((PollThread*)p)->threadFunc(); }
00022 private:
00023         char chn[16];
00024         char uri[30];
00025         char bayeuxId[50];
00026         char buf[SMARTREST_SIZE];
00027         char buf2[SMARTREST_BODY_SIZE];
00028         SmartRestSocket sock;
00029         ControlParser parser;
00030         Thread thread;
00031 };
00032 
00033 #endif /* POLLTHREAD_H */