Thread (3 messages) flat view 3 messages, 3 authors, 2021-08-24

Re: [PATCH BlueZ] device: fix advertising data UUIDs ignored when Cache = yes

From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Date: 2021-08-24 22:37:01

Hi David,

On Tue, Aug 24, 2021 at 12:00 PM David Lechner [off-list ref] wrote:
quoted hunk ↗ jump to hunk
When [GATT] Cache = yes is set in configuration BlueZ does not use
cached UUIDs for the list of service UUIDs. However, it doesn't clear
the in-memory list of UUIDs received from advertising data, so when
a device is scanned, connected and disconnected, the internal state
still reflects that the UUIDs from the advertising data have already
been handled. device_add_eir_uuids() ignored the UUIDs from the
advertising data because both dev->le_state.svc_resolved == true and
dev->eir_uuids still contains the UUIDs from the previous scan session.

This fixes the issue by resetting both le_state.svc_resolved and
eir_uuids when the device is disconnected.

Issue: https://github.com/bluez/bluez/issues/192
Signed-off-by: David Lechner <david@lechnology.com>
---
 src/device.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff --git a/src/device.c b/src/device.c
index 807106812..48b9bd8d6 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3129,6 +3129,12 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type)

        device_update_last_seen(device, bdaddr_type);

+       if (!gatt_cache_is_enabled(device)) {
+               device->le_state.svc_resolved = false;
+               g_slist_free_full(device->eir_uuids, g_free);
+               device->eir_uuids = NULL;
+       }
We might want to cleanup the eir_uuid regardless of the cache being
enabled, since the next time the device advertise it may have
completely different UUIDs, as for resetting the svc_resolved Id guess
it would be better placed at gatt_cache_cleanup since that is clearing
the db it means should be cache left with should also set svc_resolved
= false.
        g_dbus_emit_property_changed(dbus_conn, device->path,
                                                DEVICE_INTERFACE, "Connected");

--
2.25.1

-- 
Luiz Augusto von Dentz
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help