From ae334e9e63e6793a0462a7d63cd34234429de426 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 14 May 2019 14:35:58 +0200 Subject: [PATCH] hci: skip sending second baud rate change if there's no init script and no warm start --- src/hci.c | 8 ++++---- src/hci.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/hci.c b/src/hci.c index ac0829998..ac9904af8 100644 --- a/src/hci.c +++ b/src/hci.c @@ -1271,9 +1271,9 @@ static void hci_initializing_run(void){ case HCI_INIT_CUSTOM_INIT: // Custom initialization if (hci_stack->chipset && hci_stack->chipset->next_command){ - btstack_chipset_result_t result = (*hci_stack->chipset->next_command)(hci_stack->hci_packet_buffer); + hci_stack->chipset_result = (*hci_stack->chipset->next_command)(hci_stack->hci_packet_buffer); int send_cmd = 0; - switch (result){ + switch (hci_stack->chipset_result){ case BTSTACK_CHIPSET_VALID_COMMAND: send_cmd = 1; hci_stack->substate = HCI_INIT_W4_CUSTOM_INIT; @@ -1310,7 +1310,7 @@ static void hci_initializing_run(void){ log_info("Init script done"); // Init script download on Broadcom chipsets causes: - if ( (result != BTSTACK_CHIPSET_NO_INIT_SCRIPT) && + if ( (hci_stack->chipset_result != BTSTACK_CHIPSET_NO_INIT_SCRIPT) && ( hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_BROADCOM_CORPORATION || hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_EM_MICROELECTRONIC_MARIN_SA) ){ @@ -1688,7 +1688,7 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){ #endif case HCI_INIT_W4_READ_LOCAL_SUPPORTED_COMMANDS: - if (need_baud_change && + if (need_baud_change && hci_stack->chipset_result != BTSTACK_CHIPSET_NO_INIT_SCRIPT && ((hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_BROADCOM_CORPORATION) || (hci_stack->manufacturer == BLUETOOTH_COMPANY_ID_EM_MICROELECTRONIC_MARIN_SA))) { hci_stack->substate = HCI_INIT_SEND_BAUD_CHANGE_BCM; diff --git a/src/hci.h b/src/hci.h index b450222f2..5d97f3031 100644 --- a/src/hci.h +++ b/src/hci.h @@ -788,6 +788,7 @@ typedef struct { HCI_STATE state; hci_substate_t substate; btstack_timer_source_t timeout; + btstack_chipset_result_t chipset_result; uint16_t last_cmd_opcode;