SmartREST client reference implementation for the u-blox C027 mbed compatible device.

Dependencies:   C027 C027_Support mbed mbed-rtos MbedSmartRest LM75B MMA7660 C12832

Fork of MbedSmartRestTest by Vincent Wochnik

Revision:
20:ef9cc1b42e9d
Parent:
19:7bee744fe527
Child:
24:8f9b678a7932
--- a/program.cpp	Tue Feb 18 17:17:48 2014 +0000
+++ b/program.cpp	Thu Feb 20 11:51:54 2014 +0000
@@ -57,25 +57,25 @@
 {
     long deviceId = 0; Timer timer;
 
+    lcd_tenant("vaillant");
     puts("Hello!");
 
     puts("Bootstrapping");
+    lcd_status("Bootstrapping");
     if (client.bootstrap(srtpl) != SMARTREST_SUCCESS) {
         puts("Bootstrapping failed.");
+        lcd_status("Bootstrapping failed.");
         return 2;
     }
     
     puts("Starting action...");
     
     if ((deviceId = existing()) == 0) {
-        deviceId = create();
-        if (deviceId == 0)
+        if (((deviceId = create()) == 0) || (!identify(deviceId))) {
+            lcd_status("Device creation failed.");
             return 1;
-        if (!identify(deviceId))
-            return 2;
+        }
     }
-    //if (!update(deviceId))
-    //    return 3;
     update(deviceId);
 
     printf("Device ID: %ld\r\n", deviceId);
@@ -85,6 +85,7 @@
         timer.reset();
         loop(deviceId);
 
+        lcd_status("Sleeping...");
         // block remaining number of seconds
         while (timer.read() < interval) {
             Thread::yield();
@@ -97,6 +98,7 @@
     ComposedRecord newMoRec(true); // set copy=true b/c tmp objects
     ParsedRecord received;
 
+    lcd_status("Checking device existance...");
     puts("Checking for device existance...");
 
     newMoRec.add(IntegerValue(100)).add(CharValue(imei()));
@@ -139,6 +141,7 @@
     ComposedRecord newMoRec(true); // set copy=true b/c tmp objects
     ParsedRecord received;
 
+    lcd_status("Creating device...");
     puts("Creating device...");
 
     newMoRec.add(IntegerValue(101)).add(CharValue(imei()));
@@ -213,6 +216,7 @@
     ComposedRecord newMoRec(true); // set copy=true b/c tmp objects
     ParsedRecord received;
 
+    lcd_status("Updating device object...");
     puts("Updating device data...");
 
     newMoRec.add(IntegerValue(103)).add(IntegerValue(deviceId)).add(CharValue(imei())).add(CharValue(cellId())).add(CharValue(iccid()));
@@ -250,6 +254,7 @@
 {
     Aggregator aggr(5, false, true);
 
+    lcd_status("Sending measurements...");
     signalMeasurement(deviceId, aggr);
     if (client.send(aggr) != SMARTREST_SUCCESS) {
         puts("Send failed.");