Merge pull request #2654 from tannewt/fix_crash_after_repl

Fix crash after empty REPL session
This commit is contained in:
Dan Halbert 2020-02-24 21:50:08 -05:00 committed by GitHub
commit 09ab24b967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -723,7 +723,10 @@ void bleio_adapter_gc_collect(bleio_adapter_obj_t* adapter) {
void bleio_adapter_reset(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_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; adapter->connection_objs = NULL;
for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) {
bleio_connection_internal_t *connection = &bleio_connections[i]; bleio_connection_internal_t *connection = &bleio_connections[i];

View File

@ -89,14 +89,15 @@ void check_sec_status(uint8_t sec_status) {
// Turn off BLE on a reset or reload. // Turn off BLE on a reset or reload.
void bleio_reset() { void bleio_reset() {
if (!common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) {
return;
}
bleio_adapter_reset(&common_hal_bleio_adapter_obj); bleio_adapter_reset(&common_hal_bleio_adapter_obj);
if (!vm_used_ble) { if (!vm_used_ble) {
// No user-code BLE operations were done, so we can maintain the supervisor state. // No user-code BLE operations were done, so we can maintain the supervisor state.
return; 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(); bonding_reset();
supervisor_start_bluetooth(); supervisor_start_bluetooth();
} }