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/Dispatcher.h
- Revision:
- 6:98af441fd960
- Parent:
- 5:9233e88b9c83
- Child:
- 7:203c348ccc66
--- a/bt_network/BleUartRPC/Dispatcher.h Mon Feb 16 06:37:35 2015 +0000 +++ b/bt_network/BleUartRPC/Dispatcher.h Tue Feb 17 02:56:36 2015 +0000 @@ -25,18 +25,19 @@ #include "BLEDevice.h" #include "UARTService.h" - - #include "Buffer.h" + + #define MAX_PACKET_LENGTH 512 // longest packet we will send + #define MAX_ARGUMENT_LENGTH 512 // longest argument sent as parameter list + #define MAX_RESULT_LENGTH 512 // longest result received + #define UART_SEGMENT_LENGTH 20 // BLE: max UART MTU (will trigger send immediately...) class Dispatcher { public: /** Default constructor @param ble the BLEDevice instance - @param rxsize the size of the receive ring buffer (default is 1024) - @param txsize the size of the transmit ring buffer (default is 1024) */ - Dispatcher(BLEDevice &ble,int rxsize = 1024,int txsize = 1024); + Dispatcher(BLEDevice &ble); /** Dispatch function request with arguments (already serialized and prepared for transport) @@ -45,14 +46,17 @@ @param args_length the length of the serialized function argument list @param response the received response buffer @param response_length the recieved response buffer length - @returns true - dispatch succeeded, false - otherwise + @returns number of bytes sent in dispatch() or -1 if in failure */ - bool dispatch(uint8_t fn_id,uint8_t *args,int args_length,uint8_t *response,int response_length); + int dispatch(uint8_t fn_id,uint8_t *args,int args_length,uint8_t *response,int response_length); private: + int uart_write(uint8_t *data,int data_length); + int prepare_send_packet(uint8_t fn_id,uint8_t *args,int args_length); + + uint8_t m_send_packet[MAX_PACKET_LENGTH+1]; + UARTService m_uart; - Buffer<char> m_rxbuf; - Buffer<char> m_txbuf; }; #endif // __RPC_DISPATCH_H__ \ No newline at end of file