From e1271e1dc9e9ba865a6e5aed46379cd803154588 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 12 May 2022 01:03:28 +0200 Subject: Fix unexpected event on disconnect during l2cap setup. Fixes #110 --- nrf-softdevice/src/ble/l2cap.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nrf-softdevice/src/ble/l2cap.rs b/nrf-softdevice/src/ble/l2cap.rs index 33a2baa..ab366e1 100644 --- a/nrf-softdevice/src/ble/l2cap.rs +++ b/nrf-softdevice/src/ble/l2cap.rs @@ -167,6 +167,12 @@ impl L2cap

{ raw::BLE_GAP_EVTS_BLE_GAP_EVT_DISCONNECTED => { return Err(SetupError::Disconnected) } + raw::BLE_L2CAP_EVTS_BLE_L2CAP_EVT_CH_RELEASED => { + // It is possible to get L2CAP_EVT_CH_RELEASED for the + // "half-setup" channel if the conn gets disconnected while + // setting it up. + return Err(SetupError::Disconnected); + } raw::BLE_L2CAP_EVTS_BLE_L2CAP_EVT_CH_SETUP => { let l2cap_evt = get_union_field(ble_evt, &(*ble_evt).evt.l2cap_evt); let _evt = &l2cap_evt.params.ch_setup; -- cgit v1.2.3