Own fork of MbedSmartRestMain
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: MbedAgent.cpp
- Revision:
- 106:fc5f25f0e0d5
- Parent:
- 105:c61f0d62b625
- Child:
- 107:f1ee3e1eb126
diff -r c61f0d62b625 -r fc5f25f0e0d5 MbedAgent.cpp --- a/MbedAgent.cpp Mon May 11 18:10:44 2015 +0000 +++ b/MbedAgent.cpp Wed May 13 12:12:55 2015 +0000 @@ -6,14 +6,14 @@ _client(), tpl(), _bootstrap(_client, deviceInfo), _integration(_client, tpl, deviceInfo), lcdThirdLineBlank(true), signal(deviceInfo), temp(), poti(), gps(), acc(), conf(), sock(), - pool(), _operationSupport(_client, tpl, pool) + pool(), _operationSupport(tpl, pool, conf) { - reporters[0] = &signal; + reporters[0] = &conf; reporters[1] = &temp; - reporters[2] = &poti; + reporters[2] = &signal; reporters[3] = &gps; reporters[4] = &acc; - reporters[5] = &conf; + reporters[5] = &poti; } bool MbedAgent::init() @@ -97,30 +97,33 @@ void MbedAgent::loop() { ReportThread reportThread(pool); - _operationSupport.run(); - PollThread pollThread(pool, conf); - pollThread.setChannel(deviceID); + _operationSupport.executePendingOperations(); +// PollThread pollThread(pool, conf); +// pollThread.setChannel(deviceID); Watchdog wdt; wdt.kick(60.0); // set a 60.0 seconds watchdog while (true) { + int l = 0; for (size_t i = 0; i < N; ++i) { -// if (reporters[i] == &acc) { - size_t l = reporters[i]->read(buf2, sizeof(buf2), status, DISPLAY_LEN); - bool b = l; - if (b) { // Refresh LCD display needed + if (reporters[i] == NULL) { + int l2 = reporters[i]->read(buf2+l, sizeof(buf2)-l, status, DISPLAY_LEN); + if (l2) { // Refresh LCD display needed LCDDisplay::inst().setThirdLine(status); - } else if (!lcdThirdLineBlank && !b) { // Clear LCD display needed + Thread::wait(400); + } else if (!lcdThirdLineBlank && !l2) { // Clear LCD display needed LCDDisplay::inst().setThirdLine(""); + Thread::wait(100); } - lcdThirdLineBlank = !b; - if (b) { - int l2 = snprintf(buf, sizeof(buf), fmtSmartRest, "/s", l, buf2); - l2 = sock.sendOnly(buf, l2); - if (l2 < 0) - aWarning("%s\n", status); + lcdThirdLineBlank = !l2; + l += l2; } -// } + } + if (l) { + l = snprintf(buf, sizeof(buf), fmtSmartRest, "/s", l, buf2); + l = sock.sendOnly(buf, l); + if (l < 0) + aWarning("%s\n", status); } wdt.kick(); // reset watchdog timer }