Erick / Mbed 2 deprecated ICE_BLE_TEST

Dependencies:   NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed

Fork of ICE by Erick

src/BLEDataHandler/BLEDataHandler.cpp

Committer:
davidjhoward
Date:
2016-10-21
Revision:
249:68ed571e0002
Parent:
0:65cfa4873284
Child:
257:e22102d2e079

File content as of revision 249:68ed571e0002:

/******************************************************************************
 *
 * File:                BLEDataHandler.cpp
 * Desciption:          source for the ICE Bluetooth Low Energy Data Handler
 *
 *****************************************************************************/
#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
 *
 * @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;   
    
    /*TODO
        Getting the init status from Nano BLE register and 
        Proceed based on the status.    
    */    
    status = BLE.ConfigureBLEDevice();
   
    int len = strlen(json);

    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
        */
     
    }                            
}