From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1] gatt-database: Fix sending notification to all devices
Date: Thu, 18 Apr 2024 15:47:23 -0400 [thread overview]
Message-ID: <20240418194723.1440686-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If notifications where setup with GATT application that implements
AcquireNotify the code will attempt to setup a dedicate fd/io for each
device so when receiving a notification over the fd/io it is only meant
to be send to the device only.
Fixes: https://github.com/bluez/bluez/issues/820
---
src/gatt-database.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/gatt-database.c b/src/gatt-database.c
index 6c11027a79ed..7ca2f94222c6 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -112,6 +112,7 @@ struct external_profile {
struct client_io {
struct bt_att *att;
+ struct external_chrc *chrc;
unsigned int disconn_id;
struct io *io;
};
@@ -2588,7 +2589,8 @@ static bool sock_hup(struct io *io, void *user_data)
static bool sock_io_read(struct io *io, void *user_data)
{
- struct external_chrc *chrc = user_data;
+ struct client_io *client = user_data;
+ struct external_chrc *chrc = client->chrc;
uint8_t buf[512];
int fd = io_get_fd(io);
ssize_t bytes_read;
@@ -2597,12 +2599,8 @@ static bool sock_io_read(struct io *io, void *user_data)
if (bytes_read <= 0)
return false;
- send_notification_to_devices(chrc->service->app->database,
- gatt_db_attribute_get_handle(chrc->attrib),
- buf, bytes_read,
- gatt_db_attribute_get_handle(chrc->ccc),
- conf_cb,
- chrc->proxy);
+ gatt_notify_cb(chrc->attrib, chrc->ccc, buf, bytes_read, client->att,
+ client->chrc->service->app->database);
return true;
}
@@ -2652,6 +2650,7 @@ client_io_new(struct external_chrc *chrc, int fd, struct bt_att *att)
client = new0(struct client_io, 1);
client->att = bt_att_ref(att);
+ client->chrc = chrc;
client->disconn_id = bt_att_register_disconnect(att, att_disconnect_cb,
client, NULL);
client->io = sock_io_new(fd, chrc);
@@ -2809,7 +2808,7 @@ client_notify_io_get(struct external_chrc *chrc, int fd, struct bt_att *att)
client = client_io_new(chrc, fd, att);
- io_set_read_handler(client->io, sock_io_read, chrc, NULL);
+ io_set_read_handler(client->io, sock_io_read, client, NULL);
if (!chrc->notify_ios)
chrc->notify_ios = queue_new();
--
2.44.0
next reply other threads:[~2024-04-18 19:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-18 19:47 Luiz Augusto von Dentz [this message]
2024-04-18 21:43 ` [BlueZ,v1] gatt-database: Fix sending notification to all devices bluez.test.bot
2024-04-22 15:40 ` [PATCH BlueZ v1] " 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=20240418194723.1440686-1-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