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 Vincent Wochnik

Revision:
96:5dfdc8568e9f
Parent:
93:0acd11870c6a
Child:
98:9f2de96941c4
--- a/config/ConfigurationSynchronization.cpp	Wed Apr 22 11:22:25 2015 +0000
+++ b/config/ConfigurationSynchronization.cpp	Mon Apr 27 10:50:21 2015 +0000
@@ -5,16 +5,18 @@
 #include "IntegerValue.h"
 #include "logging.h"
 
-ConfigurationSynchronization::ConfigurationSynchronization(AbstractSmartRest& client, SmartRestTemplate& tpl, long& deviceId, DeviceMemory& deviceMemory, DeviceConfiguration& deviceConfiguration, ConfigurationProperties& configurationProperties) :
-    _deviceId(deviceId),
+ConfigurationSynchronization::ConfigurationSynchronization(
+    AbstractSmartRest& client, SmartRestTemplate& tpl,
+    long& deviceId, DeviceMemory& deviceMemory) :
+    _init (false),
+    _changed (false),
     _tpl(tpl),
     _client(client),
     _deviceMemory(deviceMemory),
-    _deviceConfiguration(deviceConfiguration),
-    _configurationProperties(configurationProperties)
+    _deviceId(deviceId),
+    _deviceConfiguration(),
+    _configurationProperties(_deviceConfiguration)
 {
-    _init = false;
-    _changed = false;
 }
 
 bool ConfigurationSynchronization::init()
@@ -59,7 +61,7 @@
 bool ConfigurationSynchronization::updateConfiguration(const char *cfg)
 {
     if (!_deviceConfiguration.read(cfg)) {
-        aError("updateConfiguration: Unable to read device configuration!\r\n");
+        aError("Read device config.\n");
         return false;
     }
     
@@ -77,7 +79,7 @@
     char buf[256];
     
     if (!_deviceConfiguration.write(buf, sizeof(buf))) {
-        aError("updateDeviceObject: Unable to write device configuration!\r\n");
+        aError("Unable to write config.\n");
         return false;
     }
 
@@ -89,28 +91,25 @@
     CharValue config(buf);
     IntegerValue responsibility(_configurationProperties.readInterval());
     if (!record.add(msgId) || !record.add(deviceId) || !record.add(config) || !record.add(responsibility)) {
-        aWarning("updateDeviceObject: Adding record failed!\r\n");
         return false;
     }
     
     if (_client.send(record) != SMARTREST_SUCCESS) {
-        aWarning("Sending configuration failed.\r\n");
         _client.stop();
         return false;
     }
     
     if (_client.receive(received) != SMARTREST_SUCCESS) {
-        aWarning("Receiving configuration failed.\r\n");
         _client.stop();
         return false;
     }
     _client.stop();
 
     if (received.values() != 3) {
-        aError("Invalid configuration received, expected 3 values, but %d received.\r\n", received.values());
+        aError("Invalid config, %d (3) values received.\n", received.values());
         return false;
     } else if (received.value(0).integerValue() != 201) {
-        aError("updateDeviceObject: Unexpected message ID %ld received.\r\n", received.value(0).integerValue());
+        aError("updateDeviceObject: Message ID %ld .\n", received.value(0).integerValue());
         return false;
     }
     return true;
@@ -121,11 +120,11 @@
     char buf[256];
     
     if (!_deviceMemory.loadConfiguration(buf, sizeof(buf))) {
-        aError("loadConfiguration: Unable to load device configuration!\r\n");
+        aError("Load device config.\n");
         return false;
     }
     if (!_deviceConfiguration.read(buf)) {
-        aError("loadConfiguration: Unable to read device configuration!\r\n");
+        aError("Read device config.\n");
         return false;
     }
     return true;
@@ -136,11 +135,11 @@
     char buf[256];
     
     if (!_deviceConfiguration.write(buf, sizeof(buf))) {
-        aError("saveConfiguration: Unable to write device configuration!\r\n");
+        aError("Write device config.\n");
         return false;
     }
     if (!_deviceMemory.saveConfiguration(buf)) {
-        aError("saveConfiguration: Unable to save device configuration!\r\n");
+        aError("Save device config.\n");
         return false;
     }
     return true;