Own fork of MbedSmartRestMain

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Cumulocity Official

Revision:
68:0dc778a16d0d
Parent:
67:c360a2b2c948
Child:
71:063c45e99578
--- a/MbedAgent.cpp	Sun Nov 30 19:34:49 2014 +0000
+++ b/MbedAgent.cpp	Sat Dec 06 19:47:23 2014 +0000
@@ -6,15 +6,17 @@
     _mdm(mdm),
     _deviceInfo(deviceInfo),
     _deviceMemory(deviceMemory),
+    _configurationProperties(_deviceConfiguration),
     _client(MBED_AGENT_HOST, MBED_AGENT_PORT, MBED_AGENT_DEVICE_IDENTIFIER),
     _bootstrap(_client, _io, _deviceInfo, _deviceMemory),
     _integration(_client, _tpl, _deviceId, _deviceInfo),
+    _configurationSynchronization(_client, _tpl, _deviceId, _deviceMemory, _deviceConfiguration, _configurationProperties),
     _signalQualityMeasurement(_client, _tpl, _deviceId, _deviceInfo),
     _temperatureMeasurement(_client, _tpl, _deviceId, _io.temperatureSensor()),
     _accelerationMeasurement(_client, _tpl, _deviceId, _io.accelerometer()),
     _analogMeasurement(_client, _tpl, _deviceId, _io.analog1(), _io.analog2()),
     _locationUpdate(_client, _tpl, _deviceId, _io.gpsTracker()),
-    _operationSupport(_client, _tpl, _deviceId, _io),
+    _operationSupport(_client, _tpl, _deviceId, _configurationSynchronization, _io),
     _deviceId(0)
 {
 }
@@ -22,6 +24,7 @@
 bool MbedAgent::init()
 {
     if ((!_integration.init()) ||
+        (!_configurationSynchronization.init()) ||
         (!_signalQualityMeasurement.init()) ||
         (!_temperatureMeasurement.init()) ||
         (!_accelerationMeasurement.init()) ||
@@ -47,22 +50,28 @@
         return false;
     }
     
+    if (!_configurationSynchronization.integrate()) {
+        return false;
+    }
+    
     char status[60];
     snprintf(status, sizeof(status), "ID: %ld", _deviceId);
     _io.lcdPrint("INTEGRATED", status);
 
     loop();
+
     return true;
 }
 
 void MbedAgent::loop()
 {
-    Timer timer;
+    Timer timer; int interval;
     
     timer.start();
     while (true) {
         timer.reset();
         
+        _configurationSynchronization.run();
         _signalQualityMeasurement.run();
         _temperatureMeasurement.run();
         _accelerationMeasurement.run();
@@ -70,7 +79,10 @@
         _locationUpdate.run();
         _operationSupport.run();
         
-        while (timer.read() < MBED_AGENT_INTERVAL) {
+        if ((interval = _configurationProperties.readInterval()) == 0)
+            break;
+
+        while (timer.read() < interval) {
             Thread::yield();
         }
     }