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:
71:063c45e99578
Parent:
68:0dc778a16d0d
Child:
72:c5709ae7b193
--- a/main.cpp	Tue Feb 10 20:52:13 2015 +0000
+++ b/main.cpp	Mon Feb 16 09:17:30 2015 +0000
@@ -31,44 +31,42 @@
 
     MDMRtos<MDMSerial> mdm;
     GPSI2C gps;
+    DeviceIO io(gps);
     
     //mdm.setDebug(4);
-
+    io.lcdPrint("Device Init");
     if (!mdm.init(SIM_PIN, &devStatus))
         status = 1;
     else if (!gps.init())
         status = 2;
     
-    DeviceIO io(gps);
-
     switch (status) {
     case 1:
-        io.lcdPrint("MODEM INIT FAILURE", "CHECK SIM");
+        io.lcdPrint("Modem Init Failure", "Check SIM");
         break;
     case 2:
-        io.lcdPrint("GPS INIT FAILURE");
+        io.lcdPrint("GPS Init Failure");
         break;
     }
     
     if (status != 0)
         goto error;
     
-    io.lcdPrint("DEVICE INIT");
     
-    io.lcdPrint("REGISTER NETWORK", "IMEI", devStatus.imei);
+    io.lcdPrint("Register Network", "IMEI", devStatus.imei);
 
     if (!mdm.registerNet()) {
-        io.lcdPrint("NETWORK REG ERROR");
+        io.lcdPrint("Network Reg Error");
         goto error;
     }
 
-    io.lcdPrint("JOIN NETWORK");
+    io.lcdPrint("Join Network");
 #ifdef SIM_APN
     if (mdm.join(SIM_APN, SIM_USER, SIM_PASS) == NOIP) {
 #else
     if (mdm.join() == NOIP) {
 #endif
-        io.lcdPrint("NETWORK JOIN FAILURE");
+        io.lcdPrint("Network join failure");
         goto error;
     }
     
@@ -78,31 +76,37 @@
         DeviceMemory deviceMemory(mdm);
         
         if (io.resetButtonPressed()) {
-            if (deviceMemory.resetPlatformCredentials())
-                io.deviceFeedback().beepSuccess();
-            else
-                io.deviceFeedback().beepFailure();
-            Thread::wait(1000);
+            io.lcdPrint("Factory Reset");
+            if (deviceMemory.resetPlatformCredentials()) {
+//                io.deviceFeedback().beepSuccess();
+                io.lcdPrint("Reset Success");
+            }
+            else {
+//                io.deviceFeedback().beepFailure();
+                io.lcdPrint("Reset Failure");
+            }
+//            Thread::wait(1000);
             return;
         }
 
         MbedAgent agent(io, mdm, deviceInfo, deviceMemory);
     
-        io.lcdPrint("AGENT INIT");
+        io.lcdPrint("Agent Init");
         if (!agent.init()) {
-            io.lcdPrint("AGENT INIT FAILURE");
+            io.lcdPrint("Agent Init Failure");
             goto error;
         }
         
         tries = 3;
         do {
-            io.lcdPrint("AGENT RUN");
+//            io.lcdPrint("AGENT RUN");
+            puts("R");
             if (agent.run())
                 break;
         } while (--tries > 0);
 
         if (tries == 0) {
-            io.lcdPrint("AGENT RUN FAILURE");
+            io.lcdPrint("Agent Run Failure");
             goto error;
         }
     }