Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

Revision:
249:68ed571e0002
Parent:
0:65cfa4873284
Child:
257:e22102d2e079
--- a/src/BLEDataHandler/BLEDataHandler.cpp	Fri Oct 21 11:37:35 2016 +0000
+++ b/src/BLEDataHandler/BLEDataHandler.cpp	Fri Oct 21 13:48:57 2016 +0000
@@ -1,5 +1,5 @@
 /******************************************************************************
- * 
+ *
  * File:                BLEDataHandler.cpp
  * Desciption:          source for the ICE Bluetooth Low Energy Data Handler
  *
@@ -7,18 +7,71 @@
 #include "global.h"
 #include <stdio.h>
 #include "BLEDataHandler.h"
+#include "LoggerApi.h"
+#include "ble_main.h"
+#include "ble_init.h"
+#include "ble_msg_handler.h"
 
 /*****************************************************************************
  * Function:             BLEDataHandler
- * Description:          entry point for the Analytics Logger 
+ * Description:          entry point for the Analytics Logger
  *
  * @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)
 {
-    printf("\r%s has started...\n", __func__);
+    uint8_t tx_array[500],dummy_array[500];
+    int i =0;
+    bool send_dummy =0;
+    uint8_t status = SUCCESS;   
+    
+    /*TODO
+        Getting the init status from Nano BLE register and 
+        Proceed based on the status.    
+    */    
+    status = BLE.ConfigureBLEDevice();
+   
+    int len = strlen(json);
 
-    while ( true ) {
-    }
+    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;
+        }
+        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
+        */
+     
+    }                            
 }
\ No newline at end of file