From 7fd3bc84c142e57395d12c8f4273b1ac193d940d Mon Sep 17 00:00:00 2001 From: alwaysonketo <43084048+cuizelin99@users.noreply.github.com> Date: Mon, 19 Jun 2023 09:59:05 -0700 Subject: [PATCH] Cancel incomplete BLE connection when CloseAllBleConnections() is called (#27304) When CloseAllBleConnections() is called, any ongoing attempt to establish new BLE connection should be cancelled because it is no longer needed for a new BLE connection to establish. CancelConnection() of the connection delegate should be called to cancel any ongoing new BLE connection so that platform- specific BLEManager can do cleanup. This is needed because we are encountering a problem that BLEManager not doing clean up when establishing PASE session times out, causing problem in the BT layer. Since BLEManager is platform-specific, it doesn't have knowledge of when PASE times out. But BLEManager needs to do clean up whenever CloseAllBleConnections() is called. --- src/ble/BleLayer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ble/BleLayer.cpp b/src/ble/BleLayer.cpp index 9109924ccd3754..57a8ca8dc0fdff 100644 --- a/src/ble/BleLayer.cpp +++ b/src/ble/BleLayer.cpp @@ -308,6 +308,13 @@ void BleLayer::Shutdown() void BleLayer::CloseAllBleConnections() { + // Cancel any ongoing attempt to establish new BLE connection + CHIP_ERROR err = CancelBleIncompleteConnection(); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Ble, "CancelBleIncompleteConnection() failed, err = %" CHIP_ERROR_FORMAT, err.Format()); + } + // Close and free all BLE end points. for (size_t i = 0; i < BLE_LAYER_NUM_BLE_ENDPOINTS; i++) {