Sarah Marsh / Mbed OS mbed-os-example-ble-voice

Fork of mbed-os-example-ble-LED by mbed-os-examples

Revision:
25:b08a7d2c30b6
Parent:
24:0770ad9edb2d
--- a/source/main.cpp	Mon Apr 03 18:44:40 2017 +0000
+++ b/source/main.cpp	Thu Jun 01 16:18:49 2017 +0000
@@ -14,10 +14,9 @@
  * limitations under the License.
  */
 
-#include <events/mbed_events.h>
-#include <mbed.h>
-#include "ble/BLE.h"
+
 #include "UARTService.h"
+#include "mbed.h"
 
 DigitalOut alivenessLED(LED1, 0);
 DigitalOut actuatedLED(LED2, 0);
@@ -55,13 +54,13 @@
 }
 
 /**
- * This callback allows the LEDService to receive updates to the ledState Characteristic.
+ * This callback allows the UARTService to receive updates to the UART buffer
  *
  * @param[in] params
  *     Information about the characterisitc being updated.
  */
 void onDataWrittenCallback(const GattWriteCallbackParams *params) {
-    char  rcv[UARTServicePtr->BLE_UART_SERVICE_MAX_DATA_LEN];
+    char* rcv = (char*)malloc(UARTServicePtr->BLE_UART_SERVICE_MAX_DATA_LEN);
     int c = UARTServicePtr->_getc();
     int i = 0;
     while (c != EOF){
@@ -71,6 +70,7 @@
     rcv[UARTServicePtr->BLE_UART_SERVICE_MAX_DATA_LEN-1] = '\0';
     printf("%s\r\n", rcv);
     check_command(rcv);
+    free(rcv);
 }
 
 /**