The firmware of the Grove Node

Dependencies:   BLE_API color_pixels mbed-src-nrf51822 nRF51822

Fork of BLE_LoopbackUART by Bluetooth Low Energy

Revision:
11:c0885b74a63a
Parent:
10:f34ff4e47741
--- a/node.cpp	Thu Jun 04 09:34:13 2015 +0000
+++ b/node.cpp	Thu Jun 04 12:39:32 2015 +0000
@@ -6,7 +6,7 @@
 #include "UARTService.h"
 #include "color_pixels.h"
 
-#define LOG(...)       { printf(__VA_ARGS__); }
+#define LOG(...)       // { printf(__VA_ARGS__); }
 
 #define MAX_INIT_DATA           4
 #define MAX_SENOSR_DIMENSION    9
@@ -86,14 +86,14 @@
 {
     sensor_index = 0;
     sensor = sensor_list[sensor_index];
-    sensor_init_data[0] = p3;
-    sensor_init_data[1] = p4;
+    sensor_init_data[0] = p1;
+    sensor_init_data[1] = p2;
     sensor->init(&sensor_object, sensor_init_data);
 
     actuator_index = 2;
     actuator = actuator_list[actuator_index];
-    actuator_init_data[0] = p1;
-    actuator_init_data[1] = p2;
+    actuator_init_data[0] = p3;
+    actuator_init_data[1] = p4;
     actuator_init_data[2] = 30;
     actuator->init(&actuator_object, actuator_init_data);
 }
@@ -143,31 +143,31 @@
 
 void node_parse(int argc, char *argv[])
 {
-    if (2 == argc) {
+    if (0 == strcmp(argv[0], "s")) {
         int param1 = atoi(argv[1]);
-        if (0 == strcmp(argv[0], "s")) {
-            if (param1 != sensor_index) {
-                sensor_index = param1;
-                sensor->fini(&sensor_object);
-                sensor = sensor_list[param1];
-                sensor->init(&sensor_object, sensor_init_data);
+        if (param1 != sensor_index) {
+            sensor_index = param1;
+            sensor->fini(&sensor_object);
+            sensor = sensor_list[param1];
+            sensor->init(&sensor_object, sensor_init_data);
 
-                task_mask = 0;
-            }
+            task_mask = 0;
+        }
 
-            LOG("select sensor [%d]\n", sensor_index);
-        } else if (0 == strcmp(argv[0], "a")) {
-            if (param1 != actuator_index) {
-                actuator_index = param1;
-                actuator->fini(&actuator_object);
-                actuator = actuator_list[param1];
-                actuator->init(&actuator_object, actuator_init_data);
-                
-                task_mask = 0;
-            }
+        LOG("select sensor [%d]\n", sensor_index);
+    } else if (0 == strcmp(argv[0], "a")) {
+        int param1 = atoi(argv[1]);
+        if (param1 != actuator_index) {
+            actuator_index = param1;
+            actuator->fini(&actuator_object);
+            actuator = actuator_list[param1];
+            actuator->init(&actuator_object, actuator_init_data);
+            
+            task_mask = 0;
+        }
 
-            LOG("select actuator [%d]\n", actuator_index);
-        }
+        LOG("select actuator [%d]\n", actuator_index);
+
 
     } else if (0 == strcmp(argv[0], "o")) {