Closed kevinjwalters closed 5 months ago
Correct, in general, we recommend to setup the run loop only once and keep it running, but tell the stack to power down if Bluetooth isn't needed for longer periods of time. This can be done by calling hci_power_control(HCI_STATE_OFF). When the stack is done with shutdown, an BTSTACK_EVENT_STATE with HCI_STATE_OFF is received via the hci packet handler. Also, BTstack will call the off function of the btstack_control_t struct passed in via hci_set_control. I don't know if this mechanism is used by the pico-sdk
For testing, I usually add hci_power_control(HCI_STATE_OFF) and hci_power_control(HCI_STATE_ON) to the console command handler in one of the examples.
That's for BTstack. The next question is how this can be done with the CYW43 driver which is shared by Bluetooth & Wifi. Maybe you can verify that the BTstack part works as expected and if there's a problem with CYW43 power down/up, please post on the pico-sdk repo.
I'll take a look at doing this in a pico-example
@peterharperuk great, thanks! Maybe you can also have a look at the forum post - my guess would be that there's no technical reason not to use CYW43/BTstack at the same time as DMA with ADC.
@peterharperuk Does it work? Happy New Year!
Closing due to lack of activity
Is your feature request related to a problem? Please describe. I would like to be able to shutdown Bluetooth and then start it up later.
My reason for doing this is due to the Pi Pico W's odd incompatibility between DMA ADC and using Bluetooth.
It looks like others (like @josh26turner) may wish to shutdown Bluetooth for low power reasons https://github.com/raspberrypi/pico-sdk/issues/1479
Describe the solution you'd like There's already a
btstack_run_loop_trigger_exit()
but I don't think this was intended to allow the Bluetooth stack to be shutdown/suspended and then restarted.I'd like a some example code which uses Bluetooth then stops using Bluetooth triggered by the closing of a connection from another device and then after doing something unrelated starts up the Bluetooth stack again. I'd like that to work on the Pi Pico W. Happy to test there.
Describe alternatives you've considered None.
Additional context None.