Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
280:7c1c9274cce6
Parent:
275:76285569fb64
Parent:
279:b60379a9eb1a
Child:
284:cc72206ea8e0
--- a/BLE/src/ble_msg_handler.cpp	Wed Oct 26 20:31:39 2016 +0000
+++ b/BLE/src/ble_msg_handler.cpp	Wed Oct 26 21:03:53 2016 +0000
@@ -24,11 +24,12 @@
 /******************************************************************************/
 /* Defines                                                                    */
 /******************************************************************************/
-
+#define MAX_FILE_SIZE 1000
 
 volatile bool isDeviceConnected;
 static ble_data_ready_callback_t data_ready_cb;
-
+uint8_t json_array[MAX_FILE_SIZE];
+uint8_t count,file_index,file_size;
   /*****************************************************************************
  * Function:            BLE data receive callback
  * Description:         Function used to register ble data receive callback 
@@ -63,12 +64,26 @@
                 
             case BLE_REC_DATA_CMD:
                 /*
-                TODO
-                    fill(append )the data to rx buffer and once file transfer 
-                    compleated,invoke callback function from EOF.Need to move 
-                    belo function to EOF.Appending data function to be added here               
-                */               
-                data_ready_cb(&spi_rcv_array[3], (spi_rcv_array[2]-1));                
+                    when nRF UART send a packet to mDot board, we are incrementing
+                    a counter and till count equals 3, we are appending data to
+                    json Array.when it equals 3,ie 60 bytes(assuming that each time 
+                    we are sening 20 bytes), passing this to callback to main
+                    function.          
+                */                 
+                
+                count++; 
+                /*reassembling packets */
+                memcpy(&json_array[file_index],&spi_rcv_array[3], (spi_rcv_array[2]-4));
+
+                file_index+= (spi_rcv_array[2]-4);    //((spi_rcv_array[2]-4) contains packet length excluding headers                
+                
+                if(count ==3)   //added for testing. Need to change this to if(file_index == file_size)
+                {
+                    /*Passing the entire file to callback function*/
+                    data_ready_cb(json_array, file_index);
+                    count= 0;
+                    file_index =0;
+                }                   
                 break;
                 
             case BLE_DISCONNECTION_EVNT_CMD:
@@ -77,11 +92,13 @@
                 break;
                 
             case BLE_START_OF_FILE:
+            
                 file_receiving_flag = true;
-                /*
-                TODO
-                    extract the json string length from SOF.                
-                */   
+
+            /*extract the json string length from SOF. */               
+
+                file_size = spi_rcv_array[3];
+                   
                 break;
                 
             case BLE_END_OF_FILE:                
@@ -100,4 +117,4 @@
 
 /******************************************************************************/
 /* END OF FILE                                                                */
-/******************************************************************************/
\ No newline at end of file
+/******************************************************************************/