Send hci reset after setting bd addr on stlc2500d

This commit is contained in:
Matthias Ringwald 2015-05-08 22:19:45 +02:00
parent 2f48d9200b
commit 8d29070e3b
2 changed files with 33 additions and 10 deletions

View File

@ -854,7 +854,7 @@ static void hci_initializing_run(){
case HCI_INIT_SEND_READ_LOCAL_VERSION_INFORMATION:
hci_send_cmd(&hci_read_local_version_information);
hci_stack->substate = HCI_INIT_W4_SEND_READ_LOCAL_VERSION_INFORMATION;
break;
break;
case HCI_INIT_SEND_RESET_CSR_WARM_BOOT:
hci_state_reset();
// prepare reset if command complete not received in 100ms
@ -865,6 +865,18 @@ static void hci_initializing_run(){
hci_stack->substate = HCI_INIT_W4_CUSTOM_INIT_CSR_WARM_BOOT;
hci_send_cmd(&hci_reset);
break;
case HCI_INIT_SEND_RESET_ST_WARM_BOOT:
hci_state_reset();
hci_stack->substate = HCI_INIT_W4_SEND_RESET_ST_WARM_BOOT;
hci_send_cmd(&hci_reset);
break;
case HCI_INIT_SET_BD_ADDR:
log_info("Set Public BD ADDR to %s", bd_addr_to_str(hci_stack->custom_bd_addr));
hci_stack->control->set_bd_addr_cmd(hci_stack->config, hci_stack->custom_bd_addr, hci_stack->hci_packet_buffer);
hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
hci_stack->substate = HCI_INIT_W4_SET_BD_ADDR;
hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
break;
case HCI_INIT_SEND_BAUD_CHANGE:
hci_stack->control->baudrate_cmd(hci_stack->config, ((hci_uart_config_t *)hci_stack->config)->baudrate_main, hci_stack->hci_packet_buffer);
hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
@ -877,13 +889,6 @@ static void hci_initializing_run(){
run_loop_add_timer(&hci_stack->timeout);
}
break;
case HCI_INIT_SET_BD_ADDR:
log_info("Set Public BD ADDR to %s", bd_addr_to_str(hci_stack->custom_bd_addr));
hci_stack->control->set_bd_addr_cmd(hci_stack->config, hci_stack->custom_bd_addr, hci_stack->hci_packet_buffer);
hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
hci_stack->substate = HCI_INIT_W4_SET_BD_ADDR;
hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
break;
case HCI_INIT_CUSTOM_INIT:
log_info("Custom init");
// Custom initialization
@ -1057,6 +1062,20 @@ static void hci_initializing_event_handler(uint8_t * packet, uint16_t size){
hci_stack->substate = HCI_INIT_CUSTOM_INIT;
return;
case HCI_INIT_W4_SET_BD_ADDR:
// for STLC2500D, bd addr change only gets active after sending reset command
if (hci_stack->manufacturer == 0x0030){
hci_stack->substate = HCI_INIT_SEND_RESET_ST_WARM_BOOT;
return;
}
// skipping warm boot on STLC2500D
if (need_baud_change){
hci_stack->substate = HCI_INIT_SEND_BAUD_CHANGE;
return;
}
// skipping baud change
hci_stack->substate = HCI_INIT_CUSTOM_INIT;
return;
case HCI_INIT_W4_SEND_RESET_ST_WARM_BOOT:
if (need_baud_change){
hci_stack->substate = HCI_INIT_SEND_BAUD_CHANGE;
return;

View File

@ -534,10 +534,14 @@ typedef enum hci_init_state{
HCI_INIT_SEND_READ_LOCAL_VERSION_INFORMATION,
HCI_INIT_W4_SEND_READ_LOCAL_VERSION_INFORMATION,
HCI_INIT_SEND_BAUD_CHANGE,
HCI_INIT_W4_SEND_BAUD_CHANGE,
HCI_INIT_SET_BD_ADDR,
HCI_INIT_W4_SET_BD_ADDR,
HCI_INIT_SEND_RESET_ST_WARM_BOOT,
HCI_INIT_W4_SEND_RESET_ST_WARM_BOOT,
HCI_INIT_SEND_BAUD_CHANGE,
HCI_INIT_W4_SEND_BAUD_CHANGE,
HCI_INIT_CUSTOM_INIT,
HCI_INIT_W4_CUSTOM_INIT,
HCI_INIT_SEND_RESET_CSR_WARM_BOOT,