![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Own fork of MbedSmartRestMain
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: MbedAgent.cpp
- Revision:
- 76:b07effe83fb8
- Parent:
- 73:313975bfec96
- Child:
- 77:f6717e4eccc4
--- a/MbedAgent.cpp Wed Feb 18 10:19:51 2015 +0000 +++ b/MbedAgent.cpp Wed Feb 25 10:06:11 2015 +0000 @@ -1,6 +1,7 @@ #include "MbedAgent.h" #include "rtos.h" #include "logging.h" +#include "watchdog.h" MbedAgent::MbedAgent(DeviceIO& io, MDMSerial& mdm, DeviceInfo& deviceInfo, DeviceMemory& deviceMemory) : _io(io), @@ -26,35 +27,35 @@ { bool flag = true; if (!_integration.init()) { - aWarning("Init Device Integration failed.\r\n"); + aError("Init Device Integration failed.\r\n"); flag = false; } if (!_configurationSynchronization.init()) { - aWarning("Init Configuration Synchronization failed.\r\n"); + aError("Init Configuration Synchronization failed.\r\n"); flag = false; } if (!_signalQualityMeasurement.init()) { - aWarning("Init Signal Quality Measurement failed.\r\n"); + aError("Init Signal Quality Measurement failed.\r\n"); flag = false; } if (!_temperatureMeasurement.init()) { - aWarning("Init Temperature Measurement failed.\r\n"); + aError("Init Temperature Measurement failed.\r\n"); flag = false; } if (!_accelerationMeasurement.init()) { - aWarning("Init Acceleration Measurement failed.\r\n"); + aError("Init Acceleration Measurement failed.\r\n"); flag = false; } if (!_analogMeasurement.init()) { - aWarning("Init Analog Measurement failed.\r\n"); + aError("Init Analog Measurement failed.\r\n"); flag = false; } if (!_locationUpdate.init()) { - aWarning("Init Location Measurement failed.\r\n"); + aError("Init Location Measurement failed.\r\n"); flag = false; } if (!_operationSupport.init()) { - aWarning("Init Operation Support failed.\r\n"); + aError("Init Operation Support failed.\r\n"); flag = false; } return flag; @@ -88,25 +89,23 @@ void MbedAgent::loop() { - Timer timer; int interval; - - timer.start(); + Watchdog wdt; + wdt.kick(60.0); // set a 60.0 seconds timeout on watchdog hardware timer while (true) { - timer.reset(); - _configurationSynchronization.run(); _signalQualityMeasurement.run(); _temperatureMeasurement.run(); + _analogMeasurement.run(); _accelerationMeasurement.run(); - _analogMeasurement.run(); _locationUpdate.run(); _operationSupport.run(); - if ((interval = _configurationProperties.readInterval()) == 0) - break; - - while (timer.read() < interval) { - Thread::yield(); - } +// if ((interval = _configurationProperties.readInterval()) < 0) +// break; +// +// while (timer.read() < interval) { +// Thread::yield(); +// } + wdt.kick(); // reset watchdog timer } } \ No newline at end of file