From a04a2926d7c1490d1a89181262c8f83a1400c736 Mon Sep 17 00:00:00 2001 From: Hrishikesh Dhayagude Date: Wed, 12 Jan 2022 19:40:20 +0530 Subject: [PATCH] Fix the issue of notification not being received from the device (BLE peripheral) to chiptool (#13461) --- src/platform/Linux/bluez/Helper.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platform/Linux/bluez/Helper.cpp b/src/platform/Linux/bluez/Helper.cpp index feae4149eab7d4..30844ce3bc5eab 100644 --- a/src/platform/Linux/bluez/Helper.cpp +++ b/src/platform/Linux/bluez/Helper.cpp @@ -1660,8 +1660,6 @@ static void SubscribeCharacteristicDone(GObject * aObject, GAsyncResult * aResul VerifyOrExit(success == TRUE, ChipLogError(DeviceLayer, "FAIL: BluezSubscribeCharacteristic : %s", error->message)); - // Get notifications on the TX characteristic change (e.g. indication is received) - g_signal_connect(c2, "g-properties-changed", G_CALLBACK(OnCharacteristicChanged), apConnection); BLEManagerImpl::HandleSubscribeOpComplete(static_cast(apConnection), true); exit: @@ -1671,9 +1669,13 @@ static void SubscribeCharacteristicDone(GObject * aObject, GAsyncResult * aResul static gboolean SubscribeCharacteristicImpl(BluezConnection * connection) { + BluezGattCharacteristic1 * c2 = nullptr; VerifyOrExit(connection != nullptr, ChipLogError(DeviceLayer, "BluezConnection is NULL in %s", __func__)); VerifyOrExit(connection->mpC2 != nullptr, ChipLogError(DeviceLayer, "C2 is NULL in %s", __func__)); + c2 = BLUEZ_GATT_CHARACTERISTIC1(connection->mpC2); + // 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); exit: