Skip to content

Fix crash after empty REPL session #2654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ports/nrf/common-hal/_bleio/Adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,10 @@ void bleio_adapter_gc_collect(bleio_adapter_obj_t* adapter) {

void bleio_adapter_reset(bleio_adapter_obj_t* adapter) {
common_hal_bleio_adapter_stop_scan(adapter);
common_hal_bleio_adapter_stop_advertising(adapter);
if (adapter->current_advertising_data != NULL) {
common_hal_bleio_adapter_stop_advertising(adapter);
}

adapter->connection_objs = NULL;
for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) {
bleio_connection_internal_t *connection = &bleio_connections[i];
Expand Down
7 changes: 4 additions & 3 deletions ports/nrf/common-hal/_bleio/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ void check_sec_status(uint8_t sec_status) {

// Turn off BLE on a reset or reload.
void bleio_reset() {
if (!common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) {
return;
}
bleio_adapter_reset(&common_hal_bleio_adapter_obj);
if (!vm_used_ble) {
// No user-code BLE operations were done, so we can maintain the supervisor state.
return;
}
if (common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) {
common_hal_bleio_adapter_set_enabled(&common_hal_bleio_adapter_obj, false);
}
common_hal_bleio_adapter_set_enabled(&common_hal_bleio_adapter_obj, false);
bonding_reset();
supervisor_start_bluetooth();
}
Expand Down