-
Notifications
You must be signed in to change notification settings - Fork 3k
Cordio driver hook #7163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cordio driver hook #7163
Conversation
A friend class living in the namespace ble::vendor::cordio and named CordioHCITransportDriver can be added in applications requiring access to internal data of the HCI driver and HCI transport driver. This is meant to be internal and not easily exploitable by application code.
void CordioHCITransportDriver::on_data_received(uint8_t* data, uint16_t len) | ||
{ | ||
hciTrSerialRxIncoming(data, len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right above; in the static member CordioHCITransportDriver::data_received_handler
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh hadn't seen that 👍
void CordioHCITransportDriver::on_data_received(uint8_t* data, uint16_t len) | ||
{ | ||
hciTrSerialRxIncoming(data, len); | ||
while (len) { | ||
uint8_t chunk_length = std::min(len, (uint16_t) std::numeric_limits<uint8_t>::max()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you chunking it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a fix of an unnoticed but, the driver accept uint16_t
as the size of data received while the cordio function only accepts uint8_t
as the size argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -58,6 +58,10 @@ struct buf_pool_desc_t { | |||
* - Access to the write function of the underlying HCITransport driver. | |||
*/ | |||
class CordioHCIDriver { | |||
|
|||
// hook for internal tests and passthrough driver | |||
friend class CordioHCIHook; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not that I mind but why not just set the handler public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Encapsulation. Make interfaces easy to use correctly and hard to use incorrectly.
If it was public then it means that the system has been designed to support replacement of the RX handler; it hasn't and it won't! This would lead to disasters if application code was replacing the RX handler.
void CordioHCITransportDriver::on_data_received(uint8_t* data, uint16_t len) | ||
{ | ||
hciTrSerialRxIncoming(data, len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing file?
void CordioHCITransportDriver::on_data_received(uint8_t* data, uint16_t len) | ||
{ | ||
hciTrSerialRxIncoming(data, len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh hadn't seen that 👍
void CordioHCITransportDriver::on_data_received(uint8_t* data, uint16_t len) | ||
{ | ||
hciTrSerialRxIncoming(data, len); | ||
while (len) { | ||
uint8_t chunk_length = std::min(len, (uint16_t) std::numeric_limits<uint8_t>::max()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
/morph build |
1 similar comment
/morph build |
Build : FAILUREBuild number : 2298 |
/morph build |
Build : SUCCESSBuild number : 2304 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 1926 |
Description
This patch adds the necessary mechanisms to get access to the internals of the classes
CordioHCIDriver
andCordioHCITransportDriver
. With this change a class living in the namespaceble::vendor::cordio
and namedCordioHCIHook
can get access to the internal of both classes mentioned above.This patch also allows dynamic override of the RX handler.
Note: It is not meant to be used by application; it will be used in internals tests.
Pull request type