summaryrefslogtreecommitdiff
path: root/src/device.c
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2023-02-23 19:14:44 +0000
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2023-02-23 12:50:36 -0800
commit46a5d2beccb2ea73f28502950f52032cf4811d37 (patch)
tree1ef45e88987182233ef9f63a35d6a51fb26ad305 /src/device.c
parent1106b28be85ac9586d1758839226e163e9030ee2 (diff)
downloadbluez-46a5d2beccb2ea73f28502950f52032cf4811d37.tar.gz
device: wait GATT client ready before service accept() if no cache
On device ATT attach, do not immediately call accept() for profiles, if there is no cached data in GATT database. Instead, wait for service resolution to complete, as likely accept() cannot succeed before that. Several profiles (bap, vcp, midi, deviceinfo) assume that GATT attributes are available when their accept() is called, returning success even if not. In this case, the services never find the remote attributes and are not operable. Other profiles (hog, batt, ...) fail their accept which prompts core to retry after discovery, and work correctly also in this case. Fix the failing services by waiting for service resolution as necessary, so profiles can assume the GATT DB has some content.
Diffstat (limited to 'src/device.c')
-rw-r--r--src/device.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/device.c b/src/device.c
index 28b93eb9a..d270421cc 100644
--- a/src/device.c
+++ b/src/device.c
@@ -5155,10 +5155,11 @@ static void gatt_client_init(struct btd_device *device)
g_attrib_attach_client(device->attrib, device->client);
/*
- * Notify notify existing service about the new connection so they can
- * react to notifications while discovering services
+ * If we have cache, notify existing service about the new connection
+ * so they can react to notifications while discovering services
*/
- device_accept_gatt_profiles(device);
+ if (!gatt_db_isempty(device->db))
+ device_accept_gatt_profiles(device);
device->gatt_ready_id = bt_gatt_client_ready_register(device->client,
gatt_client_ready_cb,