Skip to content

Commit 004b677

Browse files
authored
Merge pull request adafruit#9453 from dhalbert/9.1.x-fix-nordic-restart-crash
bleio_user_reset(): check if BLE running before doing any BLE ops
2 parents 41a85fd + 98610f9 commit 004b677

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ports/nordic/common-hal/_bleio/__init__.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ void common_hal_bleio_init(void) {
7878
}
7979

8080
void bleio_user_reset() {
81-
// Stop any user scanning or advertising.
82-
common_hal_bleio_adapter_stop_scan(&common_hal_bleio_adapter_obj);
83-
common_hal_bleio_adapter_stop_advertising(&common_hal_bleio_adapter_obj);
81+
if (common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) {
82+
// Stop any user scanning or advertising.
83+
common_hal_bleio_adapter_stop_scan(&common_hal_bleio_adapter_obj);
84+
common_hal_bleio_adapter_stop_advertising(&common_hal_bleio_adapter_obj);
85+
}
8486

8587
ble_drv_remove_heap_handlers();
8688

0 commit comments

Comments
 (0)