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:
- 36:aa73681951ad
- Parent:
- 35:71eb3663ecbd
--- a/bt_network/BleUartRPC/UartRPCFunctions.cpp Fri Sep 04 21:04:08 2015 +0000 +++ b/bt_network/BleUartRPC/UartRPCFunctions.cpp Mon Sep 07 04:51:43 2015 +0000 @@ -31,7 +31,7 @@ #endif #define DBG std::printf - UartRPC *__rpc = NULL; + static UartRPC *__rpc = NULL; void ble_rpc_init(BLEDevice &ble) { @@ -40,32 +40,36 @@ bool ble_rpc_open_udp_socket(char *ip_address,int port,ble_dispatch_callback_fn cb) { + bool status = false; uint8_t response[2]; memset(response,0,2); + //DBG("ble_rpc_open_udp_socket: UDP Socket open() dispatching...\r\n"); if (__rpc->dispatch(SOCKET_OPEN_FN,(void *)cb,response,2,"%s %d",ip_address,port) > 0) { //DBG("ble_rpc_open_udp_socket: UDP Socket open() dispatched SUCCESSFULLY\r\n"); - return true; + status = true; } // failure //DBG("ble_rpc_open_udp_socket: UDP Socket open() dispatch failed\r\n"); - return false; + return status; } bool ble_rpc_close_udp_socket(void) { + bool status = false; uint8_t response[2]; memset(response,0,2); + //DBG("ble_rpc_open_udp_socket: UDP Socket close() dispatched successfully. Waiting on response...\r\n"); if (__rpc->dispatch(SOCKET_CLOSE_FN,NULL,response,2,"%s","loc") > 0) { //DBG("ble_rpc_close_udp_socket: UDP Socket close() dispatched SUCCESSFULLY\r\n"); - return true; + status = true; } // failure //DBG("ble_rpc_close_udp_socket: UDP Socket close() dispatch failed\r\n"); - return false; + return status; } int ble_rpc_send_data(uint8_t *data,int data_length) @@ -92,13 +96,14 @@ } int ble_rpc_recv_packet(uint8_t *buffer,int buffer_length) - { + { + int n = 0; //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); + n = __rpc->retrieveLocalDispatch(buffer,buffer_length); } - return 0; + return n; } int ble_rpc_recv_data(uint8_t *buffer,int buffer_length)