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
bt_network/BleUartRPC/Dispatcher.h@5:9233e88b9c83, 2015-02-16 (annotated)
- Committer:
- ansond
- Date:
- Mon Feb 16 06:37:35 2015 +0000
- Revision:
- 5:9233e88b9c83
- Child:
- 6:98af441fd960
updates - pre-RPC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 5:9233e88b9c83 | 1 | /** |
ansond | 5:9233e88b9c83 | 2 | * @file Dispatcher.h |
ansond | 5:9233e88b9c83 | 3 | * @brief BLE UART RPC dispatcher header |
ansond | 5:9233e88b9c83 | 4 | * @author Doug Anson |
ansond | 5:9233e88b9c83 | 5 | * @version 1.0 |
ansond | 5:9233e88b9c83 | 6 | * @see |
ansond | 5:9233e88b9c83 | 7 | * |
ansond | 5:9233e88b9c83 | 8 | * Copyright (c) 2014 |
ansond | 5:9233e88b9c83 | 9 | * |
ansond | 5:9233e88b9c83 | 10 | * Licensed under the Apache License, Version 2.0 (the "License"); |
ansond | 5:9233e88b9c83 | 11 | * you may not use this file except in compliance with the License. |
ansond | 5:9233e88b9c83 | 12 | * You may obtain a copy of the License at |
ansond | 5:9233e88b9c83 | 13 | * |
ansond | 5:9233e88b9c83 | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
ansond | 5:9233e88b9c83 | 15 | * |
ansond | 5:9233e88b9c83 | 16 | * Unless required by applicable law or agreed to in writing, software |
ansond | 5:9233e88b9c83 | 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
ansond | 5:9233e88b9c83 | 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
ansond | 5:9233e88b9c83 | 19 | * See the License for the specific language governing permissions and |
ansond | 5:9233e88b9c83 | 20 | * limitations under the License. |
ansond | 5:9233e88b9c83 | 21 | */ |
ansond | 5:9233e88b9c83 | 22 | |
ansond | 5:9233e88b9c83 | 23 | #ifndef __RPC_DISPATCH_H__ |
ansond | 5:9233e88b9c83 | 24 | #define __RPC_DISPATCH_H__ |
ansond | 5:9233e88b9c83 | 25 | |
ansond | 5:9233e88b9c83 | 26 | #include "BLEDevice.h" |
ansond | 5:9233e88b9c83 | 27 | #include "UARTService.h" |
ansond | 5:9233e88b9c83 | 28 | |
ansond | 5:9233e88b9c83 | 29 | #include "Buffer.h" |
ansond | 5:9233e88b9c83 | 30 | |
ansond | 5:9233e88b9c83 | 31 | class Dispatcher { |
ansond | 5:9233e88b9c83 | 32 | public: |
ansond | 5:9233e88b9c83 | 33 | /** |
ansond | 5:9233e88b9c83 | 34 | Default constructor |
ansond | 5:9233e88b9c83 | 35 | @param ble the BLEDevice instance |
ansond | 5:9233e88b9c83 | 36 | @param rxsize the size of the receive ring buffer (default is 1024) |
ansond | 5:9233e88b9c83 | 37 | @param txsize the size of the transmit ring buffer (default is 1024) |
ansond | 5:9233e88b9c83 | 38 | */ |
ansond | 5:9233e88b9c83 | 39 | Dispatcher(BLEDevice &ble,int rxsize = 1024,int txsize = 1024); |
ansond | 5:9233e88b9c83 | 40 | |
ansond | 5:9233e88b9c83 | 41 | /** |
ansond | 5:9233e88b9c83 | 42 | Dispatch function request with arguments (already serialized and prepared for transport) |
ansond | 5:9233e88b9c83 | 43 | @param fn_id the identifier for the target remote function to invoke |
ansond | 5:9233e88b9c83 | 44 | @param args the serialized function argument array list |
ansond | 5:9233e88b9c83 | 45 | @param args_length the length of the serialized function argument list |
ansond | 5:9233e88b9c83 | 46 | @param response the received response buffer |
ansond | 5:9233e88b9c83 | 47 | @param response_length the recieved response buffer length |
ansond | 5:9233e88b9c83 | 48 | @returns true - dispatch succeeded, false - otherwise |
ansond | 5:9233e88b9c83 | 49 | */ |
ansond | 5:9233e88b9c83 | 50 | bool dispatch(uint8_t fn_id,uint8_t *args,int args_length,uint8_t *response,int response_length); |
ansond | 5:9233e88b9c83 | 51 | |
ansond | 5:9233e88b9c83 | 52 | private: |
ansond | 5:9233e88b9c83 | 53 | UARTService m_uart; |
ansond | 5:9233e88b9c83 | 54 | Buffer<char> m_rxbuf; |
ansond | 5:9233e88b9c83 | 55 | Buffer<char> m_txbuf; |
ansond | 5:9233e88b9c83 | 56 | }; |
ansond | 5:9233e88b9c83 | 57 | |
ansond | 5:9233e88b9c83 | 58 | #endif // __RPC_DISPATCH_H__ |