From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1] gatt-client: Fix warnings when reconnecting
Date: Fri, 24 Jan 2025 15:57:00 -0500 [thread overview]
Message-ID: <20250124205700.511446-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When reconnecting warnings could be seen due to services already
existing which is a new behavior introduced by dbd6591bd1d0
("main.conf: Add GATT.ExportClaimedServices").
---
src/gatt-client.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/src/gatt-client.c b/src/gatt-client.c
index 6f22bbb490a7..da7c16fc14af 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -1968,12 +1968,33 @@ static void service_free(void *data)
free(service);
}
+static bool match_service_handle(const void *a, const void *b)
+{
+ const struct service *service = a;
+ uint16_t start_handle = PTR_TO_UINT(b);
+
+ return service->start_handle == start_handle;
+}
+
static struct service *service_create(struct gatt_db_attribute *attr,
struct btd_gatt_client *client)
{
struct service *service;
const char *device_path = device_get_path(client->device);
bt_uuid_t uuid;
+ uint16_t start_handle, end_handle;
+ bool primary;
+
+ gatt_db_attribute_get_service_data(attr, &start_handle,
+ &end_handle,
+ &primary,
+ &uuid);
+
+ /* Check if service is already on list then return NULL to skip it */
+ service = queue_find(client->services, match_service_handle,
+ UINT_TO_PTR(start_handle));
+ if (service)
+ return NULL;
service = new0(struct service, 1);
service->chrcs = queue_new();
@@ -2146,14 +2167,6 @@ static void export_service(struct gatt_db_attribute *attr, void *user_data)
queue_push_tail(client->services, service);
}
-static bool match_service_handle(const void *a, const void *b)
-{
- const struct service *service = a;
- uint16_t start_handle = PTR_TO_UINT(b);
-
- return service->start_handle == start_handle;
-}
-
struct update_incl_data {
struct service *service;
bool changed;
--
2.48.1
next reply other threads:[~2025-01-24 20:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-24 20:57 Luiz Augusto von Dentz [this message]
2025-01-24 22:08 ` [BlueZ,v1] gatt-client: Fix warnings when reconnecting bluez.test.bot
2025-01-27 15:10 ` [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=20250124205700.511446-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