Skip to content

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

Merged
merged 2 commits into from
Jun 11, 2018
Merged

Cordio driver hook #7163

merged 2 commits into from
Jun 11, 2018

Conversation

pan-
Copy link
Member

@pan- pan- commented Jun 7, 2018

Description

This patch adds the necessary mechanisms to get access to the internals of the classes CordioHCIDriver and CordioHCITransportDriver. With this change a class living in the namespace ble::vendor::cordio and named CordioHCIHook 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

[ ] Fix
[ ] Refactor
[ ] New target
[X] Feature
[ ] Breaking change

pan- added 2 commits June 7, 2018 12:29
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing file?

Copy link
Member Author

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.

Copy link
Contributor

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());
Copy link
Contributor

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?

Copy link
Member Author

@pan- pan- Jun 7, 2018

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.

Copy link
Contributor

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;
Copy link
Member

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?

Copy link
Member Author

@pan- pan- Jun 7, 2018

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);
Copy link
Contributor

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);
Copy link
Contributor

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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 8, 2018

/morph build

1 similar comment
@0xc0170
Copy link
Contributor

0xc0170 commented Jun 9, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jun 9, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 10, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jun 10, 2018

Build : SUCCESS

Build number : 2304
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7163/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Jun 10, 2018

@mbed-ci
Copy link

mbed-ci commented Jun 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants