summaryrefslogtreecommitdiff
path: root/profiles/scanparam
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2016-09-08 15:28:54 +0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2016-09-08 15:28:54 +0300
commit212b7d44f62b52b4f40b42964706fe9a1916fdb0 (patch)
tree03e6d653495c7c3101188833fcfdbad0936b4347 /profiles/scanparam
parente78cda3b97f9a64db1ca748947acb67f6948c4e2 (diff)
downloadbluez-212b7d44f62b52b4f40b42964706fe9a1916fdb0.tar.gz
scanparam: Implement disconnect callback
This implements the profile disconnect callback using it to cleanup existing references of bt_gatt_client and gatt_db.
Diffstat (limited to 'profiles/scanparam')
-rw-r--r--profiles/scanparam/scan.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/profiles/scanparam/scan.c b/profiles/scanparam/scan.c
index f8ad8105e..0ff4a4374 100644
--- a/profiles/scanparam/scan.c
+++ b/profiles/scanparam/scan.c
@@ -165,6 +165,15 @@ static void foreach_scan_param_service(struct gatt_db_attribute *attr,
gatt_db_service_foreach_char(scan->attr, handle_characteristic, scan);
}
+static void scan_reset(struct scan *scan)
+{
+ scan->attr = NULL;
+ gatt_db_unref(scan->db);
+ scan->db = NULL;
+ bt_gatt_client_unref(scan->client);
+ scan->client = NULL;
+}
+
static int scan_param_accept(struct btd_service *service)
{
struct btd_device *device = btd_service_get_device(service);
@@ -182,11 +191,6 @@ static int scan_param_accept(struct btd_service *service)
return -1;
}
- /* Clean-up any old client/db and acquire the new ones */
- scan->attr = NULL;
- gatt_db_unref(scan->db);
- bt_gatt_client_unref(scan->client);
-
scan->db = gatt_db_ref(db);
scan->client = bt_gatt_client_ref(client);
@@ -196,10 +200,7 @@ static int scan_param_accept(struct btd_service *service)
if (!scan->attr) {
error("Scan Parameters attribute not found");
- gatt_db_unref(scan->db);
- scan->db = NULL;
- bt_gatt_client_unref(scan->client);
- scan->client = NULL;
+ scan_reset(scan);
return -1;
}
@@ -208,6 +209,17 @@ static int scan_param_accept(struct btd_service *service)
return 0;
}
+static int scan_param_disconnect(struct btd_service *service)
+{
+ struct scan *scan = btd_service_get_user_data(service);
+
+ scan_reset(scan);
+
+ btd_service_disconnecting_complete(service, 0);
+
+ return 0;
+}
+
static void scan_param_remove(struct btd_service *service)
{
struct btd_device *device = btd_service_get_device(service);
@@ -257,6 +269,7 @@ static struct btd_profile scan_profile = {
.device_probe = scan_param_probe,
.device_remove = scan_param_remove,
.accept = scan_param_accept,
+ .disconnect = scan_param_disconnect,
};
static int scan_param_init(void)