core/gatt-client: Don't read extended properties
Luiz Augusto von Dentz
maintainerPATCH 1/4 core/gatt-client: Don't read extended properties
From: Luiz Augusto von Dentz <[email protected]>
Extended properties are already read and stored in the database and can be retrieved with gatt_db_attribute_get_char_data.
--- src/gatt-client.c | 55 +++---------------------------------------------------- 1 file changed, 3 insertions(+), 52 deletions(-)
src/gatt-client.c +3 -52
@@ -71,7 +71,6 @@ struct service {bt_uuid_t uuid;char *path;struct queue *chrcs; -struct queue *pending_ext_props; };struct characteristic {
@@ -1283,7 +1282,8 @@ static struct characteristic *characteristic_create(gatt_db_attribute_get_char_data (attr, &chrc->handle, &chrc->value_handle, - &chrc->props,NULL , + &chrc->props, + &chrc->ext_props, &uuid); chrc->attr = gatt_db_get_attribute(service->client->db,
@@ -1398,7 +1398,6 @@ static void service_free(void *data)struct service *service = data;queue_destroy (service->chrcs,NULL );/* List should be empty here */ -queue_destroy (service->pending_ext_props,NULL );g_free (service->path);free (service); }
@@ -1412,7 +1411,6 @@ static struct service *service_create(struct gatt_db_attribute *attr, service = new0(struct service, 1); service->chrcs =queue_new (); - service->pending_ext_props =queue_new (); service->client = client; gatt_db_attribute_get_service_data(attr, &service->start_handle,
@@ -1484,44 +1482,6 @@ static void export_desc(struct gatt_db_attribute *attr, void *user_data)queue_push_tail (charac->descs, desc); } -static void read_ext_props_cb (bool success,uint8_t att_ecode, -const uint8_t *value,uint16_t length, -void *user_data) -{ -struct characteristic *chrc = user_data; -struct service *service = chrc->service; - -if (!success) { -error ("Failed to obtain extended properties - error: 0x%02x" , - att_ecode); -return ; - } - -if (!value || length !=2 ) { -error ("Malformed extended properties value" ); -return ; - } - - chrc->ext_props =get_le16 (value); -if (chrc->ext_props) -g_dbus_emit_property_changed (btd_get_dbus_connection (), - chrc->path, -GATT_CHARACTERISTIC_IFACE , -"Flags" ); - -queue_remove (service->pending_ext_props, chrc); -} - -static void read_ext_props (void *data,void *user_data) -{ -struct characteristic *chrc = data; - -bt_gatt_client_read_value (chrc->service->client->gatt, - chrc->ext_props_handle, - read_ext_props_cb, - chrc,NULL ); -} -static bool create_descriptors (struct gatt_db_attribute *attr,struct characteristic *charac) {
@@ -1555,9 +1515,6 @@ static void export_char(struct gatt_db_attribute *attr, void *user_data)queue_push_tail (service->chrcs, charac); -if (charac->ext_props_handle) -queue_push_tail (service->pending_ext_props, charac); -return ; fail:
@@ -1574,13 +1531,7 @@ static bool create_characteristics(struct gatt_db_attribute *attr,gatt_db_service_foreach_char (attr, export_char, &data); -if (data.failed) -return false; - -/* Obtain extended properties */ -queue_foreach (service->pending_ext_props, read_ext_props,NULL ); - -return true; +return !data.failed; }static void export_service (struct gatt_db_attribute *attr,void *user_data)
Signature · 1 line
2.5.5
Luiz Augusto von Dentz
maintainerPATCH 2/4 core/device: Remove code related to GattServices
From: Luiz Augusto von Dentz <[email protected]>
GattService has been removed so there shouldn't be any code related to it
--- src/device.c | 3 --- 1 file changed, 3 deletions(-)
src/device.c +0 -3
@@ -3366,9 +3366,6 @@ static gboolean gatt_services_changed(gpointer user_data)store_gatt_db (device); -g_dbus_emit_property_changed (dbus_conn, device->path,DEVICE_INTERFACE , -"GattServices" ); -return FALSE; }
Signature · 1 line
2.5.5
Luiz Augusto von Dentz
maintainerPATCH 3/4 core/device: Fix not storing GATT attributes
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
If services has been refreshed the attributes shall be stored so they can be reloaded properly the next time.
--- src/device.c | 2 ++ 1 file changed, 2 insertions(+)
src/device.c +2 -0
@@ -4576,6 +4576,8 @@ static void gatt_client_ready_cb(bool success, uint8_t att_ecode,btd_gatt_client_ready (device->client_dbus);device_svc_resolved (device, device->bdaddr_type,0 ); + +store_gatt_db (device); } static void gatt_client_service_changed(uint16_t start_handle,
Signature · 1 line
2.5.5
Luiz Augusto von Dentz
maintainerPATCH 4/4 doc/settings-storage: Add alternative format for descriptors
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
In case of some descriptors like CEP we must store the actual value since extended properties are not part of the discovery and btd_gatt_client no longer attempt to read it the value must be loaded in the db so gatt_db_attribute_get_char_data is able to retrieve it.
--- doc/settings-storage.txt | 1 + src/device.c | 49 +++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 43 insertions(+), 7 deletions(-)
doc/settings-storage.txt +1 -0
@@ -175,6 +175,7 @@ how to interpret rest of value: 2803:value_handle:properties:uuid Descriptor: + value:uuid uuid Sample Attributes section:
src/device.c +42 -7
98 lines not on this page · raw message
Signature · 1 line
2.5.5
Hi,
Quoted 117 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
Extended properties are already read and stored in the database and can be retrieved with
gatt_db_attribute_get_char_data.--- src/gatt-client.c | 55 +++---------------------------------------------------- 1 file changed, 3 insertions(+), 52 deletions(-)src/gatt-client.c +3
-53@@ -71,7 +71,6 @@ struct service {bt_uuid_t uuid;char *path;struct queue *chrcs; -struct queue *pending_ext_props; };struct characteristic {@@ -1283,7 +1282,8 @@ static struct characteristic *characteristic_create(gatt_db_attribute_get_char_data (attr, &chrc->handle, &chrc->value_handle, - &chrc->props,NULL , + &chrc->props, + &chrc->ext_props, &uuid); chrc->attr = gatt_db_get_attribute(service->client->db,@@ -1398,7 +1398,6 @@ static void service_free(void *data)struct service *service = data;queue_destroy (service->chrcs,NULL );/* List should be empty here */ -queue_destroy (service->pending_ext_props,NULL );g_free (service->path);free (service); }@@ -1412,7 +1411,6 @@ static struct service *service_create(struct gatt_db_attribute *attr, service = new0(struct service, 1); service->chrcs =queue_new (); - service->pending_ext_props =queue_new (); service->client = client; gatt_db_attribute_get_service_data(attr, &service->start_handle,@@ -1484,44 +1482,6 @@ static void export_desc(struct gatt_db_attribute *attr, void *user_data)queue_push_tail (charac->descs, desc); } -static void read_ext_props_cb (bool success,uint8_t att_ecode, -const uint8_t *value,uint16_t length, -void *user_data) -{ -struct characteristic *chrc = user_data; -struct service *service = chrc->service; - -if (!success) { -error ("Failed to obtain extended properties - error: 0x%02x" , - att_ecode); -return ; - } - -if (!value || length !=2 ) { -error ("Malformed extended properties value" ); -return ; - } - - chrc->ext_props =get_le16 (value); -if (chrc->ext_props) -g_dbus_emit_property_changed (btd_get_dbus_connection (), - chrc->path, -GATT_CHARACTERISTIC_IFACE , -"Flags" ); - -queue_remove (service->pending_ext_props, chrc); -} - -static void read_ext_props (void *data,void *user_data) -{ -struct characteristic *chrc = data; - -bt_gatt_client_read_value (chrc->service->client->gatt, - chrc->ext_props_handle, - read_ext_props_cb, - chrc,NULL ); -} -static bool create_descriptors (struct gatt_db_attribute *attr,struct characteristic *charac) {@@ -1555,9 +1515,6 @@ static void export_char(struct gatt_db_attribute *attr, void *user_data)queue_push_tail (service->chrcs, charac); -if (charac->ext_props_handle) -queue_push_tail (service->pending_ext_props, charac); -return ; fail:@@ -1574,13 +1531,7 @@ static bool create_characteristics(struct gatt_db_attribute *attr,gatt_db_service_foreach_char (attr, export_char, &data); -if (data.failed) -return false; - -/* Obtain extended properties */ -queue_foreach (service->pending_ext_props, read_ext_props,NULL ); - -return true; +return !data.failed; }static void export_service (struct gatt_db_attribute *attr,void *user_data) --
Quoted 1 line
2.5.5
Applied.
Signature · 1 line
Luiz Augusto von Dentz