Skip to contentSkip to conversation

profiles: fix device info service triggering auto connect

PATCH In review Jakub Pawlowski 2 participants 4 messages Oct 15, 2015 – Oct 22, 2015 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 profiles: fix device info service triggering auto connect

This patch makes sure that device info service is not triggering auto_connect.

---
 profiles/alert/server.c              | 2 +-
 profiles/cyclingspeed/cyclingspeed.c | 2 +-
 profiles/deviceinfo/deviceinfo.c     | 2 +-
 profiles/heartrate/heartrate.c       | 2 +-
 profiles/input/hog.c                 | 1 +
 profiles/proximity/immalert.c        | 2 +-
 profiles/proximity/linkloss.c        | 2 +-
 profiles/proximity/monitor.c         | 2 ++
 profiles/scanparam/scan.c            | 1 +
 profiles/thermometer/thermometer.c   | 2 +-
 src/attio.h                          | 1 +
 src/device.c                         | 4 +++-
 12 files changed, 15 insertions(+), 8 deletions(-)
profiles/alert/server.c +1 -1
index 2f6e3cd..9d102ef 100644
@@ -449,7 +449,7 @@ static void filter_devices_notify(struct btd_device *device, void *user_data)
 	cb->notify_data = notify_data;
 	cb->device = btd_device_ref(device);
 	cb->id = btd_device_add_attio_callback(device,
-						attio_connected_cb, NULL, cb);
+					attio_connected_cb, NULL, true, cb);
 }
 
 static void notify_devices(struct alert_adapter *al_adapter,
profiles/cyclingspeed/cyclingspeed.c +1 -1
index e447725..0cffa54 100644
@@ -1208,7 +1208,7 @@ static int csc_device_probe(struct btd_service *service)
 	cadapter->devices = g_slist_prepend(cadapter->devices, csc);
 
 	csc->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-						attio_disconnected_cb, csc);
+					attio_disconnected_cb, true, csc);
 
 	return 0;
 }
profiles/deviceinfo/deviceinfo.c +1 -1
index 6ee018c..10e5bd8 100644
@@ -172,7 +172,7 @@ static int deviceinfo_register(struct btd_service *service,
 	btd_service_set_user_data(service, d);
 
 	d->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-						attio_disconnected_cb, d);
+					attio_disconnected_cb, false, d);
 	return 0;
 }
 
profiles/heartrate/heartrate.c +1 -1
index 9e8c499..dcc599e 100644
@@ -784,7 +784,7 @@ static int heartrate_device_register(struct btd_device *device,
 	hradapter->devices = g_slist_prepend(hradapter->devices, hr);
 
 	hr->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-						attio_disconnected_cb, hr);
+					attio_disconnected_cb, true, hr);
 
 	return 0;
 }
