From a3b9ffd1a3b846d0bf6d5b208b06c10295b008be Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Tue, 15 Sep 2015 13:25:19 -0700 Subject: [PATCH] shared/gatt-client: enable notifications right after connecting Right now, if you re-connect to device that was previously registered in DBus, you can read and write it's characteristic without any error. Trying to register for notifications would however fail. This patch fixes that by making sure you can register for notifications before gatt_client is ready. It also re-register exising clients right after connection, not when gatt_client is ready. --- src/gatt-client.c | 12 ++++++------ src/shared/gatt-client.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gatt-client.c b/src/gatt-client.c index 225aa4277..399133a51 100644 --- a/src/gatt-client.c +++ b/src/gatt-client.c @@ -1838,12 +1838,6 @@ void btd_gatt_client_ready(struct btd_gatt_client *client) DBG("GATT client ready"); create_services(client); - - /* - * Services have already been created before. Re-enable notifications - * for any pre-registered notification sessions. - */ - queue_foreach(client->all_notify_clients, register_notify, client); } void btd_gatt_client_connected(struct btd_gatt_client *client) @@ -1860,6 +1854,12 @@ void btd_gatt_client_connected(struct btd_gatt_client *client) bt_gatt_client_unref(client->gatt); client->gatt = bt_gatt_client_ref(gatt); + + /* + * Services have already been created before. Re-enable notifications + * for any pre-registered notification sessions. + */ + queue_foreach(client->all_notify_clients, register_notify, client); } void btd_gatt_client_service_added(struct btd_gatt_client *client, diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index 098385298..d3e17e173 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -2989,7 +2989,7 @@ unsigned int bt_gatt_client_register_notify(struct bt_gatt_client *client, if (!client || !client->db || !chrc_value_handle || !callback) return 0; - if (!bt_gatt_client_is_ready(client) || client->in_svc_chngd) + if (client->in_svc_chngd) return 0; return register_notify(client, chrc_value_handle, callback, notify, -- 2.47.3