Skip to content

Commit

Permalink
Cancel incomplete BLE connection when CloseAllBleConnections() is called
Browse files Browse the repository at this point in the history
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 committed Jun 16, 2023
1 parent aa13fa3 commit 7304b22
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 7304b22

Please sign in to comment.