Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NaturalTinyShell_ice libmDot-12Sept mbed-rtos mbed
Fork of ICE by
BLE/src/ble_msg_handler.cpp
- Committer:
- jmarkel44
- Date:
- 2016-10-26
- Revision:
- 275:76285569fb64
- Parent:
- 265:0fb72c26ae68
- Child:
- 280:7c1c9274cce6
File content as of revision 275:76285569fb64:
/** ****************************************************************************** * @file ble_uart.cpp * @author Happiesstminds Firmware Team * @version v1.0 * @date 4-Oct-2016 * @brief * ****************************************************************************** * @attention * * ****************************************************************************** */ /******************************************************************************/ /* Include Files*/ /******************************************************************************/ #include "mbed.h" #include "ble_msg_handler.h" #include "ble_spi.h" #include "ble_main.h" /******************************************************************************/ /* Defines */ /******************************************************************************/ volatile bool isDeviceConnected; static ble_data_ready_callback_t data_ready_cb; /***************************************************************************** * Function: BLE data receive callback * Description: Function used to register ble data receive callback * * @param ble_data_ready_callback_t * @return none *****************************************************************************/ void BleDataRxCbRegister(ble_data_ready_callback_t data_rx_callback) { data_ready_cb = data_rx_callback; } /***************************************************************************** * Function: ProcessBleRxEvents() * Description: Process BLE data * * @param spi_rcv_array * @param length * @return none *****************************************************************************/ void ProcessBleRxEvents(uint8_t *spi_rcv_array, uint8_t len) { static bool file_receiving_flag = false; if (spi_rcv_array[0] == BLE_SOF_CMD) { switch (spi_rcv_array[1]) { case BLE_CONNECTION_EVNT_CMD: printf("Mobile device connected...\n\r"); isDeviceConnected =true; break; 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)); break; case BLE_DISCONNECTION_EVNT_CMD: printf("Mobile device disconnected...\n\r"); isDeviceConnected =false; break; case BLE_START_OF_FILE: file_receiving_flag = true; /* TODO extract the json string length from SOF. */ break; case BLE_END_OF_FILE: /* Reset the File Parameters */ file_receiving_flag = false; break; default: printf("Unknown ID\n\r"); break; } } else { printf("SOF not found\n\r"); } } /******************************************************************************/ /* END OF FILE */ /******************************************************************************/