From 894335cd3a3ac643048e4acf269269e6a95d35c0 Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Tue, 21 Mar 2023 18:37:48 +0100 Subject: [PATCH] Use Uint8:: helpers instead of reinterpret_cast --- src/platform/Tizen/BLEManagerImpl.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/platform/Tizen/BLEManagerImpl.cpp b/src/platform/Tizen/BLEManagerImpl.cpp index fe993580e3646d..2c3c70523e4c62 100644 --- a/src/platform/Tizen/BLEManagerImpl.cpp +++ b/src/platform/Tizen/BLEManagerImpl.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -188,7 +189,7 @@ void BLEManagerImpl::ReadValueRequestedCb(const char * remoteAddress, int reques ret = bt_gatt_get_value(gattHandle, &value, &len); VerifyOrReturn(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_get_value() failed. ret: %d", ret)); - ChipLogByteSpan(DeviceLayer, ByteSpan(reinterpret_cast(value), len)); + ChipLogByteSpan(DeviceLayer, ByteSpan(Uint8::from_const_char(value), len)); ret = bt_gatt_server_send_response(requestId, BT_GATT_REQUEST_TYPE_READ, offset, 0x00, value, len); g_free(value); @@ -210,7 +211,7 @@ void BLEManagerImpl::WriteValueRequestedCb(const char * remoteAddress, int reque ChipLogError(DeviceLayer, "Failed to fetch GATT Attribute from GATT handle")); ChipLogProgress(DeviceLayer, "Gatt write requested on %s: uuid=%s len=%d", __ConvertAttTypeToStr(type), StringOrNullMarker(uuid), len); - ChipLogByteSpan(DeviceLayer, ByteSpan(reinterpret_cast(value), len)); + ChipLogByteSpan(DeviceLayer, ByteSpan(Uint8::from_const_char(value), len)); g_free(uuid); ret = bt_gatt_set_value(gattHandle, value, len); @@ -219,7 +220,7 @@ void BLEManagerImpl::WriteValueRequestedCb(const char * remoteAddress, int reque ret = bt_gatt_server_send_response(requestId, BT_GATT_REQUEST_TYPE_WRITE, offset, 0x00, nullptr, 0); VerifyOrReturn(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_server_send_response() failed. ret: %d", ret)); - sInstance.HandleC1CharWriteEvent(conn, reinterpret_cast(value), len); + sInstance.HandleC1CharWriteEvent(conn, Uint8::from_const_char(value), len); } void BLEManagerImpl::NotificationStateChangedCb(bool notify, bt_gatt_server_h server, bt_gatt_h gattHandle, void * userData) @@ -270,7 +271,7 @@ void BLEManagerImpl::CharacteristicNotificationCb(bt_gatt_h characteristic, char VerifyOrReturn(conn->gattCharC2Handle == characteristic, ChipLogError(DeviceLayer, "Gatt characteristic handle did not match")); ChipLogProgress(DeviceLayer, "Notification Received from CHIP peripheral [%s]", conn->peerAddr); - sInstance.HandleRXCharChanged(conn, reinterpret_cast(value), len); + sInstance.HandleRXCharChanged(conn, Uint8::from_const_char(value), len); } void BLEManagerImpl::IndicationConfirmationCb(int result, const char * remoteAddress, bt_gatt_server_h server, @@ -1279,7 +1280,7 @@ bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const Ble::Chip conn = static_cast(g_hash_table_lookup(sInstance.mConnectionMap, conn->peerAddr)); VerifyOrExit(conn != nullptr, ChipLogError(DeviceLayer, "Failed to find connection info")); - ret = bt_gatt_set_value(mGattCharC2Handle, reinterpret_cast(pBuf->Start()), pBuf->DataLength()); + ret = bt_gatt_set_value(mGattCharC2Handle, Uint8::to_const_char(pBuf->Start()), pBuf->DataLength()); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_set_value() failed. ret: %d", ret)); ChipLogProgress(DeviceLayer, "Sending indication for CHIPoBLE RX characteristic (con %s, len %u)", conn->peerAddr, @@ -1314,7 +1315,7 @@ bool BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const Ble::Ch ChipLogError(DeviceLayer, "SendWriteRequest() called with invalid characteristic ID")); VerifyOrExit(conn->gattCharC1Handle != nullptr, ChipLogError(DeviceLayer, "Char C1 is null")); - ret = bt_gatt_set_value(conn->gattCharC1Handle, reinterpret_cast(pBuf->Start()), pBuf->DataLength()); + ret = bt_gatt_set_value(conn->gattCharC1Handle, Uint8::to_const_char(pBuf->Start()), pBuf->DataLength()); VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_set_value() failed. ret: %d", ret)); ChipLogProgress(DeviceLayer, "Sending Write Request for CHIPoBLE TX characteristic (con %s, len %u)", conn->peerAddr,