File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
features/FEATURE_BLE/targets/TARGET_CORDIO/driver Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,10 @@ struct buf_pool_desc_t {
58
58
* - Access to the write function of the underlying HCITransport driver.
59
59
*/
60
60
class CordioHCIDriver {
61
+
62
+ // hook for internal tests and passthrough driver
63
+ friend class CordioHCIHook ;
64
+
61
65
public:
62
66
/* *
63
67
* Construct a new instance of an HCI driver.
Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
+ #include < algorithm>
18
+ #include < limits>
19
+
17
20
#include " CordioHCITransportDriver.h"
18
21
#include " CordioHCIDriver.h"
19
22
@@ -23,9 +26,22 @@ namespace ble {
23
26
namespace vendor {
24
27
namespace cordio {
25
28
29
+ CordioHCITransportDriver::data_received_handler_t
30
+ CordioHCITransportDriver::data_received_handler = hciTrSerialRxIncoming;
31
+
26
32
void CordioHCITransportDriver::on_data_received (uint8_t * data, uint16_t len)
27
33
{
28
- hciTrSerialRxIncoming (data, len);
34
+ while (len) {
35
+ uint8_t chunk_length = std::min (len, (uint16_t ) std::numeric_limits<uint8_t >::max ());
36
+ data_received_handler (data, chunk_length);
37
+ len = len - chunk_length;
38
+ data = data + chunk_length;
39
+ }
40
+ }
41
+
42
+ void CordioHCITransportDriver::set_data_received_handler (data_received_handler_t handler)
43
+ {
44
+ data_received_handler = handler;
29
45
}
30
46
31
47
} // namespace cordio
Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ namespace cordio {
28
28
* It allow the stack to write data in the HCI channel.
29
29
*/
30
30
class CordioHCITransportDriver {
31
+
32
+ // hook for internal tests and passthrough driver
33
+ friend class CordioHCIHook ;
34
+
31
35
public:
32
36
/* *
33
37
* Driver destructor.
@@ -64,6 +68,13 @@ class CordioHCITransportDriver {
64
68
* @param len Number of bytes received.
65
69
*/
66
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);
67
78
};
68
79
69
80
} // namespace cordio
You can’t perform that action at this time.
0 commit comments