From 45b61a10bd0af9b0b13f508166369eb1138ae448 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 26 Mar 2025 11:40:29 -0400 Subject: [PATCH] device: Use btd_device_is_initiator instead of Connect message Device.Connect message is not the only way to initiate a connection as there is also the likes of Device.Pair which will initiate bonding, so this incorporate the bonding check into btd_device_is_initiator and replaces the checks of were Connect message was used to determine if initiator to use btd_device_is_initiator. --- src/device.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/device.c b/src/device.c index 6a6c379fc..034491b59 100644 --- a/src/device.c +++ b/src/device.c @@ -320,6 +320,8 @@ bool btd_device_is_initiator(struct btd_device *dev) return dev->le_state.initiator; else if (dev->bredr_state.connected) return dev->bredr_state.initiator; + else if (dev->bonding) + return true; return dev->att_io ? true : false; } @@ -5780,11 +5782,12 @@ static void gatt_client_init(struct btd_device *device) gatt_client_cleanup(device); - if (!device->connect && !btd_opts.reverse_discovery) { + if (!btd_device_is_initiator(device) && !btd_opts.reverse_discovery) { DBG("Reverse service discovery disabled: skipping GATT client"); return; } - if (!device->connect && !btd_opts.gatt_client) { + + if (!btd_device_is_initiator(device) && !btd_opts.gatt_client) { DBG("GATT client disabled: skipping GATT client"); return; } @@ -5834,7 +5837,7 @@ static void gatt_client_init(struct btd_device *device) * it shall be triggered only when ready to avoid possible clashes where * both sides attempt to connection at same time. */ - if (device->connect) + if (btd_device_is_initiator(device)) btd_gatt_client_eatt_connect(device->client_dbus); } -- 2.47.3