Own fork of MbedSmartRestMain

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Cumulocity Official

Revision:
67:c360a2b2c948
Parent:
61:15719dbe8820
Child:
68:0dc778a16d0d
--- a/main.cpp	Thu Oct 30 14:46:22 2014 +0000
+++ b/main.cpp	Sun Nov 30 19:34:49 2014 +0000
@@ -3,9 +3,12 @@
 #include "MDM.h"
 #include "GPS.h"
 #include "DeviceInfo.h"
+#include "DeviceMemory.h"
 #include "MbedAgent.h"
 #include "GPSTracker.h"
 
+#include <stdio.h>
+
 /**
  * SIM PIN. Null for no pin.
  */
@@ -27,7 +30,7 @@
     MDMRtos<MDMSerial> mdm;
     GPSI2C gps;
     
-    //mdm.setDebug(4);
+    mdm.setDebug(4);
 
     if (!mdm.init(SIM_PIN, &devStatus))
         status = 1;
@@ -50,19 +53,6 @@
     
     io.lcdPrint("DEVICE INIT");
     
-    /*if (io.resetButtonPressed()) {
-        puts("Resetting program.");
-        res = mdm.delFile("001_CREDENTIALS");
-        if (res < 0) {
-            puts("Credential reset failed.");
-            io.lcdPrint("CREDENTIAL RESET", "FAILURE", "PLEASE RESTART DEVICE");
-        } else {
-            puts("Credential reset successful.");
-            io.lcdPrint("CREDENTIAL RESET", "SUCCESS", "PLEASE RESTART DEVICE");
-        }
-        return 0;
-    }*/
-
     io.lcdPrint("REGISTER NETWORK", "IMEI", devStatus.imei);
 
     if (!mdm.registerNet()) {
@@ -83,7 +73,18 @@
     {
         uint8_t tries;
         DeviceInfo deviceInfo(mdm, devStatus);
-        MbedAgent agent(io, mdm, deviceInfo);
+        DeviceMemory deviceMemory(mdm);
+        
+        if (io.resetButtonPressed()) {
+            if (deviceMemory.resetPlatformCredentials())
+                io.deviceFeedback().beepSuccess();
+            else
+                io.deviceFeedback().beepFailure();
+            Thread::wait(1000);
+            return;
+        }
+
+        MbedAgent agent(io, mdm, deviceInfo, deviceMemory);
     
         io.lcdPrint("AGENT INIT");
         if (!agent.init()) {