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
Diff: BLE/src/ble_msg_handler.cpp
- Revision:
- 249:68ed571e0002
- Child:
- 259:341f04be325e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BLE/src/ble_msg_handler.cpp Fri Oct 21 13:48:57 2016 +0000 @@ -0,0 +1,112 @@ +/** + ****************************************************************************** + * @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" + +/******************************************************************************/ +/* Defines */ +/******************************************************************************/ + + +volatile bool isDeviceConnected_flag; + +/***************************************************************************** + * Function: process_rx_data() + * Description: Process BLE data + * + * @param spi_rcv_array +* @param length + * @return none + *****************************************************************************/ +void process_rx_data(uint8_t *spi_rcv_array, uint8_t len) +{ + static bool file_receiving_flag = false; + static uint16_t file_size = 0; + static uint8_t file_name[16]; + + if (spi_rcv_array[1] == BLE_SOF_CMD) { + switch (spi_rcv_array[2]) + { + case BLE_CONNECTION_EVNT_CMD: + printf("Mobile device connceted\n\r"); + isDeviceConnected_flag =true; + break; + + case BLE_REC_DATA_CMD: + printf("Data Received : \n\r"); + break; + + case BLE_DISCONNECTION_EVNT_CMD: + printf("Mobile disconnected\n\r"); + isDeviceConnected_flag =false; + break; + + case BLE_START_OF_FILE: + file_receiving_flag = true; + file_size = spi_rcv_array[4] << 8 | spi_rcv_array[5]; + memcpy (file_name, &spi_rcv_array[6], spi_rcv_array[3]); + printf("File name %s receving from mobile. File Size: %d\n\r", file_name, file_size); + break; + + case BLE_END_OF_FILE: + + /* End of file received */ + // file_available_cb(file_name, file_size); + + /* Reset the File Parameters */ + file_receiving_flag = false; + file_size = 0; + memset(file_name, 0, sizeof(file_name)); + break; + + default: + printf("Unknown ID\n\r"); + break; + } + } else { + printf("SOF not found\n\r"); + } +} +/***************************************************************************** + * Function: msg_handler() + * Description: msg_handler + * + * @param spi_rcv_array + * @param None + * @return none + *****************************************************************************/ +void msg_handler(void) +{ + + uint8_t spi_rcv_array[100]; + uint8_t len; +// printf("Reading from Master\n\r"); + + len = ReadSpiData(spi_rcv_array); + + process_rx_data(spi_rcv_array, len); + + +} + +/******************************************************************************/ +/* END OF FILE */ +/******************************************************************************/ \ No newline at end of file