profiles/input/hog.c +1 -0
index e006add..9e7939b 100644
@@ -949,6 +949,7 @@ static struct hog_device *hog_register_device(struct btd_device *device,
 	hogdev->attioid = btd_device_add_attio_callback(device,
 							attio_connected_cb,
 							attio_disconnected_cb,
+							true,
 							hogdev);
 
 	return hogdev;
profiles/proximity/immalert.c +1 -1
index 26a0ac9..37cf94a 100644
@@ -209,7 +209,7 @@ static uint8_t imm_alert_alert_lvl_write(struct attribute *a,
 		condev->device = btd_device_ref(device);
 		condev->adapter = ia;
 		condev->callback_id = btd_device_add_attio_callback(device,
-					NULL, imm_alert_disc_cb, condev);
+					NULL, imm_alert_disc_cb, true, condev);
 		ia->connected_devices = g_slist_append(ia->connected_devices,
 								condev);
 		DBG("added connected dev %p", device);
profiles/proximity/linkloss.c +1 -1
index 2f1ab13..edcfb7a 100644
@@ -254,7 +254,7 @@ static uint8_t link_loss_alert_lvl_write(struct attribute *a,
 		condev->device = btd_device_ref(device);
 		condev->adapter = la;
 		condev->callback_id = btd_device_add_attio_callback(device,
-					NULL, link_loss_disc_cb, condev);
+					NULL, link_loss_disc_cb, true, condev);
 		condev->local_disc_id = device_add_disconnect_watch(device,
 					link_loss_local_disc, condev, NULL);
 
profiles/proximity/monitor.c +2 -0
index a583eb7..da3fad8 100644
@@ -551,6 +551,7 @@ static void property_set_immediate_alert_level(
 		monitor->attioid = btd_device_add_attio_callback(device,
 							attio_connected_cb,
 							attio_disconnected_cb,
+							true,
 							monitor);
 	else if (monitor->attrib)
 		write_immediate_alert(monitor);
@@ -674,6 +675,7 @@ static void update_monitor(struct monitor *monitor)
 	monitor->attioid = btd_device_add_attio_callback(monitor->device,
 							attio_connected_cb,
 							attio_disconnected_cb,
+							true,
 							monitor);
 }
 
profiles/scanparam/scan.c +1 -0
index fbda8a8..7af671f 100644
@@ -219,6 +219,7 @@ static int scan_register(struct btd_service *service, struct gatt_primary *prim)
 	scan->attioid = btd_device_add_attio_callback(device,
 							attio_connected_cb,
 							attio_disconnected_cb,
+							true,
 							scan);
 
 	btd_service_set_user_data(service, scan);
profiles/thermometer/thermometer.c +1 -1
index b0fc3e0..f64ad5d 100644
@@ -1182,7 +1182,7 @@ static int thermometer_register(struct btd_device *device,
 	}
 
 	t->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-						attio_disconnected_cb, t);
+						attio_disconnected_cb, true, t);
 	return 0;
 }
 
src/attio.h +1 -0
index 16e2873..ff35f5a 100644
@@ -28,6 +28,7 @@ typedef void (*attio_disconnect_cb) (gpointer user_data);
 guint btd_device_add_attio_callback(struct btd_device *device,
 						attio_connect_cb cfunc,
 						attio_disconnect_cb dcfunc,
+						gboolean set_auto_connect,
 						gpointer user_data);
 
 gboolean btd_device_remove_attio_callback(struct btd_device *device, guint id);
src/device.c +3 -1
index fd177f4..625e8fd 100644
@@ -5990,6 +5990,7 @@ static gboolean notify_attios(gpointer user_data)
 guint btd_device_add_attio_callback(struct btd_device *device,
 						attio_connect_cb cfunc,
 						attio_disconnect_cb dcfunc,
+						gboolean set_auto_connect,
 						gpointer user_data)
 {
 	struct attio_data *attio;
@@ -6003,7 +6004,8 @@ guint btd_device_add_attio_callback(struct btd_device *device,
 	attio->dcfunc = dcfunc;
 	attio->user_data = user_data;
 
-	device_set_auto_connect(device, TRUE);
+	if (set_auto_connect)
+		device_set_auto_connect(device, TRUE);
 
 	/* Check if there is no GAttrib associated to the device created by a
 	 * incoming connection */
Signature · 1 line
2.5.0
#1 lore raw

ping ?

Quoted 189 lines · Jakub Pawlowski

This patch makes sure that device info service is not triggering auto_connect.

---
 profiles/alert/server.c              | 2 +-
 profiles/cyclingspeed/cyclingspeed.c | 2 +-
 profiles/deviceinfo/deviceinfo.c     | 2 +-
 profiles/heartrate/heartrate.c       | 2 +-
 profiles/input/hog.c                 | 1 +
 profiles/proximity/immalert.c        | 2 +-
 profiles/proximity/linkloss.c        | 2 +-
 profiles/proximity/monitor.c         | 2 ++
 profiles/scanparam/scan.c            | 1 +
 profiles/thermometer/thermometer.c   | 2 +-
 src/attio.h                          | 1 +
 src/device.c                         | 4 +++-
 12 files changed, 15 insertions(+), 8 deletions(-)
profiles/alert/server.c +1 -1
index 2f6e3cd..9d102ef 100644
@@ -449,7 +449,7 @@ static void filter_devices_notify(struct btd_device *device, void *user_data)
        cb->notify_data = notify_data;
        cb->device = btd_device_ref(device);
        cb->id = btd_device_add_attio_callback(device,
-                                               attio_connected_cb, NULL, cb);
+                                       attio_connected_cb, NULL, true, cb);
 }
 
 static void notify_devices(struct alert_adapter *al_adapter,
profiles/cyclingspeed/cyclingspeed.c +1 -1
index e447725..0cffa54 100644
@@ -1208,7 +1208,7 @@ static int csc_device_probe(struct btd_service *service)
        cadapter->devices = g_slist_prepend(cadapter->devices, csc);
 
        csc->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-                                               attio_disconnected_cb, csc);
