Skip to content

Commit

Permalink
Cancel incomplete BLE connection when CloseAllBleConnections() is cal…
Browse files Browse the repository at this point in the history
…led (#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.
  • Loading branch information
cuizelin99 authored and pull[bot] committed Jan 23, 2024
1 parent 49dcc18 commit 7fd3bc8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ble/BleLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand Down

0 comments on commit 7fd3bc8

Please sign in to comment.