Skip to content

Commit

Permalink
Merge pull request #6513 from dhalbert/7.3.x-6495-backport-ble-discon…
Browse files Browse the repository at this point in the history
…nect-check

Test for a BLE disconnect while reading
  • Loading branch information
tannewt authored Jun 22, 2022
2 parents d8badb5 + e8023f3 commit 25206a8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ports/nrf/common-hal/_bleio/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,12 @@ STATIC bool _on_gattc_read_rsp_evt(ble_evt_t *ble_evt, void *param) {
}
break;
}

case BLE_GAP_EVT_DISCONNECTED: {
read->conn_handle = BLE_CONN_HANDLE_INVALID;
read->done = true;
return false;
break;
}
default:
// For debugging.
// mp_printf(&mp_plat_print, "Unhandled characteristic event: 0x%04x\n", ble_evt->header.evt_id);
Expand Down Expand Up @@ -219,6 +224,8 @@ size_t common_hal_bleio_gattc_read(uint16_t handle, uint16_t conn_handle, uint8_
while (!read_info.done) {
RUN_BACKGROUND_TASKS;
}
// Test if we were disconnected while reading
common_hal_bleio_check_connected(read_info.conn_handle);

ble_drv_remove_event_handler(_on_gattc_read_rsp_evt, &read_info);
check_gatt_status(read_info.status);
Expand Down

0 comments on commit 25206a8

Please sign in to comment.