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:
- 259:341f04be325e
- Parent:
- 249:68ed571e0002
- Parent:
- 258:150f5a76162d
--- a/BLE/src/ble_msg_handler.cpp Fri Oct 21 19:13:21 2016 +0000 +++ b/BLE/src/ble_msg_handler.cpp Mon Oct 24 21:08:15 2016 +0000 @@ -26,37 +26,52 @@ /******************************************************************************/ -volatile bool isDeviceConnected_flag; - +volatile bool isDeviceConnected; +bool send_json =false; //remove:added to check mdot and APP communication. /***************************************************************************** - * Function: process_rx_data() + * Function: ProcessBleRxEvents() * Description: Process BLE data * * @param spi_rcv_array * @param length * @return none *****************************************************************************/ -void process_rx_data(uint8_t *spi_rcv_array, uint8_t len) +void ProcessBleRxEvents(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]) + if (spi_rcv_array[0] == BLE_SOF_CMD) { + switch (spi_rcv_array[1]) { case BLE_CONNECTION_EVNT_CMD: printf("Mobile device connceted\n\r"); - isDeviceConnected_flag =true; + isDeviceConnected =true; break; case BLE_REC_DATA_CMD: - printf("Data Received : \n\r"); + printf("Data Received : "); + /* + TODO + for testing purpose, if the mobile APP send first data as + 'a', then mDot send a test JSON string as reply. + */ + for(int i=3;i<(spi_rcv_array[2]-1);i++) + { + if(spi_rcv_array[3] == 0x61) + { + send_json =true; + } + printf("%c",spi_rcv_array[i]); + + } + printf("\n\r"); break; case BLE_DISCONNECTION_EVNT_CMD: printf("Mobile disconnected\n\r"); - isDeviceConnected_flag =false; + isDeviceConnected =false; break; case BLE_START_OF_FILE: @@ -102,7 +117,7 @@ len = ReadSpiData(spi_rcv_array); - process_rx_data(spi_rcv_array, len); + ProcessBleRxEvents(spi_rcv_array, len); }