Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
242:3b0086a6d625
Parent:
223:1a03451c0870
Child:
268:50bed2502270
--- a/src/OutputTask/OutputTask.cpp	Thu Oct 20 14:13:31 2016 +0000
+++ b/src/OutputTask/OutputTask.cpp	Thu Oct 20 15:30:21 2016 +0000
@@ -6,7 +6,7 @@
  *****************************************************************************/
 #include "OutputTask.h"
 #include "global.h"
-#include "MbedJSONValue.h"
+#include "cJSON.h"
 #include "ModbusMasterApi.h"
 #include "LoggerApi.h"
 #include "Control.h"
@@ -247,19 +247,10 @@
         logError("%s failed to read %s", __func__, outputFile);
         return -1;
     }
-
-    MbedJSONValue json_value;
-    parse(json_value, dataBuf);
     
-    if ( !json_value.hasMember("id") ) {
-        logError("Output file is missing expected tags");
-        return -1;
-    }
-
-    // extract the relay information
-    std::string id = json_value["id"].get<string>();
-
-    // maps don't allow duplicates, and the vector is empty for now
+    cJSON * root = cJSON_Parse(dataBuf);
+    std::string id = cJSON_GetObjectItem(root,"id")->valuestring;
+    
     vector<Control> v;
     outputMap[id] = v;
 
@@ -412,7 +403,7 @@
 static void loadPersistentOutputs(void)
 {
     bool status;
-    MbedJSONValue json_value;
+    cJSON *root;
 
     printf("\rLoading persistent outputs:\n");
 
@@ -429,15 +420,10 @@
             } else {
                 logInfo("%s: successfully read %s", __func__, i->name);
             }
-
-            parse( json_value, scratchBuf );
-            
-            if ( !json_value.hasMember("id") ) {
-                logError("Output file %s is missing expected tags", i->name);
-                continue;
-            }
-
-            std::string id = json_value["id"].get<string>();
+    
+            root = cJSON_Parse(scratchBuf);
+            //parse( json_value, scratchBuf );
+            std::string id = cJSON_GetObjectItem(root,"id")->valuestring;
             printf("\r   output %s loaded\n", i->name);
 
             // emplace the empty control vector into the output map