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