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:
parent
9fff548c88
commit
bae9f1967b
4 changed files with 37 additions and 8 deletions
|
@ -337,6 +337,9 @@ struct bt_hci_cmd_hdr {
|
||||||
/* Construct OpCode from OGF and OCF */
|
/* Construct OpCode from OGF and OCF */
|
||||||
#define BT_OP(ogf, ocf) ((ocf) | ((ogf) << 10))
|
#define BT_OP(ogf, ocf) ((ocf) | ((ogf) << 10))
|
||||||
|
|
||||||
|
/* Invalid opcode */
|
||||||
|
#define BT_OP_NOP 0x0000
|
||||||
|
|
||||||
/* Obtain OGF from OpCode */
|
/* Obtain OGF from OpCode */
|
||||||
#define BT_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6))
|
#define BT_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6))
|
||||||
/* Obtain OCF from OpCode */
|
/* Obtain OCF from OpCode */
|
||||||
|
|
|
@ -357,6 +357,33 @@ void main(void)
|
||||||
|
|
||||||
/* Enable the raw interface, this will in turn open the HCI driver */
|
/* Enable the raw interface, this will in turn open the HCI driver */
|
||||||
bt_enable_raw(&rx_queue);
|
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
|
/* Spawn the TX thread and start feeding commands and data to the
|
||||||
* controller
|
* controller
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -46,6 +46,13 @@ config BT_HCI_MESH_EXT
|
||||||
help
|
help
|
||||||
Enable support for the Bluetooth Mesh HCI Commands.
|
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
|
config BT_RPA
|
||||||
# Virtual/hidden option
|
# Virtual/hidden option
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -70,14 +70,6 @@ config BT_HCI_TX_PRIO
|
||||||
int
|
int
|
||||||
default 7
|
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
|
config BT_HCI_RESERVE
|
||||||
int
|
int
|
||||||
default 0 if BT_H4
|
default 0 if BT_H4
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue