profiles: fix device info service triggering auto connect
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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
Luiz Augusto von Dentz
maintainerHi 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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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
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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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_connectflag and accept callback sobtd_device_add_attio_callbackis 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