From 2ff6dacb7ca5ba40ad7c7c3be041fb92b704ea2e Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Fri, 7 Jun 2024 12:50:22 +0200 Subject: [PATCH] Forward BLE disconnection to CHIPoBLE layer --- src/platform/Tizen/BLEManagerImpl.cpp | 11 ++++++----- src/platform/Tizen/BLEManagerImpl.h | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/platform/Tizen/BLEManagerImpl.cpp b/src/platform/Tizen/BLEManagerImpl.cpp index 2e517f64e61c92..31cfe3456bb934 100644 --- a/src/platform/Tizen/BLEManagerImpl.cpp +++ b/src/platform/Tizen/BLEManagerImpl.cpp @@ -401,16 +401,16 @@ void BLEManagerImpl::NotifyBLEIndicationConfirmation(BLE_CONNECTION_OBJECT conId PlatformMgr().PostEventOrDie(&event); } -void BLEManagerImpl::NotifyBLEConnectionEstablished(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error) +void BLEManagerImpl::NotifyBLEConnectionEstablished(BLE_CONNECTION_OBJECT conId) { ChipDeviceEvent event{ .Type = DeviceEventType::kCHIPoBLEConnectionEstablished }; PlatformMgr().PostEventOrDie(&event); } -void BLEManagerImpl::NotifyBLEDisconnection(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error) +void BLEManagerImpl::NotifyBLEDisconnection(BLE_CONNECTION_OBJECT conId) { ChipDeviceEvent event{ .Type = DeviceEventType::kCHIPoBLEConnectionError, - .CHIPoBLEConnectionError = { .ConId = conId, .Reason = error } }; + .CHIPoBLEConnectionError = { .ConId = conId, .Reason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED } }; PlatformMgr().PostEventOrDie(&event); } @@ -873,6 +873,7 @@ void BLEManagerImpl::RemoveConnectionData(const char * remoteAddr) VerifyOrReturn(conn != nullptr, ChipLogError(DeviceLayer, "Connection does not exist for [%s]", StringOrNullMarker(remoteAddr))); + BLEManagerImpl::NotifyBLEDisconnection(conn); g_hash_table_remove(mConnectionMap, remoteAddr); ChipLogProgress(DeviceLayer, "Connection Removed"); @@ -925,7 +926,7 @@ void BLEManagerImpl::HandleConnectionEvent(bool connected, const char * remoteAd } else { - ChipLogProgress(DeviceLayer, "Device DisConnected [%s]", StringOrNullMarker(remoteAddress)); + ChipLogProgress(DeviceLayer, "Device Disconnected [%s]", StringOrNullMarker(remoteAddress)); RemoveConnectionData(remoteAddress); } } @@ -1160,7 +1161,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) ChipLogProgress(DeviceLayer, "CHIPoBLESubscribe"); HandleSubscribeReceived(event->CHIPoBLESubscribe.ConId, &Ble::CHIP_BLE_SVC_ID, &Ble::CHIP_BLE_CHAR_2_UUID); - NotifyBLEConnectionEstablished(event->CHIPoBLESubscribe.ConId, CHIP_NO_ERROR); + NotifyBLEConnectionEstablished(event->CHIPoBLESubscribe.ConId); break; case DeviceEventType::kCHIPoBLEUnsubscribe: ChipLogProgress(DeviceLayer, "CHIPoBLEUnsubscribe"); diff --git a/src/platform/Tizen/BLEManagerImpl.h b/src/platform/Tizen/BLEManagerImpl.h index 4f68be1cef0d87..c63b68aec48ae4 100644 --- a/src/platform/Tizen/BLEManagerImpl.h +++ b/src/platform/Tizen/BLEManagerImpl.h @@ -214,8 +214,8 @@ class BLEManagerImpl final : public BLEManager, // ==== Connection. CHIP_ERROR ConnectChipThing(const char * address); - void NotifyBLEConnectionEstablished(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error); - void NotifyBLEDisconnection(BLE_CONNECTION_OBJECT conId, CHIP_ERROR error); + void NotifyBLEConnectionEstablished(BLE_CONNECTION_OBJECT conId); + void NotifyBLEDisconnection(BLE_CONNECTION_OBJECT conId); void NotifyHandleNewConnection(BLE_CONNECTION_OBJECT conId); void NotifyHandleConnectFailed(CHIP_ERROR error); void NotifyHandleWriteComplete(BLE_CONNECTION_OBJECT conId);