+                                       attio_disconnected_cb, true, csc);
 
        return 0;
 }
profiles/deviceinfo/deviceinfo.c +1 -1
index 6ee018c..10e5bd8 100644
@@ -172,7 +172,7 @@ static int deviceinfo_register(struct btd_service *service,
        btd_service_set_user_data(service, d);
 
        d->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-                                               attio_disconnected_cb, d);
+                                       attio_disconnected_cb, false, d);
        return 0;
 }
 
profiles/heartrate/heartrate.c +1 -1
index 9e8c499..dcc599e 100644
@@ -784,7 +784,7 @@ static int heartrate_device_register(struct btd_device *device,
        hradapter->devices = g_slist_prepend(hradapter->devices, hr);
 
        hr->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-                                               attio_disconnected_cb, hr);
+                                       attio_disconnected_cb, true, hr);
 
        return 0;
 }
profiles/input/hog.c +1 -0
index e006add..9e7939b 100644
@@ -949,6 +949,7 @@ static struct hog_device *hog_register_device(struct btd_device *device,
        hogdev->attioid = btd_device_add_attio_callback(device,
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
+                                                       true,
                                                        hogdev);
 
        return hogdev;
profiles/proximity/immalert.c +1 -1
index 26a0ac9..37cf94a 100644
@@ -209,7 +209,7 @@ static uint8_t imm_alert_alert_lvl_write(struct attribute *a,
                condev->device = btd_device_ref(device);
                condev->adapter = ia;
                condev->callback_id = btd_device_add_attio_callback(device,
-                                       NULL, imm_alert_disc_cb, condev);
+                                       NULL, imm_alert_disc_cb, true, condev);
                ia->connected_devices = g_slist_append(ia->connected_devices,
                                                                condev);
                DBG("added connected dev %p", device);
profiles/proximity/linkloss.c +1 -1
index 2f1ab13..edcfb7a 100644
@@ -254,7 +254,7 @@ static uint8_t link_loss_alert_lvl_write(struct attribute *a,
                condev->device = btd_device_ref(device);
                condev->adapter = la;
                condev->callback_id = btd_device_add_attio_callback(device,
-                                       NULL, link_loss_disc_cb, condev);
+                                       NULL, link_loss_disc_cb, true, condev);
                condev->local_disc_id = device_add_disconnect_watch(device,
                                        link_loss_local_disc, condev, NULL);
 
profiles/proximity/monitor.c +2 -0
index a583eb7..da3fad8 100644
@@ -551,6 +551,7 @@ static void property_set_immediate_alert_level(
                monitor->attioid = btd_device_add_attio_callback(device,
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
+                                                       true,
                                                        monitor);
        else if (monitor->attrib)
                write_immediate_alert(monitor);
@@ -674,6 +675,7 @@ static void update_monitor(struct monitor *monitor)
        monitor->attioid = btd_device_add_attio_callback(monitor->device,
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
+                                                       true,
                                                        monitor);
 }
 
profiles/scanparam/scan.c +1 -0
index fbda8a8..7af671f 100644
@@ -219,6 +219,7 @@ static int scan_register(struct btd_service *service, struct gatt_primary *prim)
        scan->attioid = btd_device_add_attio_callback(device,
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
+                                                       true,
                                                        scan);
 
        btd_service_set_user_data(service, scan);
profiles/thermometer/thermometer.c +1 -1
index b0fc3e0..f64ad5d 100644
@@ -1182,7 +1182,7 @@ static int thermometer_register(struct btd_device *device,
        }
 
        t->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-                                               attio_disconnected_cb, t);
+                                               attio_disconnected_cb, true, t);
        return 0;
 }
 
src/attio.h +1 -0
index 16e2873..ff35f5a 100644
@@ -28,6 +28,7 @@ typedef void (*attio_disconnect_cb) (gpointer user_data);
 guint btd_device_add_attio_callback(struct btd_device *device,
                                                attio_connect_cb cfunc,
                                                attio_disconnect_cb dcfunc,
+                                               gboolean set_auto_connect,
                                                gpointer user_data);
 
 gboolean btd_device_remove_attio_callback(struct btd_device *device, guint id);
src/device.c +3 -2
index fd177f4..625e8fd 100644
@@ -5990,6 +5990,7 @@ static gboolean notify_attios(gpointer user_data)
 guint btd_device_add_attio_callback(struct btd_device *device,
                                                attio_connect_cb cfunc,
                                                attio_disconnect_cb dcfunc,
+                                               gboolean set_auto_connect,
                                                gpointer user_data)
 {
        struct attio_data *attio;
@@ -6003,7 +6004,8 @@ guint btd_device_add_attio_callback(struct btd_device *device,
        attio->dcfunc = dcfunc;
        attio->user_data = user_data;
 
-       device_set_auto_connect(device, TRUE);
+       if (set_auto_connect)
+               device_set_auto_connect(device, TRUE);
 
        /* Check if there is no GAttrib associated to the device created by a
         * incoming connection */
--

2.5.0

#2 lore raw

Hi Jakub,

Quoted 183 lines · Jakub Pawlowski

ping ?

Quoted 180 lines · Jakub Pawlowski

This patch makes sure that device info service is not triggering auto_connect.

---
 profiles/alert/server.c              | 2 +-
 profiles/cyclingspeed/cyclingspeed.c | 2 +-
 profiles/deviceinfo/deviceinfo.c     | 2 +-
 profiles/heartrate/heartrate.c       | 2 +-
 profiles/input/hog.c                 | 1 +
 profiles/proximity/immalert.c        | 2 +-
 profiles/proximity/linkloss.c        | 2 +-
 profiles/proximity/monitor.c         | 2 ++
 profiles/scanparam/scan.c            | 1 +
 profiles/thermometer/thermometer.c   | 2 +-
 src/attio.h                          | 1 +
 src/device.c                         | 4 +++-
 12 files changed, 15 insertions(+), 8 deletions(-)
profiles/alert/server.c +1 -1
index 2f6e3cd..9d102ef 100644
@@ -449,7 +449,7 @@ static void filter_devices_notify(struct btd_device *device, void *user_data)
        cb->notify_data = notify_data;
        cb->device = btd_device_ref(device);
        cb->id = btd_device_add_attio_callback(device,
-                                               attio_connected_cb, NULL, cb);
+                                       attio_connected_cb, NULL, true, cb);
 }
 
 static void notify_devices(struct alert_adapter *al_adapter,
profiles/cyclingspeed/cyclingspeed.c +1 -1
index e447725..0cffa54 100644
@@ -1208,7 +1208,7 @@ static int csc_device_probe(struct btd_service *service)
        cadapter->devices = g_slist_prepend(cadapter->devices, csc);
 
        csc->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-                                               attio_disconnected_cb, csc);
+                                       attio_disconnected_cb, true, csc);
 
        return 0;
 }
profiles/deviceinfo/deviceinfo.c +1 -1
index 6ee018c..10e5bd8 100644
@@ -172,7 +172,7 @@ static int deviceinfo_register(struct btd_service *service,
        btd_service_set_user_data(service, d);
 
        d->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-                                               attio_disconnected_cb, d);
+                                       attio_disconnected_cb, false, d);
        return 0;
 }
 
profiles/heartrate/heartrate.c +1 -1
index 9e8c499..dcc599e 100644
@@ -784,7 +784,7 @@ static int heartrate_device_register(struct btd_device *device,
        hradapter->devices = g_slist_prepend(hradapter->devices, hr);
 
        hr->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-                                               attio_disconnected_cb, hr);
+                                       attio_disconnected_cb, true, hr);
 
        return 0;
 }
profiles/input/hog.c +1 -0
index e006add..9e7939b 100644
@@ -949,6 +949,7 @@ static struct hog_device *hog_register_device(struct btd_device *device,
        hogdev->attioid = btd_device_add_attio_callback(device,
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
+                                                       true,
                                                        hogdev);
 
        return hogdev;
profiles/proximity/immalert.c +1 -1
index 26a0ac9..37cf94a 100644
@@ -209,7 +209,7 @@ static uint8_t imm_alert_alert_lvl_write(struct attribute *a,
                condev->device = btd_device_ref(device);
                condev->adapter = ia;
                condev->callback_id = btd_device_add_attio_callback(device,
-                                       NULL, imm_alert_disc_cb, condev);
+                                       NULL, imm_alert_disc_cb, true, condev);
                ia->connected_devices = g_slist_append(ia->connected_devices,
                                                                condev);
                DBG("added connected dev %p", device);
profiles/proximity/linkloss.c +1 -1
index 2f1ab13..edcfb7a 100644
@@ -254,7 +254,7 @@ static uint8_t link_loss_alert_lvl_write(struct attribute *a,
                condev->device = btd_device_ref(device);
                condev->adapter = la;
                condev->callback_id = btd_device_add_attio_callback(device,
-                                       NULL, link_loss_disc_cb, condev);
+                                       NULL, link_loss_disc_cb, true, condev);
                condev->local_disc_id = device_add_disconnect_watch(device,
                                        link_loss_local_disc, condev, NULL);
 
profiles/proximity/monitor.c +2 -0
index a583eb7..da3fad8 100644
@@ -551,6 +551,7 @@ static void property_set_immediate_alert_level(
                monitor->attioid = btd_device_add_attio_callback(device,
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
+                                                       true,
                                                        monitor);
        else if (monitor->attrib)
                write_immediate_alert(monitor);
@@ -674,6 +675,7 @@ static void update_monitor(struct monitor *monitor)
        monitor->attioid = btd_device_add_attio_callback(monitor->device,
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
+                                                       true,
                                                        monitor);
 }
 
profiles/scanparam/scan.c +1 -0
index fbda8a8..7af671f 100644
@@ -219,6 +219,7 @@ static int scan_register(struct btd_service *service, struct gatt_primary *prim)
        scan->attioid = btd_device_add_attio_callback(device,
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
+                                                       true,
                                                        scan);
 
        btd_service_set_user_data(service, scan);
profiles/thermometer/thermometer.c +1 -1
index b0fc3e0..f64ad5d 100644
@@ -1182,7 +1182,7 @@ static int thermometer_register(struct btd_device *device,
        }
 
        t->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-                                               attio_disconnected_cb, t);
+                                               attio_disconnected_cb, true, t);
        return 0;
 }
 
src/attio.h +1 -0
index 16e2873..ff35f5a 100644
@@ -28,6 +28,7 @@ typedef void (*attio_disconnect_cb) (gpointer user_data);
 guint btd_device_add_attio_callback(struct btd_device *device,
                                                attio_connect_cb cfunc,
                                                attio_disconnect_cb dcfunc,
+                                               gboolean set_auto_connect,
                                                gpointer user_data);
 
 gboolean btd_device_remove_attio_callback(struct btd_device *device, guint id);
