diff --git a/src/platform/Linux/bluez/BluezAdvertisement.cpp b/src/platform/Linux/bluez/BluezAdvertisement.cpp index 06f831bff8b58f..0fed99478cdaf9 100644 --- a/src/platform/Linux/bluez/BluezAdvertisement.cpp +++ b/src/platform/Linux/bluez/BluezAdvertisement.cpp @@ -224,7 +224,7 @@ void BluezAdvertisement::Shutdown() void BluezAdvertisement::StartDone(GObject * aObject, GAsyncResult * aResult) { - BluezLEAdvertisingManager1 * advMgr = BLUEZ_LEADVERTISING_MANAGER1(aObject); + auto * advMgr = reinterpret_cast(aObject); GAutoPtr error; gboolean success = FALSE; @@ -252,7 +252,7 @@ CHIP_ERROR BluezAdvertisement::StartImpl() adapterObject = g_dbus_interface_get_object(G_DBUS_INTERFACE(mAdapter.get())); VerifyOrExit(adapterObject != nullptr, ChipLogError(DeviceLayer, "FAIL: NULL adapterObject in %s", __func__)); - advMgr.reset(bluez_object_get_leadvertising_manager1(BLUEZ_OBJECT(adapterObject))); + advMgr.reset(bluez_object_get_leadvertising_manager1(reinterpret_cast(adapterObject))); VerifyOrExit(advMgr.get() != nullptr, ChipLogError(DeviceLayer, "FAIL: NULL advMgr in %s", __func__)); g_variant_builder_init(&optionsBuilder, G_VARIANT_TYPE("a{sv}")); @@ -282,7 +282,7 @@ CHIP_ERROR BluezAdvertisement::Start() void BluezAdvertisement::StopDone(GObject * aObject, GAsyncResult * aResult) { - BluezLEAdvertisingManager1 * advMgr = BLUEZ_LEADVERTISING_MANAGER1(aObject); + auto * advMgr = reinterpret_cast(aObject); GAutoPtr error; gboolean success = FALSE; @@ -308,7 +308,7 @@ CHIP_ERROR BluezAdvertisement::StopImpl() adapterObject = g_dbus_interface_get_object(G_DBUS_INTERFACE(mAdapter.get())); VerifyOrExit(adapterObject != nullptr, ChipLogError(DeviceLayer, "FAIL: NULL adapterObject in %s", __func__)); - advMgr.reset(bluez_object_get_leadvertising_manager1(BLUEZ_OBJECT(adapterObject))); + advMgr.reset(bluez_object_get_leadvertising_manager1(reinterpret_cast(adapterObject))); VerifyOrExit(advMgr.get() != nullptr, ChipLogError(DeviceLayer, "FAIL: NULL advMgr in %s", __func__)); bluez_leadvertising_manager1_call_unregister_advertisement( diff --git a/src/platform/Linux/bluez/BluezConnection.cpp b/src/platform/Linux/bluez/BluezConnection.cpp index d2db5edc005eba..88595bd86c720c 100644 --- a/src/platform/Linux/bluez/BluezConnection.cpp +++ b/src/platform/Linux/bluez/BluezConnection.cpp @@ -305,9 +305,10 @@ CHIP_ERROR BluezConnection::SendIndication(chip::System::PacketBufferHandle apBu void BluezConnection::SendWriteRequestDone(GObject * aObject, GAsyncResult * aResult, gpointer apConnection) { - BluezGattCharacteristic1 * c1 = BLUEZ_GATT_CHARACTERISTIC1(aObject); + auto * pC1 = reinterpret_cast(aObject); + GAutoPtr error; - gboolean success = bluez_gatt_characteristic1_call_write_value_finish(c1, aResult, &error.GetReceiver()); + gboolean success = bluez_gatt_characteristic1_call_write_value_finish(pC1, aResult, &error.GetReceiver()); VerifyOrReturn(success == TRUE, ChipLogError(DeviceLayer, "FAIL: SendWriteRequest : %s", error->message)); BLEManagerImpl::HandleWriteComplete(static_cast(apConnection)); @@ -354,9 +355,10 @@ void BluezConnection::OnCharacteristicChanged(GDBusProxy * aInterface, GVariant void BluezConnection::SubscribeCharacteristicDone(GObject * aObject, GAsyncResult * aResult, gpointer apConnection) { - BluezGattCharacteristic1 * c2 = BLUEZ_GATT_CHARACTERISTIC1(aObject); + auto * pC2 = reinterpret_cast(aObject); + GAutoPtr error; - gboolean success = bluez_gatt_characteristic1_call_write_value_finish(c2, aResult, &error.GetReceiver()); + gboolean success = bluez_gatt_characteristic1_call_write_value_finish(pC2, aResult, &error.GetReceiver()); VerifyOrReturn(success == TRUE, ChipLogError(DeviceLayer, "FAIL: SubscribeCharacteristic : %s", error->message)); @@ -365,13 +367,12 @@ void BluezConnection::SubscribeCharacteristicDone(GObject * aObject, GAsyncResul CHIP_ERROR BluezConnection::SubscribeCharacteristicImpl(BluezConnection * connection) { - BluezGattCharacteristic1 * c2 = nullptr; - VerifyOrExit(connection->mpC2 != nullptr, ChipLogError(DeviceLayer, "C2 is NULL in %s", __func__)); - c2 = BLUEZ_GATT_CHARACTERISTIC1(connection->mpC2); + BluezGattCharacteristic1 * pC2 = connection->mpC2; + VerifyOrExit(pC2 != nullptr, ChipLogError(DeviceLayer, "C2 is NULL in %s", __func__)); // Get notifications on the TX characteristic change (e.g. indication is received) - g_signal_connect(c2, "g-properties-changed", G_CALLBACK(OnCharacteristicChanged), connection); - bluez_gatt_characteristic1_call_start_notify(connection->mpC2, nullptr, SubscribeCharacteristicDone, connection); + g_signal_connect(pC2, "g-properties-changed", G_CALLBACK(OnCharacteristicChanged), connection); + bluez_gatt_characteristic1_call_start_notify(pC2, nullptr, SubscribeCharacteristicDone, connection); exit: return CHIP_NO_ERROR; @@ -386,22 +387,24 @@ CHIP_ERROR BluezConnection::SubscribeCharacteristic() void BluezConnection::UnsubscribeCharacteristicDone(GObject * aObject, GAsyncResult * aResult, gpointer apConnection) { - BluezGattCharacteristic1 * c2 = BLUEZ_GATT_CHARACTERISTIC1(aObject); + auto * pC2 = reinterpret_cast(aObject); + GAutoPtr error; - gboolean success = bluez_gatt_characteristic1_call_write_value_finish(c2, aResult, &error.GetReceiver()); + gboolean success = bluez_gatt_characteristic1_call_write_value_finish(pC2, aResult, &error.GetReceiver()); VerifyOrReturn(success == TRUE, ChipLogError(DeviceLayer, "FAIL: UnsubscribeCharacteristic : %s", error->message)); // Stop listening to the TX characteristic changes - g_signal_handlers_disconnect_by_data(c2, apConnection); + g_signal_handlers_disconnect_by_data(pC2, apConnection); BLEManagerImpl::HandleSubscribeOpComplete(static_cast(apConnection), false); } CHIP_ERROR BluezConnection::UnsubscribeCharacteristicImpl(BluezConnection * connection) { - VerifyOrExit(connection->mpC2 != nullptr, ChipLogError(DeviceLayer, "C2 is NULL in %s", __func__)); + BluezGattCharacteristic1 * pC2 = connection->mpC2; + VerifyOrExit(pC2 != nullptr, ChipLogError(DeviceLayer, "C2 is NULL in %s", __func__)); - bluez_gatt_characteristic1_call_stop_notify(connection->mpC2, nullptr, UnsubscribeCharacteristicDone, connection); + bluez_gatt_characteristic1_call_stop_notify(pC2, nullptr, UnsubscribeCharacteristicDone, connection); exit: return CHIP_NO_ERROR; diff --git a/src/platform/Linux/bluez/BluezEndpoint.cpp b/src/platform/Linux/bluez/BluezEndpoint.cpp index 2fdd1e1788af6b..8d37b1363e84ad 100644 --- a/src/platform/Linux/bluez/BluezEndpoint.cpp +++ b/src/platform/Linux/bluez/BluezEndpoint.cpp @@ -262,9 +262,8 @@ BluezGattCharacteristic1 * BluezEndpoint::CreateGattCharacteristic(BluezGattServ void BluezEndpoint::RegisterGattApplicationDone(GObject * aObject, GAsyncResult * aResult) { GAutoPtr error; - BluezGattManager1 * gattMgr = BLUEZ_GATT_MANAGER1(aObject); - - gboolean success = bluez_gatt_manager1_call_register_application_finish(gattMgr, aResult, &error.GetReceiver()); + gboolean success = bluez_gatt_manager1_call_register_application_finish(reinterpret_cast(aObject), aResult, + &error.GetReceiver()); VerifyOrReturn(success == TRUE, { ChipLogError(DeviceLayer, "FAIL: RegisterApplication : %s", error->message); @@ -287,7 +286,7 @@ CHIP_ERROR BluezEndpoint::RegisterGattApplicationImpl() adapterObject = g_dbus_interface_get_object(G_DBUS_INTERFACE(mAdapter.get())); VerifyOrExit(adapterObject != nullptr, ChipLogError(DeviceLayer, "FAIL: NULL adapterObject in %s", __func__)); - gattMgr.reset(bluez_object_get_gatt_manager1(BLUEZ_OBJECT(adapterObject))); + gattMgr.reset(bluez_object_get_gatt_manager1(reinterpret_cast(adapterObject))); VerifyOrExit(gattMgr.get() != nullptr, ChipLogError(DeviceLayer, "FAIL: NULL gattMgr in %s", __func__)); g_variant_builder_init(&optionsBuilder, G_VARIANT_TYPE("a{sv}")); @@ -383,7 +382,7 @@ void BluezEndpoint::BluezSignalOnObjectAdded(GDBusObjectManager * aManager, GDBu { // TODO: right now we do not handle addition/removal of adapters // Primary focus here is to handle addition of a device - GAutoPtr device(bluez_object_get_device1(BLUEZ_OBJECT(aObject))); + GAutoPtr device(bluez_object_get_device1(reinterpret_cast(aObject))); VerifyOrReturn(device.get() != nullptr); if (BluezIsDeviceOnAdapter(device.get(), mAdapter.get()) == TRUE) diff --git a/src/platform/Linux/bluez/BluezObjectIterator.h b/src/platform/Linux/bluez/BluezObjectIterator.h index ae5e01c6b9e34d..0e09cbcf217fc0 100644 --- a/src/platform/Linux/bluez/BluezObjectIterator.h +++ b/src/platform/Linux/bluez/BluezObjectIterator.h @@ -41,8 +41,8 @@ class BluezObjectIterator BluezObjectIterator() = default; explicit BluezObjectIterator(GList * position) : mPosition(position) {} - reference operator*() const { return *BLUEZ_OBJECT(mPosition->data); } - pointer operator->() const { return BLUEZ_OBJECT(mPosition->data); } + reference operator*() const { return *reinterpret_cast(mPosition->data); } + pointer operator->() const { return reinterpret_cast(mPosition->data); } bool operator==(const BluezObjectIterator & other) const { return mPosition == other.mPosition; } bool operator!=(const BluezObjectIterator & other) const { return mPosition != other.mPosition; } diff --git a/src/platform/Linux/bluez/ChipDeviceScanner.cpp b/src/platform/Linux/bluez/ChipDeviceScanner.cpp index 0d248058c3d1a0..5523bf87dfdf66 100644 --- a/src/platform/Linux/bluez/ChipDeviceScanner.cpp +++ b/src/platform/Linux/bluez/ChipDeviceScanner.cpp @@ -215,7 +215,7 @@ CHIP_ERROR ChipDeviceScanner::MainLoopStopScan(ChipDeviceScanner * self) void ChipDeviceScanner::SignalObjectAdded(GDBusObjectManager * manager, GDBusObject * object, ChipDeviceScanner * self) { - GAutoPtr device(bluez_object_get_device1(BLUEZ_OBJECT(object))); + GAutoPtr device(bluez_object_get_device1(reinterpret_cast(object))); VerifyOrReturn(device.get() != nullptr); self->ReportDevice(*device.get()); @@ -225,7 +225,7 @@ void ChipDeviceScanner::SignalInterfaceChanged(GDBusObjectManagerClient * manage GDBusProxy * aInterface, GVariant * aChangedProperties, const gchar * const * aInvalidatedProps, ChipDeviceScanner * self) { - GAutoPtr device(bluez_object_get_device1(BLUEZ_OBJECT(object))); + GAutoPtr device(bluez_object_get_device1(reinterpret_cast(object))); VerifyOrReturn(device.get() != nullptr); self->ReportDevice(*device.get());