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/ReportThread.cpp

Committer:
xinlei
Date:
2015-04-20
Revision:
94:61d44636f020
Child:
95:010b0f7a0a1a

File content as of revision 94:61d44636f020:

#include "ReportThread.h"
#include "logging.h"

const char fmt2[] = "111,%ld,%s\r\n";

void ReportThread::threadFunc()
{
    while (true) {
        osEvent e = ipool.get();
        if (e.status == osEventMail) {
            Operation *op = (Operation*)e.value.p;
            long id = op->identifier;
            OperationState state = op->state;
            ipool.free(op);
            int l = snprintf(buf2, sizeof(buf2), fmt2, id, strOperationState(state));
            l = snprintf(buf, sizeof(buf), getSmartRestFmt(), uri, l, buf2);
            l = sock.sendOnly(buf, l);
            if (l < 0) {
                    aError("Report: <%ld, %s>\n", id, strOperationState(state));
            }
        }
    }
}