Own fork of MbedSmartRestMain

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Cumulocity Official

Revision:
92:0acd11870c6a
Parent:
91:48069375dffa
Child:
93:61d44636f020
diff -r 48069375dffa -r 0acd11870c6a DeviceIntegration.cpp
--- a/DeviceIntegration.cpp	Fri Mar 20 14:27:10 2015 +0000
+++ b/DeviceIntegration.cpp	Mon Apr 13 14:24:58 2015 +0000
@@ -1,5 +1,5 @@
+#include <stdio.h>
 #include "DeviceIntegration.h"
-#include <stdio.h>
 #include "ComposedRecord.h"
 #include "CharValue.h"
 #include "IntegerValue.h"
@@ -92,14 +92,13 @@
     }
 
     if (_client.receive(received) != SMARTREST_SUCCESS) {
-        aError("No device found.\r\n");
+        aError("No device found.\n");
         _client.stop();
         return false;
     }
     _client.stop();
 
     if (received.values() == 0) {
-        aError("Received no values.\r\n");
         return false;
     }
 
@@ -108,10 +107,9 @@
     }
     
     if (received.value(0).integerValue() != 200) {
-        aError("Bad response.\r\n");
+        aError("Unknown message ID: %d.\n", received.value(0).integerValue());
         return false;
     }
-
     _deviceId = received.value(2).integerValue();
     
     return true;
@@ -122,7 +120,7 @@
     ComposedRecord record;
     ParsedRecord received;
 
-    aInfo("Creating device...\r\n");
+    aInfo("Create device...\n");
 
     IntegerValue msgId(101);
     CharValue imei(_deviceInfo.imei());
@@ -130,25 +128,24 @@
         return false;
 
     if (_client.send(record) != SMARTREST_SUCCESS) {
-        aError("Failed to sending data when creating device.\r\n");
         _client.stop();
         return 0;
     }
 
     if (_client.receive(received) != SMARTREST_SUCCESS) {
-        aError("No device found.\r\n");
+        aError("No device found.\n");
         _client.stop();
         return false;
     }
     _client.stop();
 
     if (received.values() != 3) {
-        aError("Received incomplete data when creating device.\r\n");
+        aError("createDevice: Incomplete response.\n");
         return false;
     }
     
     if (received.value(0).integerValue() != 201) {
-        aError("Received invalid data when creating device.\r\n");
+        aError("createDevice: Unknown message ID: %d.\n", received.value(0).integerValue());
         return false;
     }
 
@@ -161,7 +158,7 @@
     ComposedRecord record;
     ParsedRecord received;
 
-    aInfo("Adding global identifier...\r\n");
+    aInfo("Add global identifier.\n");
 
     IntegerValue msgId(102);
     IntegerValue deviceId(_deviceId);
@@ -176,19 +173,19 @@
     }
 
     if (_client.receive(received) != SMARTREST_SUCCESS) {
-        aError("Received data failed when adding global identifier.\r\n");
+        aError("Receive identifier failed.\n");
         _client.stop();
         return false;
     }
     _client.stop();
 
     if (received.values() != 3) {
-        aError("Received incomplete data when adding global identifier.\r\n");
+        aError("%d (3) values received.\n", received.values());
         return false;
     }
     
     if (received.value(0).integerValue() != 200) {
-        aError("Received invalid data when adding global identifier.\r\n");
+        aError("Unknown message ID: %d\n", received.value(0).integerValue());
         return false;
     }
 
@@ -205,29 +202,30 @@
     CharValue imei(_deviceInfo.imei());
     CharValue cellId(_deviceInfo.cellId());
     CharValue iccid(_deviceInfo.iccid());
+    aInfo("Update Device.");
     if ((!record.add(msgId)) || (!record.add(deviceId)) || (!record.add(imei)) || (!record.add(cellId)) || (!record.add(iccid)))
         return false;
 
     if (_client.send(record) != SMARTREST_SUCCESS) {
-        aError("Sending data failed when updating device.\r\n");
+        aError("Send.\n");
         _client.stop();
         return false;
     }
 
     if (_client.receive(received) != SMARTREST_SUCCESS) {
-        aError("Updating device failed.\r\n");
+        aError("Receive.\n");
         _client.stop();
         return false;
     }
     _client.stop();
 
     if (received.values() != 3) {
-        aError("Received incomplete data when updating device.\r\n");
+        aError("%d (3) values received.\n", received.values());
         return false;
     }
     
     if (received.value(0).integerValue() != 201) {
-        aError("Received invalid data when updating device.\r\n");
+        aError("Unknown message ID: %d\n", received.value(0).integerValue());
         return false;
     }