Mistake on this page?
Report an issue in GitHub or email us
CordioHCITransportDriver.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2017-2017 ARM Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef IMPL_HCI_TRANSPORT_DRIVER_H_
18 #define IMPL_HCI_TRANSPORT_DRIVER_H_
19 
20 #include <cstdint>
21 
22 namespace ble {
23 
24 /**
25  * Base class of the HCI transport driver.
26  * It allow the stack to write data in the HCI channel.
27  */
29 
30  // hook for internal tests and passthrough driver
31  friend class CordioHCIHook;
32 
33 public:
34  /**
35  * Driver destructor.
36  */
37  virtual ~CordioHCITransportDriver() = default;
38 
39  /**
40  * Inialization of the transport.
41  */
42  virtual void initialize() = 0;
43 
44  /**
45  * termination of the transport.
46  */
47  virtual void terminate() = 0;
48 
49  /**
50  * Write data in the transport channel.
51  *
52  * @param type The type of packet to transmit. It might be an HCI command
53  * packet, ACL packet or EVT packet. Depending on the type of transport
54  * it can prefix the packet itself.
55  * @param len Number of bytes to transmit.
56  * @param pData Pointer to the data to transmit. This is an WSF buffer
57  * and if CORDIO_ZERO_COPY_HCI is enabled we receive ownership.
58  *
59  * @return The number of bytes which have been transmited.
60  */
61  virtual uint16_t write(uint8_t type, uint16_t len, uint8_t *pData) = 0;
62 
63  /**
64  * The driver shall call this function whenever data bytes are received.
65  *
66  * @param data Pointer to the data received.
67  * @param len Number of bytes received.
68  */
69  static void on_data_received(uint8_t* data, uint16_t len);
70 
71 private:
72  typedef void (*data_received_handler_t)(uint8_t* data, uint8_t len);
73 
74  static data_received_handler_t data_received_handler;
75 
76  static void set_data_received_handler(data_received_handler_t handler);
77 };
78 
79 } // namespace ble
80 
81 #endif /* IMPL_HCI_TRANSPORT_DRIVER_H_ */
Base class of the HCI transport driver.
virtual void terminate()=0
termination of the transport.
virtual ~CordioHCITransportDriver()=default
Driver destructor.
virtual uint16_t write(uint8_t type, uint16_t len, uint8_t *pData)=0
Write data in the transport channel.
Entry namespace for all BLE API definitions.
static void on_data_received(uint8_t *data, uint16_t len)
The driver shall call this function whenever data bytes are received.
virtual void initialize()=0
Inialization of the transport.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.