Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
1:057d8fc6cb2f
Parent:
0:65cfa4873284
Child:
2:da28f21b72a1
--- a/src/ConfigurationHandler/ConfigurationHandler.cpp	Thu Sep 01 18:57:04 2016 +0000
+++ b/src/ConfigurationHandler/ConfigurationHandler.cpp	Thu Sep 01 19:42:11 2016 +0000
@@ -114,7 +114,7 @@
 {
     printf("\r\n%s: invoked with %s [%u]\n",
            __func__, msg->controlFile, msg->control);
-
+    
     switch (msg->control) {
         case CONTROL_TIMER: {
             Thread *t = spawnNewTimerControl(msg->controlFile);
@@ -186,31 +186,58 @@
     }
 }
 
-static Thread* spawnNewTimerControl( const char *controlFile )
+static Thread *spawnNewTimerControl( const char *controlFile)
 {
-    Thread *t = new Thread(TimerControl, (void *)controlFile);
+    // TODO: Be sure to free these args when the thread dies 
+    Args_t *args = (Args_t*)malloc(sizeof(Args_t));
+    
+    strncpy(args->controlFile, controlFile, sizeof(args->controlFile));
+    args->reserved = 0;
+    
+    Thread *t = new Thread(TimerControl, (void *)args);
     return t;
 }
 static Thread*  spawnNewPIDControl( const char *controlFile )
 {
-    Thread *t = new Thread(PIDControl, (void *)controlFile);
+    Args_t *args = (Args_t *)malloc(sizeof(Args_t));
+    
+    strncpy(args->controlFile, controlFile, sizeof(args->controlFile));
+    args->reserved = 0;
+    
+    Thread *t = new Thread(PIDControl, (void *)args);
     return t;
 }
 
 static Thread*  spawnNewSetpointControl( const char *controlFile )
 {
-    Thread *t = new Thread(SetpointControl, (void *)controlFile);
+    Args_t *args = (Args_t *)malloc(sizeof(Args_t));
+    
+    strncpy(args->controlFile, controlFile, sizeof(args->controlFile));
+    args->reserved = 0;
+    
+    Thread *t = new Thread(SetpointControl, (void *)args);
     return t;
 }
 
-static Thread*  spawnNewCompositeControl(const char *controlFile)
+static Thread* spawnNewCompositeControl(const char *controlFile)
 {
-    Thread *t = new Thread(CompositeControl, (void *)controlFile);
+    Args_t *args = (Args_t *)malloc(sizeof(Args_t));
+    
+    strncpy(args->controlFile, controlFile, sizeof(args->controlFile));
+    args->reserved = 0;
+
+    Thread *t = new Thread(CompositeControl, (void *)args);
     return t;
 }
+
 static Thread*  spawnNewManualControl(const char *controlFile)
 {
-    Thread *t = new Thread(ManualControl, (void *)controlFile);
+    Args_t *args = (Args_t *)malloc(sizeof(Args_t));
+    
+    strncpy(args->controlFile, controlFile, sizeof(args->controlFile));
+    args->reserved = 0;
+
+    Thread *t = new Thread(ManualControl, (void *)args);
     return t;
 }