Skip to content

Commit

Permalink
Comments about btstack_run_loop_execute (#388)
Browse files Browse the repository at this point in the history
Co-authored-by: Graham Sanderson <[email protected]>
  • Loading branch information
peterharperuk and kilograham committed Jun 6, 2023
1 parent 9736fcd commit 5f28220
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
14 changes: 14 additions & 0 deletions pico_w/bt/standalone/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
14 changes: 14 additions & 0 deletions pico_w/bt/standalone/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion pico_w/bt/standalone/server_with_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5f28220

Please sign in to comment.