From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 4/4] hog-lib: Fix not handling BT_ATT_OP_HANDLE_NFY_MULT
Date: Thu, 5 Jan 2023 14:09:44 -0800 [thread overview]
Message-ID: <20230105220944.2373424-4-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20230105220944.2373424-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This is a temporary fix for not handling BT_ATT_OP_HANDLE_NFY_MULT in
GAttr so the code will use g_attrib_attach_client to attach the
bt_gatt_client instance which is then used to register notifications
including those sent with BT_ATT_OP_HANDLE_NFY_MULT.
Fixes: https://github.com/bluez/bluez/issues/71
---
profiles/input/hog-lib.c | 23 +++++++++++++++++++++--
src/device.c | 1 +
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c
index 021db386f3b7..7ff1ede3db35 100644
--- a/profiles/input/hog-lib.c
+++ b/profiles/input/hog-lib.c
@@ -374,6 +374,15 @@ static void report_value_cb(const guint8 *pdu, guint16 len, gpointer user_data)
error("bt_uhid_send: %s (%d)", strerror(-err), -err);
}
+static void report_notify_destroy(void *user_data)
+{
+ struct report *report = user_data;
+
+ DBG("");
+
+ report->notifyid = 0;
+}
+
static void report_ccc_written_cb(guint8 status, const guint8 *pdu,
guint16 plen, gpointer user_data)
{
@@ -393,7 +402,13 @@ static void report_ccc_written_cb(guint8 status, const guint8 *pdu,
report->notifyid = g_attrib_register(hog->attrib,
ATT_OP_HANDLE_NOTIFY,
report->value_handle,
- report_value_cb, report, NULL);
+ report_value_cb, report,
+ report_notify_destroy);
+ if (!report->notifyid) {
+ error("Unable to register report notification: handle 0x%04x",
+ report->value_handle);
+ goto remove;
+ }
DBG("Report characteristic descriptor written: notifications enabled");
@@ -1798,7 +1813,11 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt)
r->notifyid = g_attrib_register(hog->attrib,
ATT_OP_HANDLE_NOTIFY,
r->value_handle,
- report_value_cb, r, NULL);
+ report_value_cb, r,
+ report_notify_destroy);
+ if (!r->notifyid)
+ error("Unable to register report notification: "
+ "handle 0x%04x", r->value_handle);
}
return true;
diff --git a/src/device.c b/src/device.c
index 995d39f2ccee..28b93eb9ac38 100644
--- a/src/device.c
+++ b/src/device.c
@@ -5152,6 +5152,7 @@ static void gatt_client_init(struct btd_device *device)
}
bt_gatt_client_set_debug(device->client, gatt_debug, NULL, NULL);
+ g_attrib_attach_client(device->attrib, device->client);
/*
* Notify notify existing service about the new connection so they can
--
2.37.3
next prev parent reply other threads:[~2023-01-05 22:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-05 22:09 [PATCH BlueZ 1/4] shared/gatt-client: Use parent debug_callback if not set on clone Luiz Augusto von Dentz
2023-01-05 22:09 ` [PATCH BlueZ 2/4] shared/gatt-client: Allow registering with NULL callback Luiz Augusto von Dentz
2023-01-05 22:09 ` [PATCH BlueZ 3/4] attrib: Introduce g_attrib_attach_client Luiz Augusto von Dentz
2023-01-05 22:09 ` Luiz Augusto von Dentz [this message]
2023-01-06 0:03 ` [BlueZ,1/4] shared/gatt-client: Use parent debug_callback if not set on clone bluez.test.bot
2023-01-06 0:11 ` Luiz Augusto von Dentz
2023-01-06 20:00 ` [PATCH BlueZ 1/4] " patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230105220944.2373424-4-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox