From 2303749342bd49ef5fc593a3fc9850a7fdb805ae Mon Sep 17 00:00:00 2001 From: tianfeng-yang <130436698+tianfeng-yang@users.noreply.github.com> Date: Mon, 10 Jul 2023 15:19:10 +0800 Subject: [PATCH] [Linux] Implement BLE cancel connection (#27649) --- src/platform/Linux/BLEManagerImpl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index a25d0eea768d18..07ea5d6170d8c4 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -729,7 +729,12 @@ void BLEManagerImpl::NewConnection(BleLayer * bleLayer, void * appState, const S CHIP_ERROR BLEManagerImpl::CancelConnection() { - return CHIP_ERROR_NOT_IMPLEMENTED; + if (mBLEScanConfig.mBleScanState == BleScanState::kConnecting) + CancelConnect(mpEndpoint); + // If in discovery mode, stop scan. + else if (mBLEScanConfig.mBleScanState != BleScanState::kNotScanning) + mDeviceScanner->StopScan(); + return CHIP_NO_ERROR; } void BLEManagerImpl::NotifyBLEPeripheralRegisterAppComplete(bool aIsSuccess, void * apAppstate)