src/device.c +1 -0
index fd177f4..625e8fd 100644
@@ -5990,6 +5990,7 @@ static gboolean notify_attios(gpointer user_data)
 guint btd_device_add_attio_callback(struct btd_device *device,
                                                attio_connect_cb cfunc,
                                                attio_disconnect_cb dcfunc,
+                                               gboolean set_auto_connect,
                                                gpointer user_data)
 {
        struct attio_data *attio;
@@ -6003,7 +6004,8 @@ guint btd_device_add_attio_callback(struct btd_device *device,
        attio->dcfunc = dcfunc;
        attio->user_data = user_data;
 
Quoted 8 lines
Quoted 8 lines
src/device.c +2 -2
-       device_set_auto_connect(device, TRUE);
+       if (set_auto_connect)
+               device_set_auto_connect(device, TRUE);
 
        /* Check if there is no GAttrib associated to the device created by a
         * incoming connection */
--

2.5.0

Actually the correct way to do it is to use the auto_connect flag and accept callback so btd_device_add_attio_callback is no longer called.

Signature · 1 line
Luiz Augusto von Dentz
#3 lore raw

Hi Luiz,

Quoted 190 lines · Luiz Augusto von Dentz

Hi Jakub,

Quoted 187 lines · Jakub Pawlowski

ping ?

Quoted 184 lines · Jakub Pawlowski

This patch makes sure that device info service is not triggering auto_connect.

---
 profiles/alert/server.c              | 2 +-
 profiles/cyclingspeed/cyclingspeed.c | 2 +-
 profiles/deviceinfo/deviceinfo.c     | 2 +-
 profiles/heartrate/heartrate.c       | 2 +-
 profiles/input/hog.c                 | 1 +
 profiles/proximity/immalert.c        | 2 +-
 profiles/proximity/linkloss.c        | 2 +-
 profiles/proximity/monitor.c         | 2 ++
 profiles/scanparam/scan.c            | 1 +
 profiles/thermometer/thermometer.c   | 2 +-
 src/attio.h                          | 1 +
 src/device.c                         | 4 +++-
 12 files changed, 15 insertions(+), 8 deletions(-)
profiles/alert/server.c +1 -1
index 2f6e3cd..9d102ef 100644
@@ -449,7 +449,7 @@ static void filter_devices_notify(struct btd_device *device, void *user_data)
        cb->notify_data = notify_data;
        cb->device = btd_device_ref(device);
        cb->id = btd_device_add_attio_callback(device,
-                                               attio_connected_cb, NULL, cb);
+                                       attio_connected_cb, NULL, true, cb);
 }
 
 static void notify_devices(struct alert_adapter *al_adapter,
profiles/cyclingspeed/cyclingspeed.c +1 -1
index e447725..0cffa54 100644
@@ -1208,7 +1208,7 @@ static int csc_device_probe(struct btd_service *service)
        cadapter->devices = g_slist_prepend(cadapter->devices, csc);
 
        csc->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-                                               attio_disconnected_cb, csc);
+                                       attio_disconnected_cb, true, csc);
 
        return 0;
 }
profiles/deviceinfo/deviceinfo.c +1 -1
index 6ee018c..10e5bd8 100644
@@ -172,7 +172,7 @@ static int deviceinfo_register(struct btd_service *service,
        btd_service_set_user_data(service, d);
 
        d->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-                                               attio_disconnected_cb, d);
+                                       attio_disconnected_cb, false, d);
        return 0;
 }
 
profiles/heartrate/heartrate.c +1 -1
index 9e8c499..dcc599e 100644
@@ -784,7 +784,7 @@ static int heartrate_device_register(struct btd_device *device,
        hradapter->devices = g_slist_prepend(hradapter->devices, hr);
 
        hr->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-                                               attio_disconnected_cb, hr);
+                                       attio_disconnected_cb, true, hr);
 
        return 0;
 }
