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/ReportThread.cpp
- Committer:
- xinlei
- Date:
- 2015-05-13
- Revision:
- 109:2ec12f10ebf4
- Parent:
- 106:c61f0d62b625
- Child:
- 122:68217ccb8cd1
File content as of revision 109:2ec12f10ebf4:
#include "ReportThread.h" #include "logging.h" static const char *fmt2 = "111,%ld,%s\r\n"; void ReportThread::threadFunc() { sock.setBlocking(3000); while (true) { dict.clear(); osEvent e = ipool.get(); if (e.status == osEventMail) { Operation *op = (Operation*)e.value.p; dict.set(op->identifier, op->state); ipool.free(op); while (!dict.full()) { osEvent e = ipool.get(200); if (e.status == osEventMail) { op = (Operation*)e.value.p; dict.set(op->identifier, op->state); ipool.free(op); } else { break; } } int l = 0; for (unsigned short i = 0; i < dict.size(); ++i) { const long id = dict[i].identifier; const OperationState state = dict[i].state; l += snprintf(buf2+l, sizeof(buf2)-l, fmt2, id, strOperationState(state)); } l = snprintf(buf, sizeof(buf), fmtSmartRest, uri, l, buf2); for (unsigned i = 0; i < 3; ++i) { int l2 = sock.sendOnly(buf, l); if (l2 < 0) { aError("Report: op state\n"); Thread::wait(3000); } else break; } } } }