Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
260:fe726583ba1d
Parent:
253:ae850c19cf81
Child:
276:851554207c77
--- a/src/ConfigurationHandler/Controls/ManualControl.cpp	Fri Oct 21 19:13:21 2016 +0000
+++ b/src/ConfigurationHandler/Controls/ManualControl.cpp	Mon Oct 24 13:07:52 2016 +0000
@@ -48,6 +48,18 @@
     // parse the json data
     cJSON * root = cJSON_Parse(dataBuf);
 
+    if ( !cJSON_HasObjectItem(root, "id") ||
+            !cJSON_HasObjectItem(root, "output") ||
+            !cJSON_HasObjectItem(root, "type") ||
+            !cJSON_HasObjectItem(root, "priority") ||
+            !cJSON_HasObjectItem(root, "duration") ||
+            !cJSON_HasObjectItem(root, "setpoint") ||
+            !cJSON_HasObjectItem(root, "state") ||
+            !cJSON_HasObjectItem(root, "percent") ) {
+        logError("Manual control is missing expected tags\n");
+        return false;
+    }
+
     id          = cJSON_GetObjectItem(root,"id")->valuestring;
     output      = cJSON_GetObjectItem(root,"output")->valuestring;
     type        = atoi(cJSON_GetObjectItem(root,"type")->valuestring);
@@ -74,7 +86,7 @@
 
 //
 // method:          update
-// description:     the setpoint control's state machine 
+// description:     the setpoint control's state machine
 //
 // @param           none
 // @return          none
@@ -172,13 +184,13 @@
 // @return          none
 //
 void ManualControl::display(void)
-{    
+{
     string mapper[] = { "INIT",
                         "STARTUP",
                         "CONTROL_ON",
                         "CONTROL_OFF"
                       };
-                      
+
     printf("\r\n");
     std::cout << left << setw(10) << setfill(' ') << "manual: ";
     std::cout << left << setw(40) << setfill(' ') << controlFile;