Hi Matthias,
I am not sure that I fully understand how to integrate powering the WILC up/down with the bt stack. Maybe I need to provide a little more context to help frame the question.
I am running the bt stack with freertos on an STM32L4MCU. I have ported code based on Atmel Studio Framework example projects which used a ATSAM7 microcontroller to allow me to power on the WILC module and have a functional BLE UART connected to the Microchip Bluetooth Data mobile application.
Here is the code which starts my Bluetooth task once the WILC has been powered up
btstack_run_loop_task = xHandle;
// start with BTstack init - especially configure HCI Transport
btstack_memory_init();
btstack_run_loop_init(btstack_run_loop_freertos_get_instance());
// setup UART HAL + Run Loop integration
uart_driver = btstack_uart_block_freertos_instance(); // RTOS
// extract UART config from transport config, but disable flow control and use default baudrate
uart_config.baudrate = HCI_DEFAULT_BAUDRATE;
uart_config.flowcontrol = 0;
uart_config.device_name = transport_config.device_name;
uart_driver->init(&uart_config);
btstack_chipset_atwilc3000_download_firmware(uart_driver, transport_config.baudrate_init, transport_config.flowcontrol, NULL, 0, &bt_app_init);
btstack_run_loop_execute();
The btstack_chipset_atwilc3000_download_firmware function includes the following to complete the firmware download and configure the uart for normal operation
static void atwilc3000_start(void);
static void atwilc3000_w4_command_complete_reset(void);
static void atwilc3000_w4_command_complete_read_local_version_information(void);
static void atwilc3000_wait_for_reset_completed(void);
static void atwilc3000_configure_uart(btstack_timer_source_t * ts);
atwilc3000_done();
Once the download firmware process is complete the bt_app_init function is called which handles initializing the HCI transport layer
static void bt_app_init(int status){
// init HCI
const hci_transport_t *transport = hci_transport_h4_instance(uart_driver);
hci_init(transport, (void*) &transport_config);
hci_set_chipset(btstack_chipset_atwilc3000_instance());
hci_set_link_key_db(btstack_link_key_db_memory_instance());
tss_app_setup();
// turn on!
hci_power_control(HCI_POWER_ON);
}
Once all of this initialization has finished I am able to see the device advertised on the Microchip Bluetooth Data mobile application and open the transparent serial service.
At this point in our application I want to power down the WILC device to save power and therefore “pause” the btstack. I think you are suggesting this would be done by calling the hci_power_control(HCI_POWER_OFF) command? Will this decouple the btstack from the controller? I would then be able to power off the WILC hardware leaving the bt stack running in an IDLE state?
Later in the application I will wont to turn the WILC controller back on and reconnect to the btstack. I will again need to go through the btstack_chipset_atwilc3000_download_firmware process but perhaps I don’t need to do the full HCI initialization process again? But I will need to connect the HCI interface to the controller and power the HCI interface back on. Which HCI initialization functions are needed for this step?
Thanks for your support
At this point in our application I want to power down the WILC device to save power and therefore “pause” the btstack. I think you are suggesting this would be done by calling the hci_power_control(HCI_POWER_OFF)command? Will this decouple the btstack from the controller? I would then be able to power off the WILC hardware leaving the bt stack running in an IDLE state?
Later in the application I will wont to turn the WILC controller back on and reconnect to the btstack. I will again need to go through the btstack_chipset_atwilc3000_download_firmware process but perhaps I don’t need to do the full HCI initialization process again? But I will need to connect the HCI interface to the controller and power the HCI interface back on. Which HCI initialization functions are needed for this step?
Thanks for your support
--On Friday, October 29, 2021 at 10:50:32 AM UTC-3 Matthias Ringwald wrote:Hi Richard
The official way to power off a Bluetooth Controller is to call hci_power_control(HCI_POWER_OFF) - analog to the initial power on in all examples.
You can turn the WILC3000 off either in the HCI Transport or btstack_power_t impelemntation. Power off and later on works in the libusb port.
Cheers
Matthias
> On 28 Oct 2021, at 15:31, Richard Sawler <junk4...@gmail.com> wrote:
>
> Hello,
>
> I am using the BTStack running on an STM32L4 MCU with the ATWILC3000 wifi/BLE controller. I have finished my port and the BLE functionality works great as I am able to add and remove connections and transfer data between devices.
>
> My challenge now is that I want to turn off the WILC3000 device when I am not using the BLE connection. This would require that I pause or stop the BTStack when I power off the device and then reinitialize the device and the stack when the device is powered back on.
>
> I do not see a clean way to handle this use case and am wondering if you have an direction on stopping and restarting the BT Stack.
>
> Thank you
>
> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/a1ceeea2-bd39-4163-8643-b9ab12298f1bn%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "btstack-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/a8c87fa1-7eb9-4488-a83d-c749c99f25cdn%40googlegroups.com.