++correction Descriptors are searched between Characteristic value declaration and characteristic definition end handle ------- Original Message ------- Sender : Nagaraj D R<nagaraj.dr@xxxxxxxxxxx> Lead Engineer/SRI-Bangalore-System & Connectivity/Samsung Electronics Date : Jun 11, 2015 15:46 (GMT+05:30) Title : Re: Re: Fwd: Fwd: [PATCH 1/1] shared/gatt-client: Fix the "Find Information req" error Hello Luiz, The problem that I was trying to address is for the characteristic attribute at 0Xfffe and characteristic value declaration at oxffff. This is a valid scenario. Characteristic need to have a characteristic value declaration but need not have characteristic descriptors. Since present design search the descriptors b/w the characteristic value declaration and service end handle, if service end handle and characteristic value declaration end handle are same (i.e 0xffff in a particular case) then descriptor search handle will be initialized to 0X000 (i.e by incrementing characteristic value handle (0xffff) ) 0x0000 handle is reserved handle + intention of searching descriptor will not be achieved. Regards Nagaraj D R ------- Original Message ------- Sender : Luiz Augusto von Dentz Date : Jun 11, 2015 15:24 (GMT+05:30) Title : Re: Fwd: Fwd: [PATCH 1/1] shared/gatt-client: Fix the "Find Information req" error Hi Nagaraj, On Thu, Jun 11, 2015 at 7:09 AM, Nagaraj D R wrote: > ping > > ------- Original Message ------- > Sender : Nagaraj D R Lead Engineer/SRI-Bangalore-System & Connectivity/Samsung Electronics > Date : May 15, 2015 11:50 (GMT+05:30) > Title : Fwd: [PATCH 1/1] shared/gatt-client: Fix the "Find Information req" error > > ping > > ------- Original Message ------- > Sender : Nagaraj D R Lead Engineer/SRI-Bangalore-System & Connectivity/Samsung Electronics > Date : May 13, 2015 17:05 (GMT+05:30) > Title : [PATCH 1/1] shared/gatt-client: Fix the "Find Information req" error > > From: "nagaraj.dr" > > characteristic descriptor is searched b/w the > characteristic "value_handle + 1" and > characteristic "end_handle" using "Find Information req" > > if remote device had declared the characteristic value_handle > at 0XFFFF (which also means there is no characteristic descriptors),then > present code would make start_handle has 0X0000(because of 16 bit > integer overflow) for "Find Information req" > > desc_start = chrc_data->value_handle + 1; > > Consequence: Below request will be sent, > ATT: Find Information req (0x04) > start 0x0000, end 0xffff > > and below will be the proper response from the remote device > ATT: Error (0x01) > Error: Invalid handle (1) > Find Information req (0x04) on handle 0x0000 > --- > src/shared/gatt-client.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c > index 7bc3b71..9b944ee 100644 > --- a/src/shared/gatt-client.c > +++ b/src/shared/gatt-client.c > @@ -601,13 +601,13 @@ static bool discover_descs(struct discovery_op *op, bool *discovering) > chrc_data->value_handle) > goto failed; Actually this check should happen in gatt_db_service_insert_characteristic which is probably creating something with handle 0 in the database which is wrong, actually perhaps it should just fail to create a characteristic in 0xffff, characteristics shall always have a value descriptor: 3.3.2 Characteristic Value Declaration The Characteristic Value declaration contains the value of the characteristic. It is the first Attribute after the characteristic declaration. All characteristic definitions shall have a Characteristic Value declaration. So I would suggest something like this: iff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index 5e1537e..7f863ef 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -706,6 +706,18 @@ service_insert_characteristic(struct gatt_db_service *service, if (handle && handle <= service->attributes[0]->handle) return NULL; + /* + * It is not possible to allocate last handle for a Characteristic + * since it would not have space for its value: + * 3.3.2 Characteristic Value Declaration + * The Characteristic Value declaration contains the value of the + * characteristic. It is the first Attribute after the characteristic + * declaration. All characteristic definitions shall have a + * Characteristic Value declaration. + */ + if (handle == UINT16_MAX) + return NULL; + i = get_attribute_index(service, 1); if (!i) return NULL; -- Luiz Augusto von Dentzÿôèº{.nÇ+‰·Ÿ®‰†+%ŠËÿ±éݶ¥Šwÿº{.nÇ+‰·¥Š{±ý¹nzÚ(¶âžØ^n‡r¡ö¦zË?ëh™¨èÚ&£ûàz¿äz¹Þ—ú+€Ê+zf£¢·hšˆ§~††Ûiÿÿï?êÿ‘êçz_è®æj:+v‰¨þ)ߣøm