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/UartRPCFunctions.cpp
- Revision:
- 9:bf0cf5828378
- Parent:
- 6:98af441fd960
- Child:
- 11:d601b867b297
--- a/bt_network/BleUartRPC/UartRPCFunctions.cpp Tue Feb 17 07:01:22 2015 +0000 +++ b/bt_network/BleUartRPC/UartRPCFunctions.cpp Wed Feb 18 06:58:01 2015 +0000 @@ -31,14 +31,6 @@ #endif #define DBG std::printf - typedef enum { - SOCKET_OPEN_FN = 0x01, - SOCKET_CLOSE_FN = 0x02, - SEND_DATA_FN = 0x04, - RECV_DATA_FN = 0x08, - NUM_FNs = 4 - } FunctionIDs; - UartRPC *__rpc = NULL; void ble_rpc_init(BLEDevice &ble) @@ -89,28 +81,23 @@ return sent_length; } + int ble_rpc_recv_packet(uint8_t *buffer,int buffer_length) + { + DBG("ble_rpc_recv_packet: checking for a local dispatch...\r\n"); + if (__rpc->localDispatchAvailable()) { + DBG("ble_rpc_recv_packet: local dispatch is ready. Retrieving...\r\n"); + return __rpc->retrieveLocalDispatch(buffer,buffer_length); + } + return 0; + } + int ble_rpc_recv_data(uint8_t *buffer,int buffer_length) { - /* - uint8_t base64_buffer[MAX_RESULT_LENGTH+1]; - memset(base64_buffer,0,MAX_RESULT_LENGTH+1); - DBG("ble_rpc_recv_data: seeing if any data is available...\r\n"); - int recv_length =__rpc->dispatch(RECV_DATA_FN,base64_buffer,MAX_RESULT_LENGTH,"%s",""); - DBG("ble_rpc_recv_data: received %d bytes of data...\r\n",recv_length); - if (recv_length > 0) { - // success - Base64 b64; - int base64_length = buffer_length; - char *raw_buffer = b64.Decode((char *)base64_buffer,strlen((char *)base64_buffer),(std::size_t *)&base64_length); - memcpy(buffer,raw_buffer,base64_length); - if (raw_buffer != NULL) free(raw_buffer); - return base64_length; + DBG("ble_rpc_recv_data: got data...\r\n"); + if (__rpc->accumulate(buffer,buffer_length)) { + DBG("ble_rpc_recv_data: received entire packet.. dispatching locally...\r\n"); + __rpc->dispatch(); } - else { - // failure - DBG("ble_rpc_recv_data: dispatch() failed\r\n"); - } - */ - return -1; + return buffer_length; } \ No newline at end of file