From bb7b1311dbd4988e2139b3c94a35bb456e733b8c Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Sat, 18 Mar 2023 08:47:26 +0100 Subject: [PATCH] [Tizen] Do not fail if BLE is already connected (#25725) * [Tizen] Do not fail if BLE is already connected * Show error message in case of BLE connection failure --- src/platform/Tizen/BLEManagerImpl.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/platform/Tizen/BLEManagerImpl.cpp b/src/platform/Tizen/BLEManagerImpl.cpp index 54527546da655a..55144ba1b68985 100644 --- a/src/platform/Tizen/BLEManagerImpl.cpp +++ b/src/platform/Tizen/BLEManagerImpl.cpp @@ -101,18 +101,19 @@ 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) { - ChipLogError(DeviceLayer, "%s", connected ? "Connection req failed" : "Disconnection req failed"); + case BT_ERROR_NONE: + case BT_ERROR_ALREADY_DONE: + sInstance.HandleConnectionEvent(connected, remoteAddress); + break; + default: + ChipLogError(DeviceLayer, "%s: %s", connected ? "Connection req failed" : "Disconnection req failed", + get_error_message(result)); if (connected) sInstance.NotifyHandleConnectFailed(CHIP_ERROR_INTERNAL); } - else - { - sInstance.HandleConnectionEvent(connected, remoteAddress); - } } gboolean BLEManagerImpl::_BleInitialize(void * userData)