diff --git a/src/hci.c b/src/hci.c index ce640bb75..ce809874a 100644 --- a/src/hci.c +++ b/src/hci.c @@ -1044,6 +1044,7 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){ log_info("Command complete for opcode %04x, expected %04x", opcode, hci_stack->last_cmd_opcode); } } + if (packet[0] == HCI_EVENT_COMMAND_STATUS){ uint8_t status = packet[2]; uint16_t opcode = READ_BT_16(packet,4); @@ -1058,12 +1059,38 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){ log_info("Command status for opcode %04x, expected %04x", opcode, hci_stack->last_cmd_opcode); } } + // Vendor == CSR if (hci_stack->substate == HCI_INIT_W4_CUSTOM_INIT && packet[0] == HCI_EVENT_VENDOR_SPECIFIC){ // TODO: track actual command command_completed = 1; } + // Late response (> 100 ms) for HCI Reset e.g. on Toshiba TC35661: + // Command complete for HCI Reset arrives after we've resent the HCI Reset command + // + // HCI Reset + // Timeout 100 ms + // HCI Reset + // Command Complete Reset + // HCI Read Local Version Information + // Command Complete Reset - but we expected Command Complete Read Local Version Information + // hang... + // + // Fix: Command Complete for HCI Reset in HCI_INIT_W4_SEND_READ_LOCAL_VERSION_INFORMATION trigger resend + if (!command_completed + && packet[0] == HCI_EVENT_COMMAND_COMPLETE + && hci_stack->substate == HCI_INIT_W4_SEND_READ_LOCAL_VERSION_INFORMATION){ + + uint16_t opcode = READ_BT_16(packet,3); + if (opcode == hci_reset.opcode){ + hci_stack->substate = HCI_INIT_SEND_READ_LOCAL_VERSION_INFORMATION; + return; + } + } + + + if (!command_completed) return; int need_baud_change = hci_stack->config