2015-05-23 03:39:31

by Ankur Patel

[permalink] [raw]
Subject: Issue Write Not Permitted Error Response not working

Hello Folks,

After implementing and running the test case for Characteristics Write Not Permitted Response (TC_GAW_SR_BI_15_C), it failed. Following the Trace, I found that Bluez (Controller) Sends ATT "Error Response: Write not Permitted" after receiving "Execute Write Request" from Host instead of sending the "Error Response" after receiving "Prepare Write Request" from Host.

Current ATT Message Exchange (Host <> Controller)
----------------------------------------------------
Frame#41(H->C): Prepare Write Request
Frame#43(C->H): Prepare Write Response
Frame#44(H->C): Execute Write Request
Frame#46(C->H): Error Response with code "Write Not Permitted"

Expected ATT Message Exchange (Host <> Controller)
----------------------------------------------------
(H->C): Prepare Write Request
(C->H): Error Response with code "Write Not Permitted"

Please find the attached Trace Capture via PTS software as http://www.filedropper.com/tcgawsrbi15c20150523090341

Code Snippet (Registered Characteristic as below - for Write not permitted):

gatt_db_service_add_characteristic(service, &uuid,
BT_ATT_PERM_READ | BT_ATT_PERM_WRITE,
BT_GATT_CHRC_PROP_READ | BT_GATT_CHRC_PROP_WRITE,
custom_ccc_read_cb, custom_not_permi_resp_write_cb,
server);

static void custom_not_permi_resp_write_cb(struct gatt_db_attribute *attrib,
unsigned int id, uint16_t offset, const uint8_t *value, size_t len,
uint8_t opcode, struct bt_att *att, void *user_data)
{
uint8_t ecode = 0x3;
gatt_db_attribute_write_result(attrib, id, ecode);
}

Any idea on why Bluez is not sending the Error Response After Prepare Write Request from Host?

Regards,
Ankur.


2015-05-25 08:31:32

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: Issue Write Not Permitted Error Response not working

Hi Ankur,

On Mon, May 25, 2015 at 11:17 AM, Ankur Patel <[email protected]> wrote:
> Thank you Gowtham Anandha Babu for brief & useful explanation. I understand your concern and my mistake. I did the same and now the Testcase is Passed. As you have mentioned, I am itself using tools/btgatt-server.c application and modifying it to pass the PTS/GATT testcases.
>
> Once I am done, I would like to share modified btgatt-server.c on forum so that anyone wants to pass PTS/GATT testcases, it will be useful.

That would be great, you can also document the PIC/PIXIT and commands
necessary like we did for android, I guess this documents can go under
doc.


--
Luiz Augusto von Dentz

2015-05-25 08:23:06

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: Issue Write Not Permitted Error Response not working

Hi Gowtham, Ankur,

On Mon, May 25, 2015 at 10:47 AM, Gowtham Anandha Babu
<[email protected]> wrote:
> Hi Ankur,
>
>> -----Original Message-----
>> From: [email protected] [mailto:linux-bluetooth-
>> [email protected]] On Behalf Of Ankur Patel
>> Sent: Saturday, May 23, 2015 9:10 AM
>> To: [email protected]
>> Subject: Issue Write Not Permitted Error Response not working
>>
>> Hello Folks,
>>
>> After implementing and running the test case for Characteristics Write Not
>> Permitted Response (TC_GAW_SR_BI_15_C), it failed. Following the Trace, I
>> found that Bluez (Controller) Sends ATT "Error Response: Write not
>> Permitted" after receiving "Execute Write Request" from Host instead of
>> sending the "Error Response" after receiving "Prepare Write Request" from
>> Host.
>>
>> Current ATT Message Exchange (Host <> Controller)
>> ----------------------------------------------------
>> Frame#41(H->C): Prepare Write Request
>> Frame#43(C->H): Prepare Write Response
>> Frame#44(H->C): Execute Write Request
>> Frame#46(C->H): Error Response with code "Write Not Permitted"
>>
>> Expected ATT Message Exchange (Host <> Controller)
>> ----------------------------------------------------
>> (H->C): Prepare Write Request
>> (C->H): Error Response with code "Write Not Permitted"
>>
>> Please find the attached Trace Capture via PTS software as
>> http://www.filedropper.com/tcgawsrbi15c20150523090341
>>
>> Code Snippet (Registered Characteristic as below - for Write not
> permitted):
>>
>> gatt_db_service_add_characteristic(service, &uuid,
>> BT_ATT_PERM_READ | BT_ATT_PERM_WRITE,
>> BT_GATT_CHRC_PROP_READ | BT_GATT_CHRC_PROP_WRITE,
>> custom_ccc_read_cb,
> custom_not_permi_resp_write_cb,
>> server);
>>
>
> PTS FAILS:
> Here you are trying to write on a CHARC which is already given write
> permission.
> So, in this case BlueZ will send Success Prepare Write Response, which is
> correct.
>
> PTS PASS:
> But If you remove the write permission from above code snippet, Bluez will
> send
> Write Not Permitted Error Response, which makes TC_GAW_SR_BI_15_C PASS.

