From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [BlueZ RFC] profile: Add probe_on_discover flag
Date: Wed, 2 Aug 2023 13:15:38 -0700 [thread overview]
Message-ID: <20230802201538.584029-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds probe_on_discover flag which indicates if profile needs to be
probed when the remote_uuid is discovered and changes device logic to
attempt to probe driver when a new UUID is discovered and
probe_on_discover is set.
---
src/device.c | 22 +++++++++++++++++-----
src/profile.h | 5 +++++
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/src/device.c b/src/device.c
index b43ced8b5c91..19ae03f7d98a 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2156,7 +2156,7 @@ done:
void device_add_eir_uuids(struct btd_device *dev, GSList *uuids)
{
GSList *l;
- bool added = false;
+ GSList *added = NULL;
if (dev->bredr_state.svc_resolved || dev->le_state.svc_resolved)
return;
@@ -2165,13 +2165,11 @@ void device_add_eir_uuids(struct btd_device *dev, GSList *uuids)
const char *str = l->data;
if (g_slist_find_custom(dev->eir_uuids, str, bt_uuid_strcmp))
continue;
- added = true;
+ added = g_slist_append(added, (void *)str);
dev->eir_uuids = g_slist_append(dev->eir_uuids, g_strdup(str));
}
- if (added)
- g_dbus_emit_property_changed(dbus_conn, dev->path,
- DEVICE_INTERFACE, "UUIDs");
+ device_probe_profiles(dev, added);
}
static void add_manufacturer_data(void *data, void *user_data)
@@ -2201,6 +2199,7 @@ static void add_service_data(void *data, void *user_data)
struct eir_sd *sd = data;
struct btd_device *dev = user_data;
bt_uuid_t uuid;
+ GSList *l;
if (bt_string_to_uuid(&uuid, sd->uuid) < 0)
return;
@@ -2208,6 +2207,10 @@ static void add_service_data(void *data, void *user_data)
if (!bt_ad_add_service_data(dev->ad, &uuid, sd->data, sd->data_len))
return;
+ l = g_slist_append(NULL, sd->uuid);
+ device_add_eir_uuids(dev, l);
+ g_slist_free(l);
+
g_dbus_emit_property_changed(dbus_conn, dev->path,
DEVICE_INTERFACE, "ServiceData");
}
@@ -3930,6 +3933,12 @@ static bool device_match_profile(struct btd_device *device,
if (profile->remote_uuid == NULL)
return false;
+ /* Don't match if device was just discovered (not connected) and the
+ * profile don't have probe_on_discover flag set.
+ */
+ if (!btd_device_is_connected(device) && !profile->probe_on_discover)
+ return false;
+
if (g_slist_find_custom(uuids, profile->remote_uuid,
bt_uuid_strcmp) == NULL)
return false;
@@ -4884,6 +4893,9 @@ void device_probe_profiles(struct btd_device *device, GSList *uuids)
struct probe_data d = { device, uuids };
char addr[18];
+ if (!uuids)
+ return;
+
ba2str(&device->bdaddr, addr);
if (device->blocked) {
diff --git a/src/profile.h b/src/profile.h
index 6871f2f0d7d8..cfc50058812d 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -33,6 +33,11 @@ struct btd_profile {
*/
bool experimental;
+ /* Indicates the profile needs to be probed when the remote_uuid is
+ * discovered.
+ */
+ bool probe_on_discover;
+
int (*device_probe) (struct btd_service *service);
void (*device_remove) (struct btd_service *service);
--
2.41.0
next reply other threads:[~2023-08-02 20:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 20:15 Luiz Augusto von Dentz [this message]
2023-08-02 21:41 ` [BlueZ,RFC] profile: Add probe_on_discover flag bluez.test.bot
2023-08-09 17:20 ` [BlueZ RFC] " patchwork-bot+bluetooth
2023-08-09 18:31 ` Pauli Virtanen
2023-08-09 19:17 ` Luiz Augusto von Dentz
2023-08-09 19:39 ` Pauli Virtanen
2023-08-09 19:53 ` Luiz Augusto von Dentz
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=20230802201538.584029-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