From a637344ca4ce1f8ff4d1dcbab178213be9ce6a45 Mon Sep 17 00:00:00 2001 From: Jakub Latusek Date: Wed, 23 Nov 2022 14:18:05 +0100 Subject: [PATCH 1/9] Remove on connection error from on scan complete Create a separate error handler for scan errors --- src/platform/Linux/BLEManagerImpl.cpp | 19 +++++++++++++++---- src/platform/Linux/BLEManagerImpl.h | 1 + .../Linux/bluez/ChipDeviceScanner.cpp | 4 +++- src/platform/Linux/bluez/ChipDeviceScanner.h | 3 +++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index 2c2a8794c66105..e1c92a7353d5f1 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -804,17 +804,28 @@ void BLEManagerImpl::OnDeviceScanned(BluezDevice1 * device, const chip::Ble::Chi void BLEManagerImpl::OnScanComplete() { - if (mBLEScanConfig.mBleScanState != BleScanState::kScanForDiscriminator && - mBLEScanConfig.mBleScanState != BleScanState::kScanForAddress) + switch (mBLEScanConfig.mBleScanState) { + case BleScanState::kNotScanning: ChipLogProgress(Ble, "Scan complete notification without an active scan."); - return; + break; + case BleScanState::kScanForAddress: + case BleScanState::kScanForDiscriminator: + ChipLogProgress(Ble, "Scan complete. No matching device found."); + break; + case BleScanState::kConnecting: + mBLEScanConfig.mBleScanState = BleScanState::kNotScanning; + break; } - BleConnectionDelegate::OnConnectionError(mBLEScanConfig.mAppState, CHIP_ERROR_TIMEOUT); mBLEScanConfig.mBleScanState = BleScanState::kNotScanning; } +void BLEManagerImpl::OnScanError(CHIP_ERROR err) +{ + ChipLogDetail(Ble, "BLE scan error: %" CHIP_ERROR_FORMAT, err.Format()); +} + } // namespace Internal } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Linux/BLEManagerImpl.h b/src/platform/Linux/BLEManagerImpl.h index 8c0d06b066cbd8..6aab5658742934 100644 --- a/src/platform/Linux/BLEManagerImpl.h +++ b/src/platform/Linux/BLEManagerImpl.h @@ -91,6 +91,7 @@ class BLEManagerImpl final : public BLEManager, public: CHIP_ERROR ConfigureBle(uint32_t aAdapterId, bool aIsCentral); + void OnScanError(ChipError error); // Driven by BlueZ IO static void HandleNewConnection(BLE_CONNECTION_OBJECT conId); diff --git a/src/platform/Linux/bluez/ChipDeviceScanner.cpp b/src/platform/Linux/bluez/ChipDeviceScanner.cpp index 46e17ce5b17089..04c522ba34aa66 100644 --- a/src/platform/Linux/bluez/ChipDeviceScanner.cpp +++ b/src/platform/Linux/bluez/ChipDeviceScanner.cpp @@ -150,7 +150,9 @@ CHIP_ERROR ChipDeviceScanner::StartScan(System::Clock::Timeout timeout) void ChipDeviceScanner::TimerExpiredCallback(chip::System::Layer * layer, void * appState) { - static_cast(appState)->StopScan(); + ChipDeviceScanner * chipDeviceScanner = static_cast(appState); + chipDeviceScanner->mDelegate->OnScanError(CHIP_ERROR_TIMEOUT); + chipDeviceScanner->StopScan(); } CHIP_ERROR ChipDeviceScanner::StopScan() diff --git a/src/platform/Linux/bluez/ChipDeviceScanner.h b/src/platform/Linux/bluez/ChipDeviceScanner.h index bbe84ac07268ba..f81f923dfb3b47 100644 --- a/src/platform/Linux/bluez/ChipDeviceScanner.h +++ b/src/platform/Linux/bluez/ChipDeviceScanner.h @@ -44,6 +44,9 @@ class ChipDeviceScannerDelegate // Called when a scan was completed (stopped or timed out) virtual void OnScanComplete() = 0; + + // Call on scan error + virtual void OnScanError(CHIP_ERROR) = 0; }; /// Allows scanning for CHIP devices From 500c9e530d0300c11d94a212f9429fb82aa0b440 Mon Sep 17 00:00:00 2001 From: Jakub Latusek Date: Wed, 23 Nov 2022 14:21:51 +0100 Subject: [PATCH 2/9] Fix typo --- src/platform/Linux/BLEManagerImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index e1c92a7353d5f1..9722f4b745cc91 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -790,7 +790,7 @@ void BLEManagerImpl::OnDeviceScanned(BluezDevice1 * device, const chip::Ble::Chi } else { - // Internal consistency eerror + // Internal consistency error ChipLogError(Ble, "Unknown discovery type. Ignoring scanned device."); return; } From 4341eecee25ee7b9ba3727e92bf96ba27e788ecc Mon Sep 17 00:00:00 2001 From: Jakub Latusek Date: Wed, 23 Nov 2022 14:22:05 +0100 Subject: [PATCH 3/9] Remove redundant variable set --- src/platform/Linux/BLEManagerImpl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index 9722f4b745cc91..13fcebe833a30e 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -814,7 +814,6 @@ void BLEManagerImpl::OnScanComplete() ChipLogProgress(Ble, "Scan complete. No matching device found."); break; case BleScanState::kConnecting: - mBLEScanConfig.mBleScanState = BleScanState::kNotScanning; break; } From 8fafbab9a57507b6854a08a62ec38f55c2ef6942 Mon Sep 17 00:00:00 2001 From: Jakub Latusek Date: Fri, 25 Nov 2022 11:03:07 +0100 Subject: [PATCH 4/9] Rewrite OnScanComplete to make it more readable. Create a separate function to handle scan errors. --- src/controller/python/chip/ble/LinuxImpl.cpp | 22 +++++++++-- .../python/chip/ble/darwin/Scanning.mm | 10 ++++- src/platform/Linux/BLEManagerImpl.cpp | 3 +- src/platform/Tizen/BLEManagerImpl.cpp | 24 ++++++++---- src/platform/Tizen/BLEManagerImpl.h | 3 +- src/platform/Tizen/ChipDeviceScanner.cpp | 2 +- src/platform/Tizen/ChipDeviceScanner.h | 5 ++- src/platform/webos/BLEManagerImpl.cpp | 38 ++++++++----------- src/platform/webos/BLEManagerImpl.h | 5 +-- src/platform/webos/ChipDeviceScanner.cpp | 2 +- src/platform/webos/ChipDeviceScanner.h | 6 ++- 11 files changed, 73 insertions(+), 47 deletions(-) diff --git a/src/controller/python/chip/ble/LinuxImpl.cpp b/src/controller/python/chip/ble/LinuxImpl.cpp index c084f957d44d1c..2aa869ed1a530f 100644 --- a/src/controller/python/chip/ble/LinuxImpl.cpp +++ b/src/controller/python/chip/ble/LinuxImpl.cpp @@ -68,9 +68,12 @@ class ScannerDelegateImpl : public ChipDeviceScannerDelegate using DeviceScannedCallback = void (*)(PyObject * context, const char * address, uint16_t discriminator, uint16_t vendorId, uint16_t productId); using ScanCompleteCallback = void (*)(PyObject * context); + using ScanErrorCallback = void (*)(PyObject * context, CHIP_ERROR::StorageType error); - ScannerDelegateImpl(PyObject * context, DeviceScannedCallback scanCallback, ScanCompleteCallback completeCallback) : - mContext(context), mScanCallback(scanCallback), mCompleteCallback(completeCallback) + ScannerDelegateImpl(PyObject * context, DeviceScannedCallback scanCallback, ScanCompleteCallback completeCallback, + ScanErrorCallback errorCallback) : + mContext(context), + mScanCallback(scanCallback), mCompleteCallback(completeCallback), mErrorCallback(errorCallback) {} void SetScanner(std::unique_ptr scanner) { mScanner = std::move(scanner); } @@ -94,20 +97,31 @@ class ScannerDelegateImpl : public ChipDeviceScannerDelegate delete this; } + virtual void OnScanError(CHIP_ERROR error) override + { + if (mErrorCallback) + { + mErrorCallback(mContext, error.AsInteger()); + } + } + private: std::unique_ptr mScanner; PyObject * const mContext; const DeviceScannedCallback mScanCallback; const ScanCompleteCallback mCompleteCallback; + const ScanErrorCallback mErrorCallback; }; } // namespace extern "C" void * pychip_ble_start_scanning(PyObject * context, void * adapter, uint32_t timeoutMs, ScannerDelegateImpl::DeviceScannedCallback scanCallback, - ScannerDelegateImpl::ScanCompleteCallback completeCallback) + ScannerDelegateImpl::ScanCompleteCallback completeCallback, + ScannerDelegateImpl::ScanErrorCallback errorCallback) { - std::unique_ptr delegate = std::make_unique(context, scanCallback, completeCallback); + std::unique_ptr delegate = + std::make_unique(context, scanCallback, completeCallback, errorCallback); std::unique_ptr scanner = ChipDeviceScanner::Create(static_cast(adapter), delegate.get()); diff --git a/src/controller/python/chip/ble/darwin/Scanning.mm b/src/controller/python/chip/ble/darwin/Scanning.mm index cfe653ca9481ab..2558fe7656bb6d 100644 --- a/src/controller/python/chip/ble/darwin/Scanning.mm +++ b/src/controller/python/chip/ble/darwin/Scanning.mm @@ -11,6 +11,7 @@ using DeviceScannedCallback = void (*)(PyObject * context, const char * address, uint16_t discriminator, uint16_t vendorId, uint16_t productId); using ScanCompleteCallback = void (*)(PyObject * context); +using ScanErrorCallback = void (*)(PyObject * context, uint32_t error); } @interface ChipDeviceBleScanner : NSObject @@ -23,10 +24,12 @@ @interface ChipDeviceBleScanner : NSObject @property (assign, nonatomic) PyObject * context; @property (assign, nonatomic) DeviceScannedCallback scanCallback; @property (assign, nonatomic) ScanCompleteCallback completeCallback; +@property (assign, nonatomic) ScanErrorCallback errorCallback; - (id)initWithContext:(PyObject *)context scanCallback:(DeviceScannedCallback)scanCallback completeCallback:(ScanCompleteCallback)completeCallback + errorCallback:(ScanErrorCallback)errorCallback timeoutMs:(uint32_t)timeout; - (void)stopTimeoutReached; @@ -38,6 +41,7 @@ @implementation ChipDeviceBleScanner - (id)initWithContext:(PyObject *)context scanCallback:(DeviceScannedCallback)scanCallback completeCallback:(ScanCompleteCallback)completeCallback + errorCallback:(ScanErrorCallback)errorCallback timeoutMs:(uint32_t)timeout { self = [super init]; @@ -50,6 +54,7 @@ - (id)initWithContext:(PyObject *)context _context = context; _scanCallback = scanCallback; _completeCallback = completeCallback; + _errorCallback = errorCallback; dispatch_source_set_event_handler(_timer, ^{ [self stopTimeoutReached]; @@ -125,14 +130,15 @@ - (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPerip @end -extern "C" void * pychip_ble_start_scanning( - PyObject * context, void * adapter, uint32_t timeout, DeviceScannedCallback scanCallback, ScanCompleteCallback completeCallback) +extern "C" void * pychip_ble_start_scanning(PyObject * context, void * adapter, uint32_t timeout, + DeviceScannedCallback scanCallback, ScanCompleteCallback completeCallback, ScanErrorCallback errorCallback) { // NOTE: adapter is ignored as it does not apply to mac ChipDeviceBleScanner * scanner = [[ChipDeviceBleScanner alloc] initWithContext:context scanCallback:scanCallback completeCallback:completeCallback + errorCallback:errorCallback timeoutMs:timeout]; return (__bridge_retained void *) (scanner); diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index 13fcebe833a30e..409ac7becfe533 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -811,13 +811,12 @@ void BLEManagerImpl::OnScanComplete() break; case BleScanState::kScanForAddress: case BleScanState::kScanForDiscriminator: + mBLEScanConfig.mBleScanState = BleScanState::kNotScanning; ChipLogProgress(Ble, "Scan complete. No matching device found."); break; case BleScanState::kConnecting: break; } - - mBLEScanConfig.mBleScanState = BleScanState::kNotScanning; } void BLEManagerImpl::OnScanError(CHIP_ERROR err) diff --git a/src/platform/Tizen/BLEManagerImpl.cpp b/src/platform/Tizen/BLEManagerImpl.cpp index 9b2d5e2537fe51..1d047d5a8bff54 100644 --- a/src/platform/Tizen/BLEManagerImpl.cpp +++ b/src/platform/Tizen/BLEManagerImpl.cpp @@ -515,18 +515,26 @@ void BLEManagerImpl::OnChipDeviceScanned(void * device, const Ble::ChipBLEDevice ConnectHandler(deviceInfo->remote_address); } -void BLEManagerImpl::OnChipScanComplete() +void BLEManagerImpl::OnScanComplete() { - if (mBLEScanConfig.mBleScanState != BleScanState::kScanForDiscriminator && - mBLEScanConfig.mBleScanState != BleScanState::kScanForAddress) + switch (mBLEScanConfig.mBleScanState) { - ChipLogProgress(DeviceLayer, "Scan complete notification without an active scan."); - return; + case BleScanState::kNotScanning: + ChipLogProgress(Ble, "Scan complete notification without an active scan."); + break; + case BleScanState::kScanForAddress: + case BleScanState::kScanForDiscriminator: + mBLEScanConfig.mBleScanState = BleScanState::kNotScanning; + ChipLogProgress(Ble, "Scan complete. No matching device found."); + break; + case BleScanState::kConnecting: + break; } +} - ChipLogError(DeviceLayer, "Scan Completed with Timeout: Notify Upstream."); - BleConnectionDelegate::OnConnectionError(mBLEScanConfig.mAppState, CHIP_ERROR_TIMEOUT); - mBLEScanConfig.mBleScanState = BleScanState::kNotScanning; +void BLEManagerImpl::OnScanError(CHIP_ERROR err) +{ + ChipLogDetail(Ble, "BLE scan error: %" CHIP_ERROR_FORMAT, err.Format()); } int BLEManagerImpl::RegisterGATTServer() diff --git a/src/platform/Tizen/BLEManagerImpl.h b/src/platform/Tizen/BLEManagerImpl.h index 7723d2dcf62221..a685a85205de65 100644 --- a/src/platform/Tizen/BLEManagerImpl.h +++ b/src/platform/Tizen/BLEManagerImpl.h @@ -138,7 +138,8 @@ class BLEManagerImpl final : public BLEManager, // ===== Members that implement virtual methods on ChipDeviceScannerDelegate void OnChipDeviceScanned(void * device, const Ble::ChipBLEDeviceIdentificationInfo & info) override; - void OnChipScanComplete() override; + void OnScanComplete() override; + void OnScanError(CHIP_ERROR err) override; // ===== Members for internal use by the following friends. diff --git a/src/platform/Tizen/ChipDeviceScanner.cpp b/src/platform/Tizen/ChipDeviceScanner.cpp index 204895347cb45c..2fb48203a1ca1e 100644 --- a/src/platform/Tizen/ChipDeviceScanner.cpp +++ b/src/platform/Tizen/ChipDeviceScanner.cpp @@ -242,7 +242,7 @@ CHIP_ERROR ChipDeviceScanner::StopChipScan() UnRegisterScanFilter(); // Report to Impl class - mDelegate->OnChipScanComplete(); + mDelegate->OnScanComplete(); mIsScanning = false; diff --git a/src/platform/Tizen/ChipDeviceScanner.h b/src/platform/Tizen/ChipDeviceScanner.h index f95f4782ece551..ac8049fdd1ecdd 100644 --- a/src/platform/Tizen/ChipDeviceScanner.h +++ b/src/platform/Tizen/ChipDeviceScanner.h @@ -65,7 +65,10 @@ class ChipDeviceScannerDelegate virtual void OnChipDeviceScanned(void * device, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) = 0; // Called when a scan was completed (stopped or timed out) - virtual void OnChipScanComplete(void) = 0; + virtual void OnScanComplete(void) = 0; + + // Called on scan error + virtual void OnScanError(CHIP_ERROR err) = 0; }; /// Allows scanning for CHIP devices diff --git a/src/platform/webos/BLEManagerImpl.cpp b/src/platform/webos/BLEManagerImpl.cpp index 4aef02746ebc5a..92b86772731340 100644 --- a/src/platform/webos/BLEManagerImpl.cpp +++ b/src/platform/webos/BLEManagerImpl.cpp @@ -500,7 +500,7 @@ bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const { bool result = false; result = SubscribeCharacteristicToWebOS(conId, static_cast(svcId->bytes), - static_cast(charId->bytes)); + static_cast(charId->bytes)); return result; } @@ -598,8 +598,7 @@ bool BLEManagerImpl::SendWriteRequestToWebOS(void * bleConnObj, const uint8_t * valueParam.put("string", value); } else - { - } + {} param.put("value", valueParam); ChipLogProgress(Ble, "SendWriteRequestToWebOS Param : param %s", param.stringify().c_str()); @@ -917,31 +916,26 @@ void BLEManagerImpl::NotifyBLEPeripheralAdvStopComplete(bool aIsSuccess, void * PlatformMgr().PostEventOrDie(&event); } -void BLEManagerImpl::OnChipScanComplete() -{ - if (mBLEScanConfig.mBleScanState != BleScanState::kScanForDiscriminator && - mBLEScanConfig.mBleScanState != BleScanState::kScanForAddress) - { - ChipLogProgress(DeviceLayer, "Scan complete notification without an active scan."); - return; - } - - ChipLogError(DeviceLayer, "Scan Completed with Timeout: Notify Upstream."); - BleConnectionDelegate::OnConnectionError(mBLEScanConfig.mAppState, CHIP_ERROR_TIMEOUT); - mBLEScanConfig.mBleScanState = BleScanState::kNotScanning; -} - void BLEManagerImpl::OnScanComplete() { - if (mBLEScanConfig.mBleScanState != BleScanState::kScanForDiscriminator && - mBLEScanConfig.mBleScanState != BleScanState::kScanForAddress) + switch (mBLEScanConfig.mBleScanState) { + case BleScanState::kNotScanning: ChipLogProgress(Ble, "Scan complete notification without an active scan."); - return; + break; + case BleScanState::kScanForAddress: + case BleScanState::kScanForDiscriminator: + mBLEScanConfig.mBleScanState = BleScanState::kNotScanning; + ChipLogProgress(Ble, "Scan complete. No matching device found."); + break; + case BleScanState::kConnecting: + break; } +} - BleConnectionDelegate::OnConnectionError(mBLEScanConfig.mAppState, CHIP_ERROR_TIMEOUT); - mBLEScanConfig.mBleScanState = BleScanState::kNotScanning; +void BLEManagerImpl::OnScanError(CHIP_ERROR err) +{ + ChipLogDetail(Ble, "BLE scan error: %" CHIP_ERROR_FORMAT, err.Format()); } bool BLEManagerImpl::gattGetServiceCb(LSHandle * sh, LSMessage * message, void * userData) diff --git a/src/platform/webos/BLEManagerImpl.h b/src/platform/webos/BLEManagerImpl.h index a9a8a0ac88312d..2ab9a5844e4fdc 100644 --- a/src/platform/webos/BLEManagerImpl.h +++ b/src/platform/webos/BLEManagerImpl.h @@ -135,10 +135,9 @@ class BLEManagerImpl final : public BLEManager, CHIP_ERROR CancelConnection() override; // ===== Members that implement virtual methods on ChipDeviceScannerDelegate - void OnScanComplete() override; void OnChipDeviceScanned(char * address) override; - void OnChipScanComplete() override; - + void OnScanComplete() override; + void OnScanError(CHIP_ERROR err) override; // ===== Members for internal use by the following friends. friend BLEManager & BLEMgr(); diff --git a/src/platform/webos/ChipDeviceScanner.cpp b/src/platform/webos/ChipDeviceScanner.cpp index 7e3a4b71b9f0a9..c79112b820bec3 100644 --- a/src/platform/webos/ChipDeviceScanner.cpp +++ b/src/platform/webos/ChipDeviceScanner.cpp @@ -336,7 +336,7 @@ CHIP_ERROR ChipDeviceScanner::StopChipScan() ChipLogProgress(DeviceLayer, "CHIP Scanner Async Thread Quit Done..Wait for Thread Windup...!"); // Report to Impl class - mDelegate->OnChipScanComplete(); + mDelegate->OnScanComplete(); mIsScanning = false; diff --git a/src/platform/webos/ChipDeviceScanner.h b/src/platform/webos/ChipDeviceScanner.h index d3481204c642a5..084d45d9ac0201 100644 --- a/src/platform/webos/ChipDeviceScanner.h +++ b/src/platform/webos/ChipDeviceScanner.h @@ -43,8 +43,10 @@ class ChipDeviceScannerDelegate virtual void OnChipDeviceScanned(char * address) = 0; // Called when a scan was completed (stopped or timed out) - virtual void OnScanComplete() = 0; - virtual void OnChipScanComplete() = 0; + virtual void OnScanComplete() = 0; + + // Called on scan error + virtual void OnScanError(CHIP_ERROR err) = 0; }; /// Allows scanning for CHIP devices From 8f88f5c862555ab59115b24ddc3ea0289e3db519 Mon Sep 17 00:00:00 2001 From: Jakub Latusek Date: Mon, 28 Nov 2022 10:27:02 +0100 Subject: [PATCH 5/9] Add missing override --- src/platform/Linux/BLEManagerImpl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/Linux/BLEManagerImpl.h b/src/platform/Linux/BLEManagerImpl.h index 6aab5658742934..ef7cb53ede7a50 100644 --- a/src/platform/Linux/BLEManagerImpl.h +++ b/src/platform/Linux/BLEManagerImpl.h @@ -91,7 +91,7 @@ class BLEManagerImpl final : public BLEManager, public: CHIP_ERROR ConfigureBle(uint32_t aAdapterId, bool aIsCentral); - void OnScanError(ChipError error); + void OnScanError(CHIP_ERROR error) override; // Driven by BlueZ IO static void HandleNewConnection(BLE_CONNECTION_OBJECT conId); From d68c0f50d5914bf4b478f1330ed9950bd4d08c72 Mon Sep 17 00:00:00 2001 From: Jakub Latusek Date: Wed, 30 Nov 2022 09:57:40 +0100 Subject: [PATCH 6/9] Style fix --- src/platform/webos/BLEManagerImpl.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/platform/webos/BLEManagerImpl.cpp b/src/platform/webos/BLEManagerImpl.cpp index 92b86772731340..3ea67b6ad1c486 100644 --- a/src/platform/webos/BLEManagerImpl.cpp +++ b/src/platform/webos/BLEManagerImpl.cpp @@ -500,7 +500,7 @@ bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const { bool result = false; result = SubscribeCharacteristicToWebOS(conId, static_cast(svcId->bytes), - static_cast(charId->bytes)); + static_cast(charId->bytes)); return result; } @@ -598,7 +598,8 @@ bool BLEManagerImpl::SendWriteRequestToWebOS(void * bleConnObj, const uint8_t * valueParam.put("string", value); } else - {} + { + } param.put("value", valueParam); ChipLogProgress(Ble, "SendWriteRequestToWebOS Param : param %s", param.stringify().c_str()); From 9a8e9ccb590549d1034232e73f91a48465afff27 Mon Sep 17 00:00:00 2001 From: Jakub Latusek Date: Mon, 13 Feb 2023 14:28:05 +0100 Subject: [PATCH 7/9] Change log level --- src/platform/Linux/BLEManagerImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index 409ac7becfe533..c9ae6ae36bf771 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -821,7 +821,7 @@ void BLEManagerImpl::OnScanComplete() void BLEManagerImpl::OnScanError(CHIP_ERROR err) { - ChipLogDetail(Ble, "BLE scan error: %" CHIP_ERROR_FORMAT, err.Format()); + ChipLogError(Ble, "BLE scan error: %" CHIP_ERROR_FORMAT, err.Format()); } } // namespace Internal From b53ad1f90a33a2d68eca354de53722e65a118d12 Mon Sep 17 00:00:00 2001 From: Jakub Latusek Date: Mon, 13 Feb 2023 15:07:39 +0100 Subject: [PATCH 8/9] Call an error in darwin on StopTimeoutReached --- src/controller/python/chip/ble/darwin/Scanning.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controller/python/chip/ble/darwin/Scanning.mm b/src/controller/python/chip/ble/darwin/Scanning.mm index 2558fe7656bb6d..1f28002da45062 100644 --- a/src/controller/python/chip/ble/darwin/Scanning.mm +++ b/src/controller/python/chip/ble/darwin/Scanning.mm @@ -105,6 +105,7 @@ - (void)stopTimeoutReached ChipLogProgress(Ble, "Scan timeout reached."); _completeCallback(_context); + _errorCallback(_context, CHIP_ERROR_TIMEOUT); dispatch_source_cancel(_timer); [self.centralManager stopScan]; From a45a4f9a27b13b7fcbb0bc5ba5f5ec53caa43011 Mon Sep 17 00:00:00 2001 From: Jakub Latusek Date: Mon, 13 Feb 2023 21:27:45 +0100 Subject: [PATCH 9/9] Error as int --- src/controller/python/chip/ble/darwin/Scanning.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/python/chip/ble/darwin/Scanning.mm b/src/controller/python/chip/ble/darwin/Scanning.mm index 1f28002da45062..c26395281e5529 100644 --- a/src/controller/python/chip/ble/darwin/Scanning.mm +++ b/src/controller/python/chip/ble/darwin/Scanning.mm @@ -105,7 +105,7 @@ - (void)stopTimeoutReached ChipLogProgress(Ble, "Scan timeout reached."); _completeCallback(_context); - _errorCallback(_context, CHIP_ERROR_TIMEOUT); + _errorCallback(_context, CHIP_ERROR_TIMEOUT.AsInteger()); dispatch_source_cancel(_timer); [self.centralManager stopScan];