From 50025310a89bf7471a007df026b00993784c7082 Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Wed, 5 Jul 2023 17:00:34 +0200 Subject: [PATCH] [Tizen] Get GATT connection MTU (#27626) --- src/platform/Tizen/BLEManagerImpl.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/platform/Tizen/BLEManagerImpl.cpp b/src/platform/Tizen/BLEManagerImpl.cpp index 3749d1d6f5027e..e2d2f61c65bda5 100644 --- a/src/platform/Tizen/BLEManagerImpl.cpp +++ b/src/platform/Tizen/BLEManagerImpl.cpp @@ -76,7 +76,7 @@ BLEManagerImpl BLEManagerImpl::sInstance; struct BLEConnection { char * peerAddr; - uint16_t mtu; + unsigned int mtu; bool subscribed; bt_gatt_h gattCharC1Handle; bt_gatt_h gattCharC2Handle; @@ -798,6 +798,13 @@ void BLEManagerImpl::AddConnectionData(const char * remoteAddr) conn = static_cast(g_malloc0(sizeof(BLEConnection))); conn->peerAddr = g_strdup(remoteAddr); + int ret; + if ((ret = bt_gatt_server_get_device_mtu(remoteAddr, &conn->mtu) != BT_ERROR_NONE)) + { + ChipLogError(DeviceLayer, "Failed to get MTU for [%s]. ret: %s", StringOrNullMarker(remoteAddr), + get_error_message(ret)); + } + if (sInstance.mIsCentral) { /* Local Device is BLE Central Role */ @@ -1185,7 +1192,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) uint16_t BLEManagerImpl::GetMTU(BLE_CONNECTION_OBJECT conId) const { auto conn = static_cast(conId); - return (conn != nullptr) ? conn->mtu : 0; + return (conn != nullptr) ? static_cast(conn->mtu) : 0; } bool BLEManagerImpl::SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const Ble::ChipBleUUID * svcId,