Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
257:e22102d2e079
Parent:
249:68ed571e0002
Child:
266:09ba8e22963d
--- a/src/BLEDataHandler/BLEDataHandler.cpp	Fri Oct 21 13:48:57 2016 +0000
+++ b/src/BLEDataHandler/BLEDataHandler.cpp	Mon Oct 24 21:05:41 2016 +0000
@@ -11,6 +11,7 @@
 #include "ble_main.h"
 #include "ble_init.h"
 #include "ble_msg_handler.h"
+#include "ble_spi.h"
 
 /*****************************************************************************
  * Function:             BLEDataHandler
@@ -19,59 +20,29 @@
  * @param                (IN) args (user-defined arguments)
  * @return               none
  *****************************************************************************/
- 
- char * json = "{\"mancontrol\": [\"m_type\", 100], [\"priority\", 100],\"state\": true}";
 
 BLE_FILE BLE;
 BLE_INIT ble_init;
 
 void BLEDataHandler(void const *args)
 {
-    uint8_t tx_array[500],dummy_array[500];
-    int i =0;
-    bool send_dummy =0;
-    uint8_t status = SUCCESS;   
-    
+    uint8_t tx_array[500], rx_buf[500];
+    uint8_t event_status;
+
     /*TODO
-        Getting the init status from Nano BLE register and 
-        Proceed based on the status.    
-    */    
-    status = BLE.ConfigureBLEDevice();
-   
-    int len = strlen(json);
+        Getting the init status from Nano BLE register and
+        Proceed based on the status.
+    */
+    event_status = BLE.ConfigureBLEDevice();
 
-    for(i = 0; i < len; i++)
-    {
-        tx_array[i] = json[i];
-        dummy_array[i] = 'a' +i;
-    }  
-    
-    printf("BLE Handler Waiting for connection..\n\r");   
-        
-    while(1)
-    {              
-        if(send_dummy ==false)
-        {
-            /*TODO            
-                sending a dummy packet to Nano BLE before file transfer.
-                This need to be removed.            
-            */   
-            ble_init.SendBleData(dummy_array, 1);
-            send_dummy =true;
+    while(1) {
+
+        event_status = PollBLEEvents(rx_buf);
+        if(event_status == true) {
+            printf("BLE Handler rx_buf=%s\r\n",rx_buf);
+            GetCurrentReadings( (char *)tx_array, sizeof(tx_array));
+            BLE.SendFile(tx_array,strlen((char *)tx_array));
         }
-        wait(5);          
-        /*TODO
-            Before sending the file to Nano BLE,need to check Nano BLE device 
-            connection status.Peviously GPIO line used.This status can be read 
-            by sending a command to Nano BLE.This implemnttaion is pending.               
-        */
-        GetCurrentReadings( (char *)tx_array, sizeof(tx_array));
-                  
-        BLE.SendFile(tx_array,strlen((char *)tx_array));                        
-        
-        /*TODO
-            Reading data from Nano BLE Pending
-        */
-     
-    }                            
+        Thread::wait(100);
+    }
 }
\ No newline at end of file