profiles/input/hog.c +1 -0
index e006add..9e7939b 100644
@@ -949,6 +949,7 @@ static struct hog_device *hog_register_device(struct btd_device *device,
        hogdev->attioid = btd_device_add_attio_callback(device,
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
+                                                       true,
                                                        hogdev);
 
        return hogdev;
profiles/proximity/immalert.c +1 -1
index 26a0ac9..37cf94a 100644
@@ -209,7 +209,7 @@ static uint8_t imm_alert_alert_lvl_write(struct attribute *a,
                condev->device = btd_device_ref(device);
                condev->adapter = ia;
                condev->callback_id = btd_device_add_attio_callback(device,
-                                       NULL, imm_alert_disc_cb, condev);
+                                       NULL, imm_alert_disc_cb, true, condev);
                ia->connected_devices = g_slist_append(ia->connected_devices,
                                                                condev);
                DBG("added connected dev %p", device);
profiles/proximity/linkloss.c +1 -1
index 2f1ab13..edcfb7a 100644
@@ -254,7 +254,7 @@ static uint8_t link_loss_alert_lvl_write(struct attribute *a,
                condev->device = btd_device_ref(device);
                condev->adapter = la;
                condev->callback_id = btd_device_add_attio_callback(device,
-                                       NULL, link_loss_disc_cb, condev);
+                                       NULL, link_loss_disc_cb, true, condev);
                condev->local_disc_id = device_add_disconnect_watch(device,
                                        link_loss_local_disc, condev, NULL);
 
profiles/proximity/monitor.c +2 -0
index a583eb7..da3fad8 100644
@@ -551,6 +551,7 @@ static void property_set_immediate_alert_level(
                monitor->attioid = btd_device_add_attio_callback(device,
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
+                                                       true,
                                                        monitor);
        else if (monitor->attrib)
                write_immediate_alert(monitor);
@@ -674,6 +675,7 @@ static void update_monitor(struct monitor *monitor)
        monitor->attioid = btd_device_add_attio_callback(monitor->device,
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
+                                                       true,
                                                        monitor);
 }
 
profiles/scanparam/scan.c +1 -0
index fbda8a8..7af671f 100644
@@ -219,6 +219,7 @@ static int scan_register(struct btd_service *service, struct gatt_primary *prim)
        scan->attioid = btd_device_add_attio_callback(device,
                                                        attio_connected_cb,
                                                        attio_disconnected_cb,
+                                                       true,
                                                        scan);
 
        btd_service_set_user_data(service, scan);
profiles/thermometer/thermometer.c +1 -1
index b0fc3e0..f64ad5d 100644
@@ -1182,7 +1182,7 @@ static int thermometer_register(struct btd_device *device,
        }
 
        t->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
-                                               attio_disconnected_cb, t);
+                                               attio_disconnected_cb, true, t);
        return 0;
 }
 
src/attio.h +1 -0
index 16e2873..ff35f5a 100644
@@ -28,6 +28,7 @@ typedef void (*attio_disconnect_cb) (gpointer user_data);
 guint btd_device_add_attio_callback(struct btd_device *device,
                                                attio_connect_cb cfunc,
                                                attio_disconnect_cb dcfunc,
+                                               gboolean set_auto_connect,
                                                gpointer user_data);
 
 gboolean btd_device_remove_attio_callback(struct btd_device *device, guint id);
src/device.c +3 -1
index fd177f4..625e8fd 100644
@@ -5990,6 +5990,7 @@ static gboolean notify_attios(gpointer user_data)
 guint btd_device_add_attio_callback(struct btd_device *device,
                                                attio_connect_cb cfunc,
                                                attio_disconnect_cb dcfunc,
+                                               gboolean set_auto_connect,
                                                gpointer user_data)
 {
        struct attio_data *attio;
@@ -6003,7 +6004,8 @@ guint btd_device_add_attio_callback(struct btd_device *device,
        attio->dcfunc = dcfunc;
        attio->user_data = user_data;
 
-       device_set_auto_connect(device, TRUE);
+       if (set_auto_connect)
+               device_set_auto_connect(device, TRUE);
 
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
src/device.c +0 -1
        /* Check if there is no GAttrib associated to the device created by a
         * incoming connection */
--

2.5.0

Actually the correct way to do it is to use the auto_connect flag and accept callback so btd_device_add_attio_callback is no longer called.

I re-wrote deviceinfo profile (made it just like gap is), please check if that's what you wanted. If yes I will rewrite rest of profiles same way to make sure they don't triger autoconnect unnecessary (except for Heart Rate, you mentioned it should be done as external profile)

Quoted 4 lines

--
Luiz Augusto von Dentz