Own fork of MbedSmartRestMain
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
operation/ReportThread.cpp
- Committer:
- xinlei
- Date:
- 2015-05-11
- Revision:
- 105:c61f0d62b625
- Parent:
- 98:e369fc75c000
- Child:
- 108:2ec12f10ebf4
File content as of revision 105:c61f0d62b625:
#include "ReportThread.h" #include "logging.h" static const char *fmt2 = "111,%ld,%s\r\n"; void ReportThread::threadFunc() { sock.setBlocking(3000); 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)); for (unsigned short i = 0; i < 10; ++i) { osEvent e = ipool.get(200); if (e.status == osEventMail) { op = (Operation*)e.value.p; id = op->identifier; OperationState state = op->state; ipool.free(op); l += snprintf(buf2+l, sizeof(buf2)-l, fmt2, id, strOperationState(state)); } else { break; } } l = snprintf(buf, sizeof(buf), fmtSmartRest, uri, l, buf2); l = sock.sendOnly(buf, l); if (l < 0) { aError("Report: <%ld, %s>\n", id, strOperationState(state)); } } } }