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: libnsdl_m0 BLE_API Base64 nRF51822 SplitterAssembler
Diff: bt_network/BleUartRPC/UartRPC.cpp
- Revision:
- 33:4f6929e123f2
- Parent:
- 16:fb9c3f2af2df
- Child:
- 35:71eb3663ecbd
--- a/bt_network/BleUartRPC/UartRPC.cpp Sat Jul 25 06:10:42 2015 +0000 +++ b/bt_network/BleUartRPC/UartRPC.cpp Sat Jul 25 19:15:48 2015 +0000 @@ -29,11 +29,16 @@ #endif #define DBG std::printf + // immediate response variable pointers... + uint8_t *_immediate_response_buffer = NULL; + int _immediate_response_buffer_length = 0; + // constructor UartRPC::UartRPC(BLEDevice &ble) : m_dispatcher(ble), m_recv_accumulator() { this->m_recv_raw_data = NULL; this->m_recv_raw_data_length = 0; this->m_local_dispatch_available = false; + this->m_location = NULL; } uint8_t __tmp_buffer[MAX_ARGUMENT_LENGTH+1]; @@ -56,6 +61,11 @@ return this->m_dispatcher.dispatch(fn_id,__tmp_buffer,strlen((char *)__tmp_buffer),response,response_length); } + // set the location instance + void UartRPC::setLocationInstance(BLELocation *location) { + this->m_location = location; + } + // dispatch locally void UartRPC::dispatch() { // assemble the argument buffer... @@ -115,6 +125,22 @@ this->m_cb = NULL; break; } + case GET_LOCATION_FN: { + // reset our local dispatch + this->resetLocalDispatch(); + + // process the location update response... + Base64 b64; + base64_buffer_length = final_length; + char *location = b64.Decode((char *)base64_buffer,strlen((char *)base64_buffer),(std::size_t *)&base64_buffer_length); + int location_length = base64_buffer_length; // modified by Decode().... + //DBG("UartRPC: dispatch(local): GET_LOCATION_FN: location(%d): %s\r\n",location_length,location); + if (this->m_location != NULL) this->m_location->processLocationUpdateResponse(location,location_length); + + // local dispatch is now ready... + this->m_local_dispatch_available = true; + break; + } case RECV_DATA_FN: { // reset our local dispatch //DBG("UartRPC: dispatch(local): resetting...\r\n"); @@ -137,6 +163,8 @@ default: { // all other function ID's are non-local DBG("UartRPC: dispatch(local): ignoring non-local function call request (id=0x%.2x)...\r\n",fn_id); + + // reset the local dispatch this->resetLocalDispatch(); break; }