mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-11 00:44:27 +00:00
Merge branch 'master' of https://github.com/bluekitchen/btstack
This commit is contained in:
commit
a4965b3654
47
src/hci.c
47
src/hci.c
@ -1015,39 +1015,38 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
|
|||||||
|
|
||||||
if (!command_completed) return;
|
if (!command_completed) return;
|
||||||
|
|
||||||
|
int need_baud_change = hci_stack->config && ((hci_uart_config_t *)hci_stack->config)->baudrate_main == 0;
|
||||||
|
int need_addr_change = hci_stack->custom_bd_addr_set && hci_stack->control && hci_stack->control->set_bd_addr_cmd;
|
||||||
|
|
||||||
switch(hci_stack->substate){
|
switch(hci_stack->substate){
|
||||||
case HCI_INIT_W4_SEND_RESET:
|
case HCI_INIT_W4_SEND_RESET:
|
||||||
run_loop_remove_timer(&hci_stack->timeout);
|
run_loop_remove_timer(&hci_stack->timeout);
|
||||||
if (hci_stack->config == NULL || ((hci_uart_config_t *)hci_stack->config)->baudrate_main == 0){
|
if (need_baud_change){
|
||||||
if (hci_stack->custom_bd_addr_set && hci_stack->control && hci_stack->control->set_bd_addr_cmd){
|
hci_stack->substate = HCI_INIT_SEND_BAUD_CHANGE;
|
||||||
// skip baud change
|
return;
|
||||||
hci_stack->substate = HCI_INIT_SET_BD_ADDR;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
// skip baud change and set bd addr
|
|
||||||
hci_stack->substate = HCI_INIT_CUSTOM_INIT;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
hci_stack->substate = HCI_INIT_READ_BUFFER_SIZE;
|
// skipping baud change
|
||||||
|
if (need_addr_change){
|
||||||
|
hci_stack->substate = HCI_INIT_SET_BD_ADDR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// also skip set bd addr
|
||||||
|
hci_stack->substate = HCI_INIT_CUSTOM_INIT;
|
||||||
|
return;
|
||||||
|
case HCI_INIT_W4_SEND_BAUD_CHANGE:
|
||||||
|
log_info("Local baud rate change");
|
||||||
|
hci_stack->hci_transport->set_baudrate(((hci_uart_config_t *)hci_stack->config)->baudrate_main);
|
||||||
|
if (need_addr_change){
|
||||||
|
hci_stack->substate = HCI_INIT_SET_BD_ADDR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// skipping addr change
|
||||||
|
hci_stack->substate = HCI_INIT_CUSTOM_INIT;
|
||||||
return;
|
return;
|
||||||
case HCI_INIT_W4_CUSTOM_INIT_CSR_WARM_BOOT:
|
case HCI_INIT_W4_CUSTOM_INIT_CSR_WARM_BOOT:
|
||||||
run_loop_remove_timer(&hci_stack->timeout);
|
run_loop_remove_timer(&hci_stack->timeout);
|
||||||
hci_stack->substate = HCI_INIT_CUSTOM_INIT;
|
hci_stack->substate = HCI_INIT_CUSTOM_INIT;
|
||||||
return;
|
return;
|
||||||
case HCI_INIT_LOCAL_BAUD_CHANGE:
|
|
||||||
log_info("Local baud rate change");
|
|
||||||
hci_stack->hci_transport->set_baudrate(((hci_uart_config_t *)hci_stack->config)->baudrate_main);
|
|
||||||
if (hci_stack->custom_bd_addr_set && hci_stack->control && hci_stack->control->set_bd_addr_cmd){
|
|
||||||
// skip baud change
|
|
||||||
hci_stack->substate = HCI_INIT_SET_BD_ADDR;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
// skip baud change and set bd addr
|
|
||||||
hci_stack->substate = HCI_INIT_CUSTOM_INIT;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case HCI_INIT_W4_CUSTOM_INIT:
|
case HCI_INIT_W4_CUSTOM_INIT:
|
||||||
// repeat custom init
|
// repeat custom init
|
||||||
hci_stack->substate = HCI_INIT_CUSTOM_INIT;
|
hci_stack->substate = HCI_INIT_CUSTOM_INIT;
|
||||||
|
@ -532,8 +532,6 @@ typedef enum hci_init_state{
|
|||||||
HCI_INIT_W4_SEND_RESET,
|
HCI_INIT_W4_SEND_RESET,
|
||||||
HCI_INIT_SEND_BAUD_CHANGE,
|
HCI_INIT_SEND_BAUD_CHANGE,
|
||||||
HCI_INIT_W4_SEND_BAUD_CHANGE,
|
HCI_INIT_W4_SEND_BAUD_CHANGE,
|
||||||
HCI_INIT_LOCAL_BAUD_CHANGE,
|
|
||||||
HCI_INIT_W4_LOCAL_BAUD_CHANGE,
|
|
||||||
HCI_INIT_SET_BD_ADDR,
|
HCI_INIT_SET_BD_ADDR,
|
||||||
HCI_INIT_W4_SET_BD_ADDR,
|
HCI_INIT_W4_SET_BD_ADDR,
|
||||||
HCI_INIT_CUSTOM_INIT,
|
HCI_INIT_CUSTOM_INIT,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user