shared/gatt-client: enable notifications right after connecting
PATCH 1/1 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(-)
src/gatt-client.c +6 -6
@@ -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,
src/shared/gatt-client.c +1 -1
@@ -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,
Signature · 1 line
2.5.0
Hi Jakub,
Quoted 55 lines · Jakub Pawlowski
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_clientis ready. It also re-register exising clients right after connection, not whengatt_clientis ready.--- src/gatt-client.c | 12 ++++++------ src/shared/gatt-client.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)src/gatt-client.c +6
-6@@ -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,src/shared/gatt-client.c +1
-2@@ -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, --
Quoted 1 line
2.5.0
Applied, thanks.
Signature · 1 line
Luiz Augusto von Dentz