Yep, which means when defining the permission and properties needs to
be consistent with what the callback expects. There is a similar
problem with D-Bus as well since we don't call WriteValue until
execute that can also generate an error if the permissions are not set
correctly.

> For more info you can start tools/btgatt-server and
> emulate all services and cross-check the functionality.
>
> Let others comment on this.
>
>> static void custom_not_permi_resp_write_cb(struct gatt_db_attribute
>> *attrib,
>> unsigned int id, uint16_t offset, const uint8_t
> *value, size_t len,
>> uint8_t opcode, struct bt_att *att, void *user_data)
> {
>> uint8_t ecode = 0x3;
>> gatt_db_attribute_write_result(attrib, id, ecode); }
>>
>> Any idea on why Bluez is not sending the Error Response After Prepare
> Write
>> Request from Host?
>>
>> Regards,
>> Ankur.
>> --
>
> Regards,
> Gowtham Anandha Babu
>
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth"
> in
>> the body of a message to [email protected] More majordomo
>> info at http://vger.kernel.org/majordomo-info.html
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html



--
Luiz Augusto von Dentz

2015-05-25 08:17:57

by Ankur Patel

[permalink] [raw]
Subject: RE: Issue Write Not Permitted Error Response not working

> Hi Ankur,
>
> > Hello Folks,
> >
> > After implementing and running the test case for Characteristics Write
> > Not Permitted Response (TC_GAW_SR_BI_15_C), it failed. Following the
> > Trace, I found that Bluez (Controller) Sends ATT "Error Response:
> > Write not Permitted" after receiving "Execute Write Request" from
> > Host instead of sending the "Error Response" after receiving "Prepare
> > Write Request" from Host.
> >
> > Current ATT Message Exchange (Host <> Controller)
> > ----------------------------------------------------
> > Frame#41(H->C): Prepare Write Request
> > Frame#43(C->H): Prepare Write Response
> > Frame#44(H->C): Execute Write Request
> > Frame#46(C->H): Error Response with code "Write Not Permitted"
> >
> > Expected ATT Message Exchange (Host <> Controller)
> > ----------------------------------------------------
> > (H->C): Prepare Write Request
> > (C->H): Error Response with code "Write Not Permitted"
> >
> > Please find the attached Trace Capture via PTS software as
> > http://www.filedropper.com/tcgawsrbi15c20150523090341
> >
> > Code Snippet (Registered Characteristic as below - for Write not
> permitted):
> >
> > gatt_db_service_add_characteristic(service, &uuid,
> > BT_ATT_PERM_READ | BT_ATT_PERM_WRITE,
> > BT_GATT_CHRC_PROP_READ | BT_GATT_CHRC_PROP_WRITE,
> > custom_ccc_read_cb,
> custom_not_permi_resp_write_cb,
> > server);
> >
>
> PTS FAILS:
> Here you are trying to write on a CHARC which is already given write
> permission.
> So, in this case BlueZ will send Success Prepare Write Response, which is
> correct.
>
> PTS PASS:
> But If you remove the write permission from above code snippet, Bluez will
> send Write Not Permitted Error Response, which makes
> TC_GAW_SR_BI_15_C PASS.
>
> For more info you can start tools/btgatt-server and emulate all services and
> cross-check the functionality.
>
> Let others comment on this.
>
> > static void custom_not_permi_resp_write_cb(struct gatt_db_attribute
> > *attrib,
> > unsigned int id, uint16_t offset, const uint8_t
> *value, size_t len,
> > uint8_t opcode, struct bt_att *att, void
> > *user_data)
> {
> > uint8_t ecode = 0x3;
> > gatt_db_attribute_write_result(attrib, id, ecode); }
> >
> > Any idea on why Bluez is not sending the Error Response After Prepare
> Write
> > Request from Host?
> >
> > Regards,
> > Ankur.
> > --
>
> Regards,
> Gowtham Anandha Babu

Thank you Gowtham Anandha Babu for brief & useful explanation. I understand your concern and my mistake. I did the same and now the Testcase is Passed. As you have mentioned, I am itself using tools/btgatt-server.c application and modifying it to pass the PTS/GATT testcases.

Once I am done, I would like to share modified btgatt-server.c on forum so that anyone wants to pass PTS/GATT testcases, it will be useful.

Appreciate your support,
Ankur

2015-05-25 07:47:52

by Gowtham Anandha Babu

[permalink] [raw]
Subject: RE: Issue Write Not Permitted Error Response not working

Hi Ankur,

> -----Original Message-----
> From: [email protected] [mailto:linux-bluetooth-
> [email protected]] On Behalf Of Ankur Patel
> Sent: Saturday, May 23, 2015 9:10 AM
> To: [email protected]
> Subject: Issue Write Not Permitted Error Response not working
>
> Hello Folks,
>
> After implementing and running the test case for Characteristics Write Not
> Permitted Response (TC_GAW_SR_BI_15_C), it failed. Following the Trace, I
> found that Bluez (Controller) Sends ATT "Error Response: Write not
> Permitted" after receiving "Execute Write Request" from Host instead of
> sending the "Error Response" after receiving "Prepare Write Request" from
> Host.
>
> Current ATT Message Exchange (Host <> Controller)
> ----------------------------------------------------
> Frame#41(H->C): Prepare Write Request
> Frame#43(C->H): Prepare Write Response
> Frame#44(H->C): Execute Write Request
> Frame#46(C->H): Error Response with code "Write Not Permitted"
>
> Expected ATT Message Exchange (Host <> Controller)
> ----------------------------------------------------
> (H->C): Prepare Write Request
> (C->H): Error Response with code "Write Not Permitted"
>
> Please find the attached Trace Capture via PTS software as
> http://www.filedropper.com/tcgawsrbi15c20150523090341
>
> Code Snippet (Registered Characteristic as below - for Write not
permitted):
>
> gatt_db_service_add_characteristic(service, &uuid,
> BT_ATT_PERM_READ | BT_ATT_PERM_WRITE,
> BT_GATT_CHRC_PROP_READ | BT_GATT_CHRC_PROP_WRITE,
> custom_ccc_read_cb,
custom_not_permi_resp_write_cb,
> server);
>

PTS FAILS:
Here you are trying to write on a CHARC which is already given write
permission.
So, in this case BlueZ will send Success Prepare Write Response, which is
correct.

PTS PASS:
But If you remove the write permission from above code snippet, Bluez will
send
Write Not Permitted Error Response, which makes TC_GAW_SR_BI_15_C PASS.

For more info you can start tools/btgatt-server and
emulate all services and cross-check the functionality.

Let others comment on this.

> static void custom_not_permi_resp_write_cb(struct gatt_db_attribute
> *attrib,
> unsigned int id, uint16_t offset, const uint8_t
*value, size_t len,
> uint8_t opcode, struct bt_att *att, void *user_data)
{
> uint8_t ecode = 0x3;
> gatt_db_attribute_write_result(attrib, id, ecode); }
>
> Any idea on why Bluez is not sending the Error Response After Prepare
Write
> Request from Host?
>
> Regards,
> Ankur.
> --

Regards,
Gowtham Anandha Babu

> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth"
in
> the body of a message to [email protected] More majordomo
> info at http://vger.kernel.org/majordomo-info.html