Own fork of MbedSmartRestMain

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Cumulocity Official

Revision:
93:61d44636f020
Parent:
92:0acd11870c6a
Child:
94:010b0f7a0a1a
--- a/MbedAgent.cpp	Mon Apr 13 14:24:58 2015 +0000
+++ b/MbedAgent.cpp	Mon Apr 20 15:04:23 2015 +0000
@@ -5,22 +5,23 @@
 
 MbedAgent::MbedAgent(GPSI2C& gps, MDMSerial& mdm, LCDDisplay& lcdDisplay,
     DeviceInfo& deviceInfo, DeviceMemory& deviceMemory) :
+    _deviceId(0),
     _mdm(mdm),
     _deviceInfo(deviceInfo),
     _deviceMemory(deviceMemory),
+    _lcdDisplay(lcdDisplay),
     _configurationProperties(_deviceConfiguration),
     _client(mdm),
     _bootstrap(_client, lcdDisplay, _deviceInfo, _deviceMemory),
     _integration(_client, _tpl, _deviceId, _deviceInfo),
-    _lcdDisplay(lcdDisplay),
     _configurationSynchronization(_client, _tpl, _deviceId, _deviceMemory, _deviceConfiguration, _configurationProperties),
     _signalQualityMeasurement(_client, _tpl, _deviceId, _deviceInfo, _lcdDisplay),
     _temperatureMeasurement(_client, _tpl, _deviceId, deviceInfo, _lcdDisplay),
     _accelerationMeasurement(_client, _tpl, _deviceId, deviceInfo, _lcdDisplay),
     _analogMeasurement(_client, _tpl, _deviceId, deviceInfo, _lcdDisplay),
     _locationUpdate(_client, _tpl, _deviceId, gps, deviceInfo, _lcdDisplay),
-    _operationSupport(_client, _tpl, _deviceId, _configurationSynchronization, _lcdDisplay),
-    _deviceId(0)
+    pool(),
+    _operationSupport(_client, _tpl, _deviceId, pool)
 {
 }
 
@@ -67,6 +68,8 @@
     // device bootstrapping process
     if (!_bootstrap.setUpCredentials())
         return -1;
+    setAuth(_bootstrap.username(), _bootstrap.password());
+    aInfo("Set auth: %s:%s (%s)\n", getUsername(), getPassword(), getAuthStr());
 
     Thread::wait(5000);
 
@@ -74,7 +77,9 @@
     if (!_integration.integrate()) {
         return -2;
     }
-    
+    setIdentifier(_client.getIdentifier());
+    aInfo("Set id: %s\n", getIdentifier());
+
     if (!_configurationSynchronization.integrate()) {
         return -3;
     }
@@ -93,18 +98,21 @@
 
 void MbedAgent::loop()
 {
+    ReportThread reportThread(pool, _mdm);
+    _operationSupport.run();
+    PollingThread pollingThread(pool, _mdm, _lcdDisplay, _configurationSynchronization);
+    pollingThread.setChannel(_deviceId);
+
     Watchdog wdt;
     wdt.kick(60.0);    // set a 60.0 seconds timeout on watchdog hardware timer
-
     while (true) {
-        _operationSupport.run();
-        _configurationSynchronization.run();
-        _signalQualityMeasurement.run();
-        _temperatureMeasurement.run();
-        _accelerationMeasurement.run();
-        _analogMeasurement.run();
-        _locationUpdate.run();
-
+//        _configurationSynchronization.run();
+//        _analogMeasurement.run();
+//        _signalQualityMeasurement.run();
+//        _temperatureMeasurement.run();
+//        _accelerationMeasurement.run();
+//        _locationUpdate.run();
+        Thread::wait(30000);
 //        if ((interval = _configurationProperties.readInterval()) < 0)
 //            break;
 //        while (timer.read() < interval) {