From c4fb3dd160cb2a9cc86bd8312bfda1f9b1af4f63 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Sun, 11 Feb 2024 11:35:18 +0100 Subject: [PATCH] pbio/sys/program_stop: Drop hack to stop Bluetooth. We have an old hack that shuts down the bluetooth process. When starting a new task after that in a cleanup routine such as added in 04fd2e770d97ab4771e77072bab0d9d61bcdeb45, the hub will never finish the task, which prevents the user program from stopping. We have several proper fixes in place now, and we are about to merge some updates that will make all Bluetooth task objects static, so we should remove this hack. Fixes https://github.com/pybricks/support/issues/1438 --- CHANGELOG.md | 4 ++++ lib/pbio/sys/program_stop.c | 6 ------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0948e47b7..3e689572d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ - Added `pybricks.iodevices.XboxController` ([support#191], [support#1024]). - Re-enable `pybricks.iodevices.LWP3Device` missing from last beta. +### Fixes +- Fix hub not shutting down while a program runs ([support#1438]). + ### Changed - On Technic Hub and City Hub, the Bluetooth chip is now configured to reject connection parameter updates from peripherals. This avoids interference with @@ -15,6 +18,7 @@ [support#191]: https://github.com/pybricks/support/issues/191 [support#1024]: https://github.com/pybricks/support/issues/1024 +[support#1438]: https://github.com/pybricks/support/issues/1438 ## [3.4.0b1] - 2023-11-24 diff --git a/lib/pbio/sys/program_stop.c b/lib/pbio/sys/program_stop.c index a883e5711..e9cd95e84 100644 --- a/lib/pbio/sys/program_stop.c +++ b/lib/pbio/sys/program_stop.c @@ -32,12 +32,6 @@ static bool stop_button_pressed; */ void pbsys_program_stop(bool force_stop) { if (pbsys_status_test(PBIO_PYBRICKS_STATUS_USER_PROGRAM_RUNNING)) { - if (force_stop) { - // HACK: Bluetooth drivers have issues with pending tasks not being - // cancellable, so this should force them to be canceled and avoid - // undefined behavior due to use after free. - pbdrv_bluetooth_power_on(false); - } pbsys_main_stop_program(force_stop); } }