Couple fixes and improvements
v6 cover Couple fixes and improvements
I've back to work on making Android gatt to make use of shared/gatt. Here is couple of fixes I've done to shared code when doing this work.
Android gatt still needs testing but will be available sooner or later
v2:
- fix test-gatt for long write seesion testes
- prepare test-gatt test to support other changes
- do aggregation of prep writes for long write session
- support reliable nested long write
- start to look into characteristic extended prop for reliable session
v3:
- rebase
- remove patch adding notification type - that one needs to be reworked
v4:
- Fix according to Luiz comment
v5:
- Fix additional Luiz comments
v6:
- move getting extended properties to gatt_db_attribute_get_char_data instead
of separate API
- added patch which read extended characteristic propertis descriptors during discovery session when acting as gatt-client. This is needed so the call of gatt_db_attribute_get_char_data will return correct ext_prop value.
- Added patch fixing charcteristic properties in btgatt-server and test-gatt
Łukasz Rymanowski (5):
btgatt-server: Fix GATT device name properties
test-gatt: Fix characteristic properties
shared/gatt-db: Extend gatt_db_attribute_get_char_data with ext. prop shared/gatt-server Check for ext. charact. prop. on reliable session
gatt-client: Read extended props on service discovery
profiles/deviceinfo/deviceinfo.c | 2 +- profiles/gap/gas.c | 2 +- profiles/scanparam/scan.c | 2 +- src/device.c | 2 +- src/gatt-client.c | 3 +- src/shared/gatt-client.c | 120 ++++++++++++++++++++++++++++++++++++++- src/shared/gatt-db.c | 63 ++++++++++++++++++++ src/shared/gatt-db.h | 1 + src/shared/gatt-server.c | 50 +++++++++++++++- tools/btgatt-client.c | 8 ++- tools/btgatt-server.c | 11 ++-- unit/test-gatt.c | 41 +++++++++---- 12 files changed, 278 insertions(+), 27 deletions(-)
Signature · 1 line
2.5.0
PATCH v6 1/5 btgatt-server: Fix GATT device name properties
Since GATT device name characteristic has extended characteristic property descriptor, that should be set in properties as well. This patch fixes that.
--- tools/btgatt-server.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/btgatt-server.c +2 -1
@@ -419,7 +419,8 @@ static void populate_gap_service(struct server *server)bt_uuid16_create (&uuid,GATT_CHARAC_DEVICE_NAME );gatt_db_service_add_characteristic (service, &uuid,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ , +BT_GATT_CHRC_PROP_READ | +BT_GATT_CHRC_PROP_EXT_PROP , gap_device_name_read_cb, gap_device_name_write_cb, server);
Signature · 1 line
2.5.0
PATCH v6 2/5 test-gatt: Fix characteristic properties
In reply to Łukasz RymanowskiThis patch fixes characteristic property for those characteristics which contains extended characteristic properties descriptor.
--- unit/test-gatt.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
unit/test-gatt.c +12 -9
@@ -257,7 +257,7 @@ struct context {raw_pdu (0x09 ,0x07 ,0x12 ,0xf0 ,0x02 ,0x13 ,0xf0 ,0x00 , \0x2a ), \raw_pdu (0x08 ,0x13 ,0xf0 ,0x18 ,0xf0 ,0x03 ,0x28 ), \ -raw_pdu (0x09 ,0x15 ,0x14 ,0xf0 ,0x02 ,0x15 ,0xf0 ,0xef , \ +raw_pdu (0x09 ,0x15 ,0x14 ,0xf0 ,0x82 ,0x15 ,0xf0 ,0xef , \0xcd ,0xab ,0x89 ,0x67 ,0x45 ,0x23 ,0x01 ,0x00 , \0x00 ,0x00 ,0x00 ,0x09 ,0xB0 ,0x00 ,0x00 ), \ raw_pdu(0x08, 0x15, 0xf0, 0x18, 0xf0, 0x03, 0x28), \
@@ -268,7 +268,7 @@ struct context {raw_pdu (0x04 ,0x16 ,0xf0 ,0x16 ,0xf0 ), \raw_pdu (0x05 ,0x01 ,0x16 ,0xf0 ,0x00 ,0x29 ), \raw_pdu (0x08 ,0x01 ,0x00 ,0x10 ,0x00 ,0x03 ,0x28 ), \ -raw_pdu (0x09 ,0x07 ,0x02 ,0x00 ,0x32 ,0x03 ,0x00 ,0x29 , \ +raw_pdu (0x09 ,0x07 ,0x02 ,0x00 ,0xb2 ,0x03 ,0x00 ,0x29 , \0x2a ), \raw_pdu (0x08 ,0x03 ,0x00 ,0x10 ,0x00 ,0x03 ,0x28 ), \raw_pdu (0x01 ,0x08 ,0x03 ,0x00 ,0x0a )
@@ -1556,7 +1556,8 @@ static struct gatt_db *make_test_spec_small_db(void) BT_ATT_PERM_WRITE, BT_GATT_CHRC_PROP_READ | BT_GATT_CHRC_PROP_NOTIFY | - BT_GATT_CHRC_PROP_INDICATE, + BT_GATT_CHRC_PROP_INDICATE | +BT_GATT_CHRC_PROP_EXT_PROP , "BlueZ"), DESCRIPTOR(GATT_CLIENT_CHARAC_CFG_UUID, BT_ATT_PERM_READ | BT_ATT_PERM_WRITE, 0x00, 0x00),
@@ -1572,7 +1573,8 @@ static struct gatt_db *make_test_spec_small_db(void) "BlueZ Unit Tester"), CHARACTERISTIC(0000B009-0000-0000-0123-456789abcdef,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE , -BT_GATT_CHRC_PROP_READ ,0x09 ), +BT_GATT_CHRC_PROP_READ | +BT_GATT_CHRC_PROP_EXT_PROP ,0x09 ),DESCRIPTOR (GATT_CHARAC_EXT_PROPER_UUID ,BT_ATT_PERM_READ ,0x01 ,0x00 ), CHARACTERISTIC(GATT_CHARAC_APPEARANCE, BT_ATT_PERM_READ,
@@ -1617,7 +1619,8 @@ static struct gatt_db *make_test_spec_large_db_1(void)PRIMARY_SERVICE (0x0080 ,"a00b" ,7 ),CHARACTERISTIC (0xb008 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE ,BT_GATT_CHRC_PROP_READ | -BT_GATT_CHRC_PROP_WRITE , +BT_GATT_CHRC_PROP_WRITE | +BT_GATT_CHRC_PROP_EXT_PROP ,0x08 ),DESCRIPTOR (0xb015 ,BT_ATT_PERM_READ |BT_ATT_PERM_WRITE ,0x01 ), DESCRIPTOR(0xb016, BT_ATT_PERM_READ | BT_ATT_PERM_WRITE, 0x02),
@@ -2546,7 +2549,7 @@ int main(int argc, char *argv[])raw_pdu (0x09 ,0x07 ,0x12 ,0xf0 ,0x02 ,0x13 ,0xf0 ,0x00 ,0x2a ),raw_pdu (0x08 ,0x13 ,0xf0 ,0x18 ,0xf0 ,0x03 ,0x28 ), -raw_pdu (0x09 ,0x15 ,0x14 ,0xf0 ,0x02 ,0x15 ,0xf0 ,0xef , +raw_pdu (0x09 ,0x15 ,0x14 ,0xf0 ,0x82 ,0x15 ,0xf0 ,0xef ,0xcd ,0xab ,0x89 ,0x67 ,0x45 ,0x23 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x09 , 0xb0, 0x00, 0x00),
@@ -2560,7 +2563,7 @@ int main(int argc, char *argv[]) ts_small_db,NULL ,raw_pdu (0x03 ,0x00 ,0x02 ),raw_pdu (0x08 ,0x01 ,0x00 ,0x0f ,0x00 ,0x03 ,0x28 ), -raw_pdu (0x09 ,0x07 ,0x02 ,0x00 ,0x32 ,0x03 ,0x00 ,0x29 , +raw_pdu (0x09 ,0x07 ,0x02 ,0x00 ,0xb2 ,0x03 ,0x00 ,0x29 ,0x2a ),raw_pdu (0x08 ,0x03 ,0x00 ,0x0f ,0x00 ,0x03 ,0x28 ), raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a));
@@ -2599,7 +2602,7 @@ int main(int argc, char *argv[])raw_pdu (0x09 ,0x07 ,0x12 ,0xf0 ,0x02 ,0x13 ,0xf0 ,0x00 ,0x2a ),raw_pdu (0x08 ,0x13 ,0xf0 ,0x17 ,0xf0 ,0x03 ,0x28 ), -raw_pdu (0x09 ,0x15 ,0x14 ,0xf0 ,0x02 ,0x15 ,0xf0 ,0xef , +raw_pdu (0x09 ,0x15 ,0x14 ,0xf0 ,0x82 ,0x15 ,0xf0 ,0xef ,0xcd ,0xab ,0x89 ,0x67 ,0x45 ,0x23 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x09 , 0xb0, 0x00, 0x00),
@@ -2613,7 +2616,7 @@ int main(int argc, char *argv[]) ts_small_db,NULL ,raw_pdu (0x03 ,0x00 ,0x02 ),raw_pdu (0x08 ,0x01 ,0x00 ,0x0f ,0x00 ,0x03 ,0x28 ), -raw_pdu (0x09 ,0x07 ,0x02 ,0x00 ,0x32 ,0x03 ,0x00 ,0x29 , +raw_pdu (0x09 ,0x07 ,0x02 ,0x00 ,0xb2 ,0x03 ,0x00 ,0x29 ,0x2a ),raw_pdu (0x08 ,0x03 ,0x00 ,0x0f ,0x00 ,0x03 ,0x28 ), raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a));
Signature · 1 line
2.5.0
PATCH v6 3/5 shared/gatt-db: Extend gatt_db_attribute_get_char_data with ext. prop
In reply to Łukasz RymanowskiThis patch adds way to get extended properties from characteristic extended property descriptor
--- profiles/deviceinfo/deviceinfo.c | 2 +- profiles/gap/gas.c | 2 +- profiles/scanparam/scan.c | 2 +- src/device.c | 2 +- src/gatt-client.c | 3 +- src/shared/gatt-client.c | 6 ++-- src/shared/gatt-db.c | 63 ++++++++++++++++++++++++++++++++++++++++ src/shared/gatt-db.h | 1 + tools/btgatt-client.c | 8 +++-- tools/btgatt-server.c | 8 +++-- unit/test-gatt.c | 4 +-- 11 files changed, 85 insertions(+), 16 deletions(-)
profiles/deviceinfo/deviceinfo.c +1 -1
@@ -88,7 +88,7 @@ static void handle_characteristic(struct gatt_db_attribute *attr,bt_string_to_uuid (&pnpid_uuid,PNPID_UUID );if (!gatt_db_attribute_get_char_data (attr,NULL , &value_handle,NULL , - &uuid)) { +NULL , &uuid)) {error ("Failed to obtain characteristic data" );return ; }
profiles/gap/gas.c +1 -1
@@ -181,7 +181,7 @@ static void handle_characteristic(struct gatt_db_attribute *attr,bt_uuid_t uuid;if (!gatt_db_attribute_get_char_data (attr,NULL , &value_handle,NULL , - &uuid)) { +NULL , &uuid)) {error ("Failed to obtain characteristic data" );return ; }
profiles/scanparam/scan.c +1 -1
@@ -140,7 +140,7 @@ static void handle_characteristic(struct gatt_db_attribute *attr,bt_uuid_t uuid, scan_interval_wind_uuid, scan_refresh_uuid;if (!gatt_db_attribute_get_char_data (attr,NULL , &value_handle,NULL , - &uuid)) { +NULL , &uuid)) {error ("Failed to obtain characteristic data" );return ; }
src/device.c +1 -1
@@ -1987,7 +1987,7 @@ static void store_chrc(struct gatt_db_attribute *attr, void *user_data)bt_uuid_t uuid;if (!gatt_db_attribute_get_char_data (attr, &handle_num, &value_handle, - &properties, &uuid)) { + &properties,NULL , &uuid)) {warn ("Error storing characteristic - can't get data" );return ; }
src/gatt-client.c +2 -1
@@ -1283,7 +1283,8 @@ static struct characteristic *characteristic_create(gatt_db_attribute_get_char_data (attr, &chrc->handle, &chrc->value_handle, - &chrc->props, &uuid); + &chrc->props,NULL , + &uuid); chrc->attr =gatt_db_get_attribute (service->client->db, chrc->value_handle);
src/shared/gatt-client.c +3 -3
@@ -243,9 +243,9 @@ static struct notify_chrc *notify_chrc_create(struct bt_gatt_client *client,if (bt_uuid_cmp (&uuid,gatt_db_attribute_get_type (attr)))return NULL ; -if (!gatt_db_attribute_get_char_data (attr,NULL ,NULL , - &properties,NULL )) -return NULL ; +if (!gatt_db_attribute_get_char_data (attr,NULL ,NULL , &properties, +NULL ,NULL )) +return NULL ; chrc = new0(struct notify_chrc, 1);
src/shared/gatt-db.c +63 -0
85 lines not on this page · raw message
src/shared/gatt-db.h +1 -0
@@ -199,6 +199,7 @@ bool gatt_db_attribute_get_char_data(const struct gatt_db_attribute *attrib,uint16_t *handle, uint16_t *value_handle, uint8_t *properties, + uint16_t *ext_prop, bt_uuid_t *uuid); bool gatt_db_attribute_get_incl_data(const struct gatt_db_attribute *attrib,
tools/btgatt-client.c +5 -3
@@ -297,18 +297,20 @@ static void print_chrc(struct gatt_db_attribute *attr, void *user_data) {uint16_t handle, value_handle;uint8_t properties; +uint16_t ext_prop;bt_uuid_t uuid;if (!gatt_db_attribute_get_char_data (attr, &handle, &value_handle, &properties, + &ext_prop, &uuid))return ;printf ("\t " COLOR_YELLOW "charac" COLOR_OFF -" - start: 0x%04x, value: 0x%04x, " -"props: 0x%02x, uuid: " , - handle, value_handle, properties); +" - start: 0x%04x, value: 0x%04x, " +"props: 0x%02x, ext_props: 0x%04x, uuid: " , + handle, value_handle, properties, ext_prop);print_uuid (&uuid);gatt_db_service_foreach_desc (attr, print_desc,NULL );
tools/btgatt-server.c +5 -3
@@ -932,18 +932,20 @@ static void print_chrc(struct gatt_db_attribute *attr, void *user_data) {uint16_t handle, value_handle;uint8_t properties; +uint16_t ext_prop;bt_uuid_t uuid;if (!gatt_db_attribute_get_char_data (attr, &handle, &value_handle, &properties, + &ext_prop, &uuid))return ;printf ("\t " COLOR_YELLOW "charac" COLOR_OFF -" - start: 0x%04x, value: 0x%04x, " -"props: 0x%02x, uuid: " , - handle, value_handle, properties); +" - start: 0x%04x, value: 0x%04x, " +"props: 0x%02x, ext_prop: 0x%04x, uuid: " , + handle, value_handle, properties, ext_prop);print_uuid (&uuid);gatt_db_service_foreach_desc (attr, print_desc,NULL );
unit/test-gatt.c +2 -2
@@ -526,9 +526,9 @@ static bool matching_char_data(struct gatt_db_attribute *a,bt_uuid_t a_uuid, b_uuid;gatt_db_attribute_get_char_data (a, &a_handle, &a_value_handle, - &a_properties, &a_uuid); + &a_properties,NULL , &a_uuid);gatt_db_attribute_get_char_data (b, &b_handle, &b_value_handle, - &b_properties, &b_uuid); + &b_properties,NULL , &b_uuid);return a_handle == b_handle && a_value_handle == b_value_handle && a_properties == b_properties &&
Signature · 1 line
2.5.0
PATCH v6 4/5 shared/gatt-server Check for ext. charact. prop. on reliable session
In reply to Łukasz RymanowskiWith this patch we make sure that reliable session is done on characteristics which does support it.
--- src/shared/gatt-server.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++- unit/test-gatt.c | 14 ++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-)
src/shared/gatt-server.c +49 -1
@@ -72,6 +72,8 @@ struct prep_write_data {uint16_t handle;uint16_t offset;uint16_t length; + +bool reliable_supported; };static void prep_write_data_destroy (void *user_data)
@@ -1111,6 +1113,23 @@ static bool append_prep_data(struct prep_write_data *prep_data, uint16_t handle,return true; } +static bool is_reliable_write_supported (const struct bt_gatt_server *server, +uint16_t handle) +{ +struct gatt_db_attribute *attr; +uint16_t ext_prop; + + attr =gatt_db_get_attribute (server->db, handle); +if (!attr) +return false; + +if (!gatt_db_attribute_get_char_data (attr,NULL ,NULL ,NULL , &ext_prop, +NULL )) +return false; + +return (ext_prop &BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE ); +} +static bool prep_data_new (struct bt_gatt_server *server,uint16_t handle,uint16_t offset,uint16_t length,uint8_t *value)
@@ -1128,6 +1147,13 @@ static bool prep_data_new(struct bt_gatt_server *server, prep_data->handle = handle; prep_data->offset = offset; +/* +* Handle is the value handle. We need characteristic declaration +* handle which in BlueZ is handle_value -1 +*/ + prep_data->reliable_supported =is_reliable_write_supported (server, + handle -1 ); +queue_push_tail (server->prep_queue, prep_data);return true;
@@ -1258,6 +1284,14 @@ error: ehandle, err); } +static bool find_no_reliable_characteristic (const void *data, +const void *match_data) +{ +const struct prep_write_data *prep_data = data; + +return !prep_data->reliable_supported; +} +static void exec_write_cb (uint8_t opcode,const void *pdu,uint16_t length,void *user_data) {
@@ -1265,6 +1299,7 @@ static void exec_write_cb(uint8_t opcode, const void *pdu,uint8_t flags;uint8_t ecode;bool write; +uint16_t ehandle =0 ;if (length !=1 ) { ecode =BT_ATT_ERROR_INVALID_PDU ;
@@ -1293,6 +1328,19 @@ static void exec_write_cb(uint8_t opcode, const void *pdu,return ; } +/* If there is more than one prep request, we are in reliable session */ +if (queue_length (server->prep_queue) >1 ) { +struct prep_write_data *prep_data; + + prep_data =queue_find (server->prep_queue, + find_no_reliable_characteristic,NULL ); +if (prep_data) { + ecode =BT_ATT_ERROR_REQUEST_NOT_SUPPORTED ; + ehandle = prep_data->handle; + goto error; + } + } +exec_next_prep_write (server,0 ,0 );return ;
@@ -1300,7 +1348,7 @@ static void exec_write_cb(uint8_t opcode, const void *pdu, error:queue_remove_all (server->prep_queue,NULL ,NULL , prep_write_data_destroy); -bt_att_send_error_rsp (server->att, opcode,0 , ecode); +bt_att_send_error_rsp (server->att, opcode, ehandle, ecode); } static void exchange_mtu_cb(uint8_t opcode, const void *pdu,
unit/test-gatt.c +14 -0
@@ -4437,5 +4437,19 @@ int main(int argc, char *argv[]) 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff), raw_pdu(0x01, 0x16, 0x04, 0x00, 0x03)); +define_test_server ("/robustness/no-reliable-characteristic" , + test_server, ts_large_db_1,NULL , +raw_pdu (0x03 ,0x00 ,0x02 ), +raw_pdu (0x16 ,0x82 ,0x00 ,0x00 ,0x00 ,0x01 ,0x02 ,0x03 ), +raw_pdu (0x17 ,0x82 ,0x00 ,0x00 ,0x00 ,0x01 ,0x02 ,0x03 ), +raw_pdu (0x16 ,0x25 ,0x00 ,0x00 ,0x00 ,0x01 ,0x02 ,0x03 ), +raw_pdu (0x17 ,0x25 ,0x00 ,0x00 ,0x00 ,0x01 ,0x02 ,0x03 ), +raw_pdu (0x16 ,0x82 ,0x00 ,0x03 ,0x00 ,0x04 ,0x05 ,0x06 ), +raw_pdu (0x17 ,0x82 ,0x00 ,0x03 ,0x00 ,0x04 ,0x05 ,0x06 ), +raw_pdu (0x16 ,0x25 ,0x00 ,0x03 ,0x00 ,0x04 ,0x05 ,0x06 ), +raw_pdu (0x17 ,0x25 ,0x00 ,0x03 ,0x00 ,0x04 ,0x05 ,0x06 ), +raw_pdu (0x18 ,0x01 ), +raw_pdu (0x01 ,0x18 ,0x25 ,0x00 ,0x06 )); +return tester_run (); }
Signature · 1 line
2.5.0
PATCH v6 5/5 gatt-client: Read extended props on service discovery
In reply to Łukasz RymanowskiNow once extended props can be taken with characteristic data we need to makes sure that after discovery correct value is in database.
With this patch, value of all the extended properties descriptors are read during discovery just after discover of descriptors
--- src/shared/gatt-client.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++ unit/test-gatt.c | 2 + 2 files changed, 116 insertions(+)
src/shared/gatt-client.c +114 -0
@@ -316,6 +316,7 @@ struct discovery_op {struct queue *pending_svcs;struct queue *pending_chrcs;struct queue *svcs; +struct queue *ext_prop_desc;struct gatt_db_attribute *cur_svc;bool success;uint16_t start;
@@ -331,6 +332,7 @@ static void discovery_op_free(struct discovery_op *op)queue_destroy (op->pending_svcs,NULL );queue_destroy (op->pending_chrcs, free);queue_destroy (op->svcs,NULL ); +queue_destroy (op->ext_prop_desc,NULL );free (op); }
@@ -360,6 +362,7 @@ static struct discovery_op *discovery_op_create(struct bt_gatt_client *client, op->pending_svcs =queue_new (); op->pending_chrcs =queue_new (); op->svcs =queue_new (); + op->ext_prop_desc =queue_new (); op->client = client; op->complete_func = complete_func; op->failure_func = failure_func;
@@ -604,6 +607,107 @@ failed:return false; } +static void ext_prop_write_cb (struct gatt_db_attribute *attrib, +int err,void *user_data) +{ +struct bt_gatt_client *client = user_data; + +util_debug (client->debug_callback, client->debug_data, +"Value set status: %d" , err); +} + +static void ext_prop_read_cb (bool success,uint8_t att_ecode, +const uint8_t *value,uint16_t length, +void *user_data); + +static bool read_ext_prop_desc (struct discovery_op *op) +{ +struct bt_gatt_client *client = op->client; +uint16_t handle; +struct gatt_db_attribute *attr; + + attr =queue_peek_head (op->ext_prop_desc); +if (!attr) +return false; + + handle =gatt_db_attribute_get_handle (attr); +bt_gatt_client_read_value (client, handle, ext_prop_read_cb, +discovery_op_ref (op), + discovery_op_unref); + +return true; +} + +static void ext_prop_read_cb (bool success,uint8_t att_ecode, +const uint8_t *value,uint16_t length, +void *user_data) +{ +struct discovery_op *op = user_data; +struct bt_gatt_client *client = op->client; +bool discovering; +struct gatt_db_attribute *desc_attr =NULL ; +struct gatt_db_attribute *next_srv; +uint16_t start, end; + +util_debug (client->debug_callback, client->debug_data, +"Ext. prop value: 0x%04x" , (uint16_t )value[0 ]); + + desc_attr =queue_pop_head (op->ext_prop_desc); +if (!desc_attr) + goto failed; + +if (!gatt_db_attribute_write (desc_attr,0 , value, length,0 ,NULL , + ext_prop_write_cb, client)) + goto failed; + +/* Any other descriptor to read? */ +if (read_ext_prop_desc (op)) +return ; + +/* Continue with discovery */ +do { +if (!discover_descs (op, &discovering)) + goto failed; + +if (discovering) +return ; + +/* Done with the current service */ +gatt_db_service_set_active (op->cur_svc, true); + + next_srv =queue_pop_head (op->svcs); +if (!next_srv) + goto done; + +if (!gatt_db_attribute_get_service_handles (next_srv, &start, + &end)) + goto failed; + + }while (start == end); + +/* Move on to the next service */ + op->cur_svc = next_srv; + + client->discovery_req =bt_gatt_discover_characteristics (client->att, + start, end, + discover_chrcs_cb, +discovery_op_ref (op), + discovery_op_unref); +if (client->discovery_req) +return ; + +util_debug (client->debug_callback, client->debug_data, +"Failed to start characteristic discovery" ); + +discovery_op_unref (op); + +failed: + success = false; + +done: +discovery_op_complete (op, success, att_ecode); +} +static void discover_descs_cb (bool success,uint8_t att_ecode,struct bt_gatt_result *result,void *user_data)
@@ -618,6 +722,7 @@ static void discover_descs_cb(bool success, uint8_t att_ecode,char uuid_str[MAX_LEN_UUID_STR ];unsigned int desc_count;bool discovering; +bt_uuid_t ext_prop_uuid;discovery_req_clear (client);
@@ -640,6 +745,8 @@ static void discover_descs_cb(bool success, uint8_t att_ecode,util_debug (client->debug_callback, client->debug_data,"Descriptors found: %u" , desc_count); +bt_uuid16_create (&ext_prop_uuid,GATT_CHARAC_EXT_PROPER_UUID ); +while (bt_gatt_iter_next_descriptor (&iter, &handle, u128.data)) {bt_uuid128_create (&uuid, u128);
@@ -657,8 +764,15 @@ static void discover_descs_cb(bool success, uint8_t att_ecode,if (gatt_db_attribute_get_handle (attr) != handle) goto failed; + +if (!bt_uuid_cmp (&ext_prop_uuid, &uuid)) +queue_push_tail (op->ext_prop_desc, attr); } +/* If we got extended prop descriptor, lets read it right away */ +if (read_ext_prop_desc (op)) +return ; + next:if (!discover_descs (op, &discovering)) goto failed;
unit/test-gatt.c +2 -0
@@ -267,6 +267,8 @@ struct context {raw_pdu (0x01 ,0x08 ,0x18 ,0xf0 ,0x0a ), \raw_pdu (0x04 ,0x16 ,0xf0 ,0x16 ,0xf0 ), \raw_pdu (0x05 ,0x01 ,0x16 ,0xf0 ,0x00 ,0x29 ), \ +raw_pdu (0x0a ,0x16 ,0xf0 ), \ +raw_pdu (0x0b ,0x01 ,0x00 ), \raw_pdu (0x08 ,0x01 ,0x00 ,0x10 ,0x00 ,0x03 ,0x28 ), \raw_pdu (0x09 ,0x07 ,0x02 ,0x00 ,0xb2 ,0x03 ,0x00 ,0x29 , \ 0x2a), \
Signature · 1 line
2.5.0
Hi Łukasz,
Quoted 52 lines · Łukasz Rymanowski
I've back to work on making Android gatt to make use of shared/gatt. Here is couple of fixes I've done to shared code when doing this work.
Android gatt still needs testing but will be available sooner or later
v2:
- fix test-gatt for long write seesion testes
- prepare test-gatt test to support other changes
- do aggregation of prep writes for long write session
- support reliable nested long write
- start to look into characteristic extended prop for reliable sessionv3:
- rebase
- remove patch adding notification type - that one needs to be reworkedv4:
- Fix according to Luiz commentv5:
- Fix additional Luiz commentsv6:
- move getting extended properties togatt_db_attribute_get_char_datainstead
of separate API
- added patch which read extended characteristic propertis descriptors during discovery session when acting as gatt-client. This is needed so the call ofgatt_db_attribute_get_char_datawill return correctext_propvalue.
- Added patch fixing charcteristic properties in btgatt-server and test-gattŁukasz Rymanowski (5):
btgatt-server: Fix GATT device name properties
test-gatt: Fix characteristic properties
shared/gatt-db: Extendgatt_db_attribute_get_char_datawith ext. prop shared/gatt-server Check for ext. charact. prop. on reliable session
gatt-client: Read extended props on service discoveryprofiles/deviceinfo/deviceinfo.c | 2 +- profiles/gap/gas.c | 2 +- profiles/scanparam/scan.c | 2 +- src/device.c | 2 +- src/gatt-client.c | 3 +- src/shared/gatt-client.c | 120 ++++++++++++++++++++++++++++++++++++++- src/shared/gatt-db.c | 63 ++++++++++++++++++++ src/shared/gatt-db.h | 1 + src/shared/gatt-server.c | 50 +++++++++++++++- tools/btgatt-client.c | 8 ++- tools/btgatt-server.c | 11 ++-- unit/test-gatt.c | 41 +++++++++---- 12 files changed, 278 insertions(+), 27 deletions(-)
Quoted 2 lines
--
2.5.0
Applied, thanks.
Signature · 1 line
Luiz Augusto von Dentz