From 2b7f40c6332a62d04cff73b34a0e8792e352e81f Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Fri, 17 Mar 2023 10:22:53 +0100 Subject: [PATCH 1/2] [Tizen] Do not fail if BLE is already connected --- src/platform/Tizen/BLEManagerImpl.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/platform/Tizen/BLEManagerImpl.cpp b/src/platform/Tizen/BLEManagerImpl.cpp index 54527546da655a..eb77e53e56f694 100644 --- a/src/platform/Tizen/BLEManagerImpl.cpp +++ b/src/platform/Tizen/BLEManagerImpl.cpp @@ -101,18 +101,18 @@ static void __AdapterStateChangedCb(int result, bt_adapter_state_e adapterState, void BLEManagerImpl::GattConnectionStateChangedCb(int result, bool connected, const char * remoteAddress, void * userData) { - ChipLogProgress(DeviceLayer, "Gatt Connection State Changed: %s result [%d]", connected ? "Connected" : "Disconnected", result); - - if (result != BT_ERROR_NONE) + ChipLogProgress(DeviceLayer, "Gatt Connection State Changed [%u]: %s", result, connected ? "Connected" : "Disconnected"); + switch (result) { + case BT_ERROR_NONE: + case BT_ERROR_ALREADY_DONE: + sInstance.HandleConnectionEvent(connected, remoteAddress); + break; + default: ChipLogError(DeviceLayer, "%s", connected ? "Connection req failed" : "Disconnection req failed"); if (connected) sInstance.NotifyHandleConnectFailed(CHIP_ERROR_INTERNAL); } - else - { - sInstance.HandleConnectionEvent(connected, remoteAddress); - } } gboolean BLEManagerImpl::_BleInitialize(void * userData) From dc6923d36d4b9a88cbec4c2c90fd4292339595ee Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Fri, 17 Mar 2023 10:52:10 +0100 Subject: [PATCH 2/2] Show error message in case of BLE connection failure --- src/platform/Tizen/BLEManagerImpl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/platform/Tizen/BLEManagerImpl.cpp b/src/platform/Tizen/BLEManagerImpl.cpp index eb77e53e56f694..55144ba1b68985 100644 --- a/src/platform/Tizen/BLEManagerImpl.cpp +++ b/src/platform/Tizen/BLEManagerImpl.cpp @@ -109,7 +109,8 @@ void BLEManagerImpl::GattConnectionStateChangedCb(int result, bool connected, co sInstance.HandleConnectionEvent(connected, remoteAddress); break; default: - ChipLogError(DeviceLayer, "%s", connected ? "Connection req failed" : "Disconnection req failed"); + ChipLogError(DeviceLayer, "%s: %s", connected ? "Connection req failed" : "Disconnection req failed", + get_error_message(result)); if (connected) sInstance.NotifyHandleConnectFailed(CHIP_ERROR_INTERNAL); }