Skip to content

Commit

Permalink
nimble/host: Fix checking for NOP in ble_hs_hci_rx_evt
Browse files Browse the repository at this point in the history
NOP can be sent as Command Complete or Command Status. Those events
don't have opcode field in same place so old code was not checking
proper bytes. It looks like this never worked for Command Status case.
  • Loading branch information
sjanc committed Jan 24, 2020
1 parent 77d0b3d commit e97cab2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions nimble/host/src/ble_hs_hci.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,28 +356,29 @@ ble_hs_hci_rx_ack(uint8_t *ack_ev)
int
ble_hs_hci_rx_evt(uint8_t *hci_ev, void *arg)
{
struct ble_hci_ev *ev = (void *) hci_ev;
struct ble_hci_ev_command_complete *cmd_complete = (void *) ev->data;
struct ble_hci_ev_command_status *cmd_status = (void *) ev->data;
int enqueue;

BLE_HS_DBG_ASSERT(hci_ev != NULL);

switch (hci_ev[0]) {
switch (ev->opcode) {
case BLE_HCI_EVCODE_COMMAND_COMPLETE:
enqueue = (cmd_complete->opcode == BLE_HCI_OPCODE_NOP);
break;
case BLE_HCI_EVCODE_COMMAND_STATUS:
if (hci_ev[3] == 0 && hci_ev[4] == 0) {
enqueue = 1;
} else {
ble_hs_hci_rx_ack(hci_ev);
enqueue = 0;
}
enqueue = (cmd_status->opcode == BLE_HCI_OPCODE_NOP);
break;

default:
enqueue = 1;
break;
}

if (enqueue) {
ble_hs_enqueue_hci_event(hci_ev);
} else {
ble_hs_hci_rx_ack(hci_ev);
}

return 0;
Expand Down

0 comments on commit e97cab2

Please sign in to comment.