Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
246:ca91a441b4dc
Parent:
242:3b0086a6d625
Child:
251:e730d7077e46
--- a/src/CommandParser/cmd.cpp	Thu Oct 20 17:59:18 2016 +0000
+++ b/src/CommandParser/cmd.cpp	Thu Oct 20 22:20:52 2016 +0000
@@ -42,7 +42,7 @@
 #include "mDot.h"
 #include "rtos.h"
 #include "rtc.h"
-#include "MbedJSONValue.h"
+#include "cJSON.h"
 
 Serial serial(USBTX, USBRX);
 ntshell_t ntshell;
@@ -1216,13 +1216,13 @@
         printf("\rFailed to read %s\n", argv[1]);
         return;
     }
-
-    MbedJSONValue json_value;
-    parse(json_value, buf);
-
-    json_value["state"] = relayState;
-
-    std::string s = json_value.serialize();
+    
+    cJSON * root = cJSON_Parse(buf);
+    strncpy( cJSON_GetObjectItem(root,"state")->valuestring, relayState.c_str(), (strlen(relayState.c_str())-1) );
+    std::string s = cJSON_Print(root);
+    cJSON_Delete(root);
+    
+    printf("writing back: %s\r\n",s.c_str());
 
     rc = GLOBAL_mdot->saveUserFile(argv[1], (void*)s.c_str(), MAX_FILE_SIZE);
     if ( rc != true ) {
@@ -1265,13 +1265,13 @@
         return;
     }
 
-    MbedJSONValue json_value;
-    parse(json_value, buf);
-
-    json_value["setpoint"] = argv[2];
-    json_value["tol"] = argv[3];
-
-    std::string s = json_value.serialize();
+    cJSON * root = cJSON_Parse(buf);
+    strncpy( cJSON_GetObjectItem(root,"setpoint")->valuestring, argv[2], (strlen(argv[2])-1) );
+    strncpy( cJSON_GetObjectItem(root,"tol")->valuestring, argv[3], (strlen(argv[3])-1) );
+    std::string s = cJSON_Print(root);
+    cJSON_Delete(root);
+    
+    printf("writing back: %s\r\n",s.c_str());
 
     rc = GLOBAL_mdot->saveUserFile(argv[1], (void*)s.c_str(), MAX_FILE_SIZE);
     if ( rc != true ) {