diff --git a/pico_w/bt/standalone/client.c b/pico_w/bt/standalone/client.c index 08c182b..ca515ae 100644 --- a/pico_w/bt/standalone/client.c +++ b/pico_w/bt/standalone/client.c @@ -272,6 +272,20 @@ int main() { // turn on! hci_power_control(HCI_POWER_ON); + // btstack_run_loop_execute is only required when using the 'polling' method (e.g. using pico_cyw43_arch_poll library). + // This example uses the 'threadsafe background` method, where BT work is handled in a low priority IRQ, so it + // is fine to call bt_stack_run_loop_execute() but equally you can continue executing user code. + +#if 1 // this is only necessary when using polling (which we aren't, but we're showing it is still safe to call in this case) btstack_run_loop_execute(); +#else + // this core is free to do it's own stuff except when using 'polling' method (in which case you should use + // btstacK_run_loop_ methods to add work to the run loop. + + // this is a forever loop in place of where user code would go. + while(true) { + sleep_ms(1000); + } +#endif return 0; } diff --git a/pico_w/bt/standalone/server.c b/pico_w/bt/standalone/server.c index 0ac0e6b..7fa9db7 100644 --- a/pico_w/bt/standalone/server.c +++ b/pico_w/bt/standalone/server.c @@ -73,7 +73,21 @@ int main() { // turn on bluetooth! hci_power_control(HCI_POWER_ON); + + // btstack_run_loop_execute is only required when using the 'polling' method (e.g. using pico_cyw43_arch_poll library). + // This example uses the 'threadsafe background` method, where BT work is handled in a low priority IRQ, so it + // is fine to call bt_stack_run_loop_execute() but equally you can continue executing user code. +#if 0 // btstack_run_loop_execute() is not required, so lets not use it btstack_run_loop_execute(); +#else + // this core is free to do it's own stuff except when using 'polling' method (in which case you should use + // btstacK_run_loop_ methods to add work to the run loop. + + // this is a forever loop in place of where user code would go. + while(true) { + sleep_ms(1000); + } +#endif return 0; } diff --git a/pico_w/bt/standalone/server_with_wifi.c b/pico_w/bt/standalone/server_with_wifi.c index 0272a01..af17e6f 100644 --- a/pico_w/bt/standalone/server_with_wifi.c +++ b/pico_w/bt/standalone/server_with_wifi.c @@ -85,7 +85,7 @@ int main() { // register for ATT event att_server_register_packet_handler(packet_handler); - // set one-shot btstack timer + // use an async worker for for the led async_context_add_at_time_worker_in_ms(cyw43_arch_async_context(), &heartbeat_worker, HEARTBEAT_PERIOD_MS); // Connect to Wi-Fi