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

operation/PollThread.h

Committer:
xinlei
Date:
2016-08-08
Revision:
139:f8ab852e83e7
Parent:
108:f1ee3e1eb126

File content as of revision 139:f8ab852e83e7:

#ifndef POLLTHREAD_H
#define POLLTHREAD_H
#include "SmartRestSocket.h"
#include "Operation.h"
#include "SmartRestConf.h"
#include "ControlParser.h"

class PollThread
{
public:
        PollThread(OperationPool& pool): sock(), parser(pool),
                thread(PollThread::threadWrapper, this) {
                strncpy(uri, "/devicecontrol/notifications", sizeof(uri));
        }
        virtual ~PollThread() {}
        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[SMARTREST_BODY_SIZE];
        SmartRestSocket sock;
        ControlParser parser;
        Thread thread;
};

#endif /* POLLTHREAD_H */