BLE Nano Code.Tested with Integrated mDot code

Dependencies:   BLE_API mbed nRF51822

Fork of eco_Labs_ble_Client by Happiest

Revision:
33:17b8c186eb07
Parent:
32:bb3b81b06676
Child:
34:d146cdbffd91
--- a/ble_msg_handler.cpp	Wed Dec 07 10:05:21 2016 +0000
+++ b/ble_msg_handler.cpp	Thu Dec 15 06:26:45 2016 +0000
@@ -50,13 +50,11 @@
  */
 static void ble_rx_Data_Callback(uint8_t *rx_data, uint8_t len)
 {
-    uint8_t send_buf[100];
+    uint8_t send_buf[SPI_TX_BUF_SIZE];
              
     send_buf[0] = BLE_SOF_CMD;
-//    send_buf[1] = BLE_REC_DATA_CMD;
     send_buf[1] = rx_data[0];       
     send_buf[2] = len+4;  
-      
     memcpy(&send_buf[3], &rx_data[1], (len-1));
     send_buf[len + 3] = BLE_EOT_CMD;    
     spi_slave_tx_data(send_buf, (len + 4));
@@ -70,20 +68,20 @@
  */
 void spi_rx_Data_Callback(uint8_t *rx_data, uint8_t len)
 {    
-    uint8_t tmp_buf[30];
+    uint8_t tmp_buf[SPI_TX_BUF_SIZE];
     if(rx_data !=NULL)
     {         
-        if (rx_data[1] == 0xFF) {  
-            //Dummy packet from mDot to clear buffer.
-        } else if (rx_data[1] == BLE_SOF_CMD) {        
+        if (rx_data[1] == 0xFF) 
+        {
+            //Dummy send to clear buffer.
+        } 
+        else if (rx_data[1] == BLE_SOF_CMD) 
+        {        
             switch (rx_data[2]) {
                 case BLE_INIT_CMD:
-                        /* TODO: Get the BLE Device name from rx_data and pass it to
-                         ble_init */
                         if(init_success ==false)
                         {
-                            memcpy(tmp_buf, &rx_data[4], rx_data[3]);
-                            //memset(tmp_buf, 'a', 5);                                        
+                            memcpy(tmp_buf, &rx_data[4], rx_data[3]);                                   
                             ble_init(tmp_buf,rx_data[3]);
                             toggle_led();
                         }
@@ -100,7 +98,6 @@
                     break;
                     
                 case BLE_START_OF_FILE:
-    //                toggle_led();
                     memcpy(tmp_buf, &rx_data[4], rx_data[3]);                
                     ble_send_data(tmp_buf, rx_data[3]);
                     break;
@@ -109,6 +106,12 @@
                     memcpy(tmp_buf, &rx_data[4], rx_data[3]);
                     ble_send_data(tmp_buf, rx_data[3]);
                     break;
+ 
+                case BLE_RESET_CMD:
+                    
+                    /*Performing system reset*/   
+                    NVIC_SystemReset();
+                    break;
                     
                 default :
                     break;