Skip to contentSkip to conversation

core/gatt: Fix not setting auto connect flag

PATCH Applied Luiz Augusto von Dentz 1 participant 2 messages Sep 1, 2015 – Sep 2, 2015 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/1 core/gatt: Fix not setting auto connect flag

From: Luiz Augusto von Dentz <[email protected]>

Profiles registered via org.bluez.GattManager1.RegisterProfile shall properly register a driver and cause the device to be marked to auto connect if the device supports the UUID given.

---
 src/device.c        | 14 ++++++++++++--
 src/gatt-database.c |  2 ++
 2 files changed, 14 insertions(+), 2 deletions(-)
src/device.c +12 -2
index 3dde8b8..bdea55b 100644
@@ -2841,10 +2841,20 @@ static void dev_probe_gatt(struct btd_profile *p, void *user_data)
 	struct gatt_probe_data *data = user_data;
 	struct btd_service *service;
 
-	if (p->device_probe == NULL)
+	if (!p->remote_uuid || bt_uuid_strcmp(p->remote_uuid, data->cur_uuid))
 		return;
 
-	if (!p->remote_uuid || bt_uuid_strcmp(p->remote_uuid, data->cur_uuid))
+	/*
+	 * Add device to auto connect list in case the driver has the auto
+	 * connect flag set.
+	 * NOTE: This should work regardless if a service is created and
+	 * probed since external drivers don't need to maintain any
+	 * states they don't implement device_probe callback.
+	 */
+	if (p->auto_connect)
+		device_set_auto_connect(data->dev, TRUE);
+
+	if (p->device_probe == NULL)
 		return;
 
 	service = service_create(data->dev, p);
src/gatt-database.c +2 -0
index 91aba2f..97cef77 100644
@@ -383,6 +383,7 @@ static void profile_remove(void *data)
 	DBG("Removed \"%s\"", p->name);
 
 	adapter_foreach(adapter_remove_profile, p);
+	btd_profile_unregister(p);
 
 	g_free((void *) p->name);
 	g_free((void *) p->remote_uuid);
@@ -2314,6 +2315,7 @@ static void add_profile(void *data, void *user_data)
 {
 	struct btd_adapter *adapter = user_data;
 
+	btd_profile_register(data);
 	adapter_add_profile(adapter, data);
 }
 
Signature · 1 line
2.4.3
author maintainer Applied
#1 lore raw

Hi,

Quoted 58 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

Profiles registered via org.bluez.GattManager1.RegisterProfile shall properly register a driver and cause the device to be marked to auto connect if the device supports the UUID given.

---
 src/device.c        | 14 ++++++++++++--
 src/gatt-database.c |  2 ++
 2 files changed, 14 insertions(+), 2 deletions(-)
src/device.c +12 -2
index 3dde8b8..bdea55b 100644
@@ -2841,10 +2841,20 @@ static void dev_probe_gatt(struct btd_profile *p, void *user_data)
        struct gatt_probe_data *data = user_data;
        struct btd_service *service;
 
-       if (p->device_probe == NULL)
+       if (!p->remote_uuid || bt_uuid_strcmp(p->remote_uuid, data->cur_uuid))
                return;
 
-       if (!p->remote_uuid || bt_uuid_strcmp(p->remote_uuid, data->cur_uuid))
+       /*
+        * Add device to auto connect list in case the driver has the auto
+        * connect flag set.
+        * NOTE: This should work regardless if a service is created and
+        * probed since external drivers don't need to maintain any
+        * states they don't implement device_probe callback.
+        */
+       if (p->auto_connect)
+               device_set_auto_connect(data->dev, TRUE);
+
+       if (p->device_probe == NULL)
                return;
 
        service = service_create(data->dev, p);
src/gatt-database.c +2 -1
index 91aba2f..97cef77 100644
@@ -383,6 +383,7 @@ static void profile_remove(void *data)
        DBG("Removed \"%s\"", p->name);
 
        adapter_foreach(adapter_remove_profile, p);
+       btd_profile_unregister(p);
 
        g_free((void *) p->name);
        g_free((void *) p->remote_uuid);
@@ -2314,6 +2315,7 @@ static void add_profile(void *data, void *user_data)
 {
        struct btd_adapter *adapter = user_data;
 
+       btd_profile_register(data);
        adapter_add_profile(adapter, data);
 }
 
--
Quoted 1 line

2.4.3

Applied.

Signature · 1 line
Luiz Augusto von Dentz