From 16711807a57ff9dbbebb0f516fb53611f50fd494 Mon Sep 17 00:00:00 2001 From: tianfeng-yang <130436698+tianfeng-yang@users.noreply.github.com> Date: Thu, 11 May 2023 01:48:31 +0800 Subject: [PATCH] Fix the problem of hang after BLE discovery fails during commission (#26442) --- src/controller/CHIPDeviceController.cpp | 7 +++++++ src/platform/Linux/BLEManagerImpl.cpp | 1 + 2 files changed, 8 insertions(+) diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 2ae83b320839db..e483a83b140d06 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -792,6 +792,13 @@ void DeviceCommissioner::OnDiscoveredDeviceOverBleError(void * appState, CHIP_ER { self->ReleaseCommissioneeDevice(device); self->mRendezvousParametersForDeviceDiscoveredOverBle = RendezvousParameters(); + + // Callback is required when BLE discovery fails, otherwise the caller will always be in a suspended state + // A better way to handle it should define a new error code + if (self->mPairingDelegate != nullptr) + { + self->mPairingDelegate->OnPairingComplete(err); + } } } #endif // CONFIG_NETWORK_LAYER_BLE diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index 2cc5c6a69d19c5..a25d0eea768d18 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -825,6 +825,7 @@ void BLEManagerImpl::OnScanComplete() void BLEManagerImpl::OnScanError(CHIP_ERROR err) { + BleConnectionDelegate::OnConnectionError(mBLEScanConfig.mAppState, err); ChipLogError(Ble, "BLE scan error: %" CHIP_ERROR_FORMAT, err.Format()); }