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:
- davidjhoward
- Date:
- 2016-10-24
- Revision:
- 259:341f04be325e
- Parent:
- 249:68ed571e0002
- Parent:
- 258:150f5a76162d
File content as of revision 259:341f04be325e:
/** ****************************************************************************** * @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; bool send_json =false; //remove:added to check mdot and APP communication. /***************************************************************************** * 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; static uint16_t file_size = 0; static uint8_t file_name[16]; 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 =true; break; case BLE_REC_DATA_CMD: 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 =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); ProcessBleRxEvents(spi_rcv_array, len); } /******************************************************************************/ /* END OF FILE */ /******************************************************************************/