[PATCH BlueZ v1 2/2] device: Consider service state on device_is_connected

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

This checks if there is any service connected on device_is_connected
since some profiles maybe probed using advertising data which doesn't
require a connection.
---
 src/device.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/device.c b/src/device.c
index 1db96d9a672c..e5191cabe81a 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3225,7 +3225,11 @@ uint8_t btd_device_get_bdaddr_type(struct btd_device *dev)
 
 bool btd_device_is_connected(struct btd_device *dev)
 {
-	return dev->bredr_state.connected || dev->le_state.connected;
+	if (dev->bredr_state.connected || dev->le_state.connected)
+		return true;
+
+	return find_service_with_state(dev->services,
+						BTD_SERVICE_STATE_CONNECTED);
 }
 
 static void clear_temporary_timer(struct btd_device *dev)
@@ -3276,6 +3280,13 @@ static bool device_disappeared(gpointer user_data)
 {
 	struct btd_device *dev = user_data;
 
+	if (btd_device_is_connected(dev)) {
+		char addr[18];
+		ba2str(&dev->bdaddr, addr);
+		DBG("Device %s is marked as connected", dev->path);
+		return TRUE;
+	}
+
 	/* If there are services connecting restart the timer to give more time
 	 * for the service to either complete the connection or disconnect.
 	 */
-- 
2.43.0





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux