Skip to content

samples: Bluetooth: hci_uart: Implement NOP Command Complete #14682

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
Apr 11, 2019

Conversation

carlescufi
Copy link
Member

@carlescufi carlescufi commented Mar 19, 2019

Implement the Controller counterpart to CONFIG_BT_WAIT_NOP so that it
issues a NOP Command Complete event after booting up, to signal to the
Host that it is ready to receive HCI traffic.

Fixes #15333

Signed-off-by: Carles Cufi [email protected]

@codecov-io
Copy link

Codecov Report

Merging #14682 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #14682   +/-   ##
=======================================
  Coverage   51.97%   51.97%           
=======================================
  Files         309      309           
  Lines       45584    45584           
  Branches    10555    10555           
=======================================
  Hits        23694    23694           
  Misses      17082    17082           
  Partials     4808     4808

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2320973...bfb4415. Read the comment docs.

@carlescufi
Copy link
Member Author

carlescufi commented Apr 10, 2019

Output of a reset with this patch:

image

@jhedberg @lemrey can you double-check the event is correctly formatted?

@lemrey
Copy link
Collaborator

lemrey commented Apr 10, 2019

This should address #15333.

@carlescufi carlescufi requested a review from joerchan April 10, 2019 14:46
@carlescufi carlescufi added the bug The issue is a bug, or the PR is fixing a bug label Apr 10, 2019
@carlescufi carlescufi added this to the v1.14.0 milestone Apr 10, 2019
Copy link
Member

@jhedberg jhedberg left a comment

Choose a reason for hiding this comment

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

Looks generally good, except for one minor endianness "correctness" issue

},
.cc = {
.ncmd = 1,
.opcode = BT_OP_NOP,
Copy link
Member

Choose a reason for hiding this comment

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

I know that it makes no difference in practice, however this should really be sys_cpu_to_le16(BT_OP_NOP) to keep track of what endianness .opcode is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this actually allowed on an initializer?

Copy link
Member

Choose a reason for hiding this comment

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

On big endian this maps to __bswap_16() which is defined as follows:

#define __bswap_16(x) ((u16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) 

I'd think the compiler should be able to handle that even for the initialiser of a const variable, but you could always try it by using __bswap_16(BT_OP_NOP)

Copy link
Member Author

Choose a reason for hiding this comment

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

It is. Updated, thanks!

};

for (i = 0; i < sizeof(cc_evt); i++) {
uart_poll_out(hci_uart_dev, *(((u8_t *)&cc_evt)+i));
Copy link
Member

Choose a reason for hiding this comment

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

(const u8_t *), just for consistency

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, thank you

Implement the Controller counterpart to CONFIG_BT_WAIT_NOP so that it
issues a NOP Command Complete event after booting up, to signal to the
Host that it is ready to receive HCI traffic.

Fixes zephyrproject-rtos#15333

Signed-off-by: Carles Cufi <[email protected]>
In order to fit in SRAM, reduce the CONFIG_BT_MAX_CONN from 20 to 16 in
the configuration used for the BBC micro:bit.

Signed-off-by: Carles Cufi <[email protected]>
Copy link
Collaborator

@lemrey lemrey left a comment

Choose a reason for hiding this comment

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

LGTM

@carlescufi carlescufi merged commit 14c7570 into zephyrproject-rtos:master Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants