samples: Bluetooth: hci_uart: Implement NOP Command Complete

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 <carles.cufi@nordicsemi.no>
This commit is contained in:
Carles Cufi 2019-03-19 16:51:06 +01:00 committed by Carles Cufí
commit bae9f1967b
4 changed files with 37 additions and 8 deletions

View file

@ -337,6 +337,9 @@ struct bt_hci_cmd_hdr {
/* Construct OpCode from OGF and OCF */
#define BT_OP(ogf, ocf) ((ocf) | ((ogf) << 10))
/* Invalid opcode */
#define BT_OP_NOP 0x0000
/* Obtain OGF from OpCode */
#define BT_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6))
/* Obtain OCF from OpCode */

View file

@ -357,6 +357,33 @@ void main(void)
/* Enable the raw interface, this will in turn open the HCI driver */
bt_enable_raw(&rx_queue);
if (IS_ENABLED(CONFIG_BT_WAIT_NOP)) {
/* Issue a Command Complete with NOP */
int i;
const struct {
const u8_t h4;
const struct bt_hci_evt_hdr hdr;
const struct bt_hci_evt_cmd_complete cc;
} __packed cc_evt = {
.h4 = H4_EVT,
.hdr = {
.evt = BT_HCI_EVT_CMD_COMPLETE,
.len = sizeof(struct bt_hci_evt_cmd_complete),
},
.cc = {
.ncmd = 1,
.opcode = sys_cpu_to_le16(BT_OP_NOP),
},
};
for (i = 0; i < sizeof(cc_evt); i++) {
uart_poll_out(hci_uart_dev,
*(((const u8_t *)&cc_evt)+i));
}
}
/* Spawn the TX thread and start feeding commands and data to the
* controller
*/

View file

@ -46,6 +46,13 @@ config BT_HCI_MESH_EXT
help
Enable support for the Bluetooth Mesh HCI Commands.
config BT_WAIT_NOP
bool "Wait for \"NOP\" Command Complete event during init"
help
Emit a Command Complete event from the Controller (and wait for it
from the Host) for the NOP opcode to indicate that the Controller is
ready to receive commands.
config BT_RPA
# Virtual/hidden option
bool

View file

@ -70,14 +70,6 @@ config BT_HCI_TX_PRIO
int
default 7
config BT_WAIT_NOP
bool "Wait for \"NOP\" Command Complete event during init"
help
Some controllers emit a Command Complete event for the NOP
opcode to indicate that they're ready to receive commands.
This option should be selected if the controller used
exhibits such behavior.
config BT_HCI_RESERVE
int
default 0 if BT_H4