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
Diff: operation/OperationSupport.cpp
- Revision:
- 67:c360a2b2c948
- Parent:
- 65:a62dbef2f924
- Child:
- 68:0dc778a16d0d
--- a/operation/OperationSupport.cpp Thu Oct 30 14:46:22 2014 +0000 +++ b/operation/OperationSupport.cpp Sun Nov 30 19:34:49 2014 +0000 @@ -16,9 +16,11 @@ _deviceId(deviceId), _executor(client, tpl, deviceId, io), _thread1(OperationSupport::thread1_func, this), - _thread2(OperationSupport::thread2_func, this) + _thread2(OperationSupport::thread2_func, this), + _thread3(OperationSupport::thread3_func, this) { _init = false; + _firstRun = true; } bool OperationSupport::init() @@ -55,7 +57,9 @@ bool OperationSupport::run() { - if (!_store.hasPending()) { + if (_firstRun) { + _firstRun = false; + return true; if (!requestPendingOperations()) return false; } @@ -222,6 +226,40 @@ } } +void OperationSupport::thread3() +{ + char bayeuxId[33]; + + ComposedRecord record; + ParsedRecord received; + + while ((!_init) || (_firstRun)) + Thread::yield(); + + // request Bayeux ID + { + IntegerValue msgId(80); + if (!record.add(msgId)) + return; + + if ((_client.stream("/devicecontrol/notifications", record) != SMARTREST_SUCCESS)) { + puts("Sending stream failed."); + _client.stop(); + return; + } + if ((_client.receive(received) != SMARTREST_SUCCESS)) { + puts("Receiving stream failed."); + _client.stop(); + } + _client.stop(); + + puts(received.value(0).characterValue()); + } + + while (true) { + } +} + void OperationSupport::thread1_func(void const *arg) { OperationSupport *that; @@ -235,3 +273,10 @@ that = (OperationSupport*)arg; that->thread2(); } + +void OperationSupport::thread3_func(void const *arg) +{ + OperationSupport *that; + that = (OperationSupport*)arg; + that->thread3(); +}