diff --git a/chipset/bcm/btstack_chipset_bcm.c b/chipset/bcm/btstack_chipset_bcm.c index 90038b670..887269574 100644 --- a/chipset/bcm/btstack_chipset_bcm.c +++ b/chipset/bcm/btstack_chipset_bcm.c @@ -291,7 +291,7 @@ static btstack_chipset_result_t chipset_next_command(uint8_t * hci_cmd_buffer){ #endif -static const btstack_chipset_t btstack_chipset_bcm = { +static btstack_chipset_t btstack_chipset_bcm = { "BCM", chipset_init, chipset_next_command, @@ -303,3 +303,15 @@ static const btstack_chipset_t btstack_chipset_bcm = { const btstack_chipset_t * btstack_chipset_bcm_instance(void){ return &btstack_chipset_bcm; } + +/** + * @brief Enable init file - needed by btstack_chipset_bcm_download_firmware when using h5 + * @param enabled + */ +void btstack_chipset_bcm_enable_init_script(int enabled){ + if (enabled){ + btstack_chipset_bcm.next_command = &chipset_next_command; + } else { + btstack_chipset_bcm.next_command = NULL; + } +} \ No newline at end of file diff --git a/chipset/bcm/btstack_chipset_bcm.h b/chipset/bcm/btstack_chipset_bcm.h index 2a658c17f..7929985f8 100644 --- a/chipset/bcm/btstack_chipset_bcm.h +++ b/chipset/bcm/btstack_chipset_bcm.h @@ -73,6 +73,12 @@ void btstack_chipset_bcm_set_hcd_folder_path(const char * path); */ void btstack_chipset_bcm_set_device_name(const char * path); +/** + * @brief Enable init file - needed by btstack_chipset_bcm_download_firmware when using h5 + * @param enabled + */ +void btstack_chipset_bcm_enable_init_script(int enabled); + #if defined __cplusplus } #endif diff --git a/chipset/bcm/btstack_chipset_bcm_download_firmware.c b/chipset/bcm/btstack_chipset_bcm_download_firmware.c index 6eb7761ac..a208dba88 100644 --- a/chipset/bcm/btstack_chipset_bcm_download_firmware.c +++ b/chipset/bcm/btstack_chipset_bcm_download_firmware.c @@ -116,7 +116,11 @@ static void bcm_send_next_init_script_command(void){ break; case BTSTACK_CHIPSET_DONE: log_info("bcm: init script done"); + // disable init script for main startup + btstack_chipset_bcm_enable_init_script(0); + // reset baudreate to default uart_driver->set_baudrate(115200); + // notify main download_complete(0); break; default: diff --git a/port/posix-h5-bcm/main.c b/port/posix-h5-bcm/main.c index 3a87ba7bf..d80998ed9 100644 --- a/port/posix-h5-bcm/main.c +++ b/port/posix-h5-bcm/main.c @@ -151,6 +151,18 @@ int main(int argc, const char * argv[]){ uart_config.device_name = transport_config.device_name; uart_driver->init(&uart_config); + // setup HCI (to be able to use bcm chipset driver) + // init HCI + const hci_transport_t * transport = hci_transport_h5_instance(uart_driver); + const btstack_link_key_db_t * link_key_db = btstack_link_key_db_fs_instance(); + hci_init(transport, (void*) &transport_config); + hci_set_link_key_db(link_key_db); + hci_set_chipset(btstack_chipset_bcm_instance()); + + // inform about BTstack state + hci_event_callback_registration.callback = &packet_handler; + hci_add_event_handler(&hci_event_callback_registration); + // handle CTRL-c signal(SIGINT, sigint_handler); @@ -177,16 +189,6 @@ static void phase2(int status){ printf("Phase 2: Main app\n"); - // init HCI - const hci_transport_t * transport = hci_transport_h5_instance(uart_driver); - const btstack_link_key_db_t * link_key_db = btstack_link_key_db_fs_instance(); - hci_init(transport, (void*) &transport_config); - hci_set_link_key_db(link_key_db); - - // inform about BTstack state - hci_event_callback_registration.callback = &packet_handler; - hci_add_event_handler(&hci_event_callback_registration); - // setup app btstack_main(main_argc, main_argv); }