From: Tyszkowski Jakub <jakub.tyszkowski@tieto.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCHv2 01/16] android/tester: Expose gatt-tester's pdu definition to other testers
Date: Tue, 30 Sep 2014 13:41:58 +0200 [thread overview]
Message-ID: <542A9706.6000504@tieto.com> (raw)
In-Reply-To: <CABBYNZJwTo-hQ4LuaxbmQt8WGoPCrM-a_W1NQdf8AvJboNyu2w@mail.gmail.com>
Hi Luiz,
On 09/30/2014 12:08 PM, Luiz Augusto von Dentz wrote:
> Hi Jakub,
>
> On Fri, Sep 26, 2014 at 9:31 AM, Jakub Tyszkowski
> <jakub.tyszkowski@tieto.com> wrote:
>> This is not to reinvent this mechanism again for every tester that needs
>> to send raw pdu data.
>>
>> 'end_pdu' was renamed to 'null_pdu' to better fit also as request pdu in
>> 'pdu_set' structure while setting the response not null.
>>
>> This mechanism can be used later to send response regardles of data that
>> came with request on this specific CID. This will siplify responding to
>> sdp request without defining request pdus.
>> ---
>> android/tester-a2dp.c | 2 +-
>> android/tester-avrcp.c | 2 +-
>> android/tester-gatt.c | 49 +++++++++++++++++--------------------------------
>> android/tester-main.h | 15 +++++++++++++++
>> 4 files changed, 34 insertions(+), 34 deletions(-)
>>
>> diff --git a/android/tester-a2dp.c b/android/tester-a2dp.c
>> index 1b2a8ce..ab3936e 100644
>> --- a/android/tester-a2dp.c
>> +++ b/android/tester-a2dp.c
>> @@ -50,7 +50,7 @@ static const uint8_t rsp_start[] = { 0x42, 0x07 };
>> static const uint8_t req_suspend[] = { 0x50, 0x09, 0x04 };
>> static const uint8_t rsp_suspend[] = { 0x52, 0x09 };
>>
>> -const struct pdu {
>> +const struct pdu_set {
>> const uint8_t *req;
>> size_t req_len;
>> const uint8_t *rsp;
>> diff --git a/android/tester-avrcp.c b/android/tester-avrcp.c
>> index 07b95f5..b539e0e 100644
>> --- a/android/tester-avrcp.c
>> +++ b/android/tester-avrcp.c
>> @@ -71,7 +71,7 @@ static const uint8_t rsp_start[] = { 0x42, 0x07 };
>> static const uint8_t req_suspend[] = { 0x50, 0x09, 0x04 };
>> static const uint8_t rsp_suspend[] = { 0x52, 0x09 };
>>
>> -static const struct pdu {
>> +static const struct pdu_set {
>> const uint8_t *req;
>> size_t req_len;
>> const uint8_t *rsp;
>> diff --git a/android/tester-gatt.c b/android/tester-gatt.c
>> index 5d18bf0..ccc8e24 100644
>> --- a/android/tester-gatt.c
>> +++ b/android/tester-gatt.c
>> @@ -34,23 +34,8 @@
>> #define CONN1_ID 1
>> #define CONN2_ID 2
>>
>> -#define data(args...) ((const unsigned char[]) { args })
>> -
>> -#define raw_pdu(args...) \
>> - { \
>> - .data = data(args), \
>> - .size = sizeof(data(args)), \
>> - }
>> -
>> -#define end_pdu { .data = NULL }
>> -
>> static struct queue *list; /* List of gatt test cases */
>>
>> -struct pdu {
>> - const uint8_t *data;
>> - uint16_t size;
>> -};
>> -
>> static bt_uuid_t client_app_uuid = {
>> .uu = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
>> 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 },
>> @@ -397,7 +382,7 @@ static struct pdu search_service[] = {
>> raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
>> raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
>> raw_pdu(0x01, 0x10, 0x11, 0x00, 0x0a),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu search_service_2[] = {
>> @@ -407,13 +392,13 @@ static struct pdu search_service_2[] = {
>> raw_pdu(0x11, 0x06, 0x11, 0x00, 0x20, 0x00, 0x01, 0x18),
>> raw_pdu(0x10, 0x21, 0x00, 0xff, 0xff, 0x00, 0x28),
>> raw_pdu(0x01, 0x10, 0x21, 0x00, 0x0a),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu search_service_3[] = {
>> raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
>> raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu get_characteristic_1[] = {
>> @@ -425,7 +410,7 @@ static struct pdu get_characteristic_1[] = {
>> raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),
>> raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
>> raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu get_descriptor_1[] = {
>> @@ -441,7 +426,7 @@ static struct pdu get_descriptor_1[] = {
>> raw_pdu(0x05, 0x01, 0x04, 0x00, 0x00, 0x29),
>> raw_pdu(0x04, 0x05, 0x00, 0x10, 0x00),
>> raw_pdu(0x01, 0x04, 0x05, 0x00, 0x0a),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu get_descriptor_2[] = {
>> @@ -457,7 +442,7 @@ static struct pdu get_descriptor_2[] = {
>> raw_pdu(0x05, 0x01, 0x04, 0x00, 0x00, 0x29, 0x05, 0x00, 0x01, 0x29),
>> raw_pdu(0x04, 0x06, 0x00, 0x10, 0x00),
>> raw_pdu(0x01, 0x04, 0x06, 0x00, 0x0a),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu get_descriptor_3[] = {
>> @@ -471,7 +456,7 @@ static struct pdu get_descriptor_3[] = {
>> raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
>> raw_pdu(0x04, 0x01, 0x00, 0x10, 0x00),
>> raw_pdu(0x01, 0x04, 0x01, 0x00, 0x0a),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu get_included_1[] = {
>> @@ -483,7 +468,7 @@ static struct pdu get_included_1[] = {
>> raw_pdu(0x09, 0x08, 0x02, 0x00, 0x15, 0x00, 0x19, 0x00, 0xff, 0xfe),
>> raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x02, 0x28),
>> raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu get_included_2[] = {
>> @@ -498,7 +483,7 @@ static struct pdu get_included_2[] = {
>> 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10),
>> raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x02, 0x28),
>> raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu get_included_3[] = {
>> @@ -508,7 +493,7 @@ static struct pdu get_included_3[] = {
>> raw_pdu(0x01, 0x11, 0x11, 0x00, 0x0a),
>> raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x02, 0x28),
>> raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu read_characteristic_1[] = {
>> @@ -522,7 +507,7 @@ static struct pdu read_characteristic_1[] = {
>> raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
>> raw_pdu(0x0a, 0x03, 0x00),
>> raw_pdu(0x0b, 0x01),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu read_characteristic_2[] = {
>> @@ -536,7 +521,7 @@ static struct pdu read_characteristic_2[] = {
>> raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
>> raw_pdu(0x0a, 0x03, 0x00),
>> raw_pdu(0x01, 0x0a, 0x03, 0x00, 0x08),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu read_descriptor_1[] = {
>> @@ -554,7 +539,7 @@ static struct pdu read_descriptor_1[] = {
>> raw_pdu(0x01, 0x04, 0x05, 0x00, 0x0a),
>> raw_pdu(0x0a, 0x04, 0x00),
>> raw_pdu(0x0b, 0x01),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu read_descriptor_2[] = {
>> @@ -572,7 +557,7 @@ static struct pdu read_descriptor_2[] = {
>> raw_pdu(0x01, 0x04, 0x05, 0x00, 0x0a),
>> raw_pdu(0x0a, 0x04, 0x00),
>> raw_pdu(0x01, 0x0a, 0x04, 0x00, 0x08),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu write_characteristic_1[] = {
>> @@ -585,7 +570,7 @@ static struct pdu write_characteristic_1[] = {
>> raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
>> raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
>> raw_pdu(0x52, 0x03, 0x00, 0x00, 0x01, 0x02, 0x03),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu write_characteristic_2[] = {
>> @@ -599,7 +584,7 @@ static struct pdu write_characteristic_2[] = {
>> raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
>> raw_pdu(0x12, 0x03, 0x00, 0x00, 0x01, 0x02, 0x03),
>> raw_pdu(0x13),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static struct pdu write_characteristic_3[] = {
>> @@ -613,7 +598,7 @@ static struct pdu write_characteristic_3[] = {
>> raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
>> raw_pdu(0x12, 0x03, 0x00, 0x00, 0x01, 0x02, 0x03),
>> raw_pdu(0x01, 0x12, 0x03, 0x00, 0x08),
>> - end_pdu
>> + null_pdu
>> };
>>
>> static void gatt_client_register_action(void)
>> diff --git a/android/tester-main.h b/android/tester-main.h
>> index 6afc553..4cbc83f 100644
>> --- a/android/tester-main.h
>> +++ b/android/tester-main.h
>> @@ -55,6 +55,21 @@
>> #include <hardware/bt_gatt_client.h>
>> #include <hardware/bt_gatt_server.h>
>>
>> +struct pdu {
>> + uint8_t *data;
>> + uint16_t size;
>
> The size should probably be size_t, or even better use struct iovec
> directly here since it is about the same.
I wouldn't go that far and use iovec's here.
I actually had one patch on top of this set which replaces this struct
with iovec but in the end the only benefit was one struct definition
less as bthost API does not take iovecs:
void bthost_send_cid(struct bthost *bthost, uint16_t handle,
uint16_t cid, const void *data, uint16_t len)
And this function is also a reason for 'size' being uint16_t.
BTW I think 'pdu.data' looks better than 'pdu.iov_base' and we shouldn't
make it look more complicated than it is without the real benefit.
>
>> +};
>> +
>> +#define raw_data(args...) ((unsigned char[]) { args })
>> +
>> +#define raw_pdu(args...) \
>> + { \
>> + .data = raw_data(args), \
>> + .size = sizeof(raw_data(args)), \
>> + }
>> +
>> +#define null_pdu { .data = NULL }
>> +
>> #define TEST_CASE_BREDR(text, ...) { \
>> HCIEMU_TYPE_BREDR, \
>> text, \
>> --
>> 1.9.1
>
>
>
Regards,
Jakub
next prev parent reply other threads:[~2014-09-30 11:41 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-26 6:31 [PATCHv2 00/16] android/tester: Unifying the way PDU is handled Jakub Tyszkowski
2014-09-26 6:31 ` [PATCHv2 01/16] android/tester: Expose gatt-tester's pdu definition to other testers Jakub Tyszkowski
2014-09-30 10:08 ` Luiz Augusto von Dentz
2014-09-30 11:41 ` Tyszkowski Jakub [this message]
2014-09-30 12:10 ` Luiz Augusto von Dentz
2014-10-01 8:20 ` Tyszkowski Jakub
2014-09-26 6:31 ` [PATCHv2 02/16] android/tester: Make AVRCP tests use generic pdu struct Jakub Tyszkowski
2014-09-30 9:37 ` Szymon Janc
2014-09-26 6:31 ` [PATCHv2 03/16] android/tester: Make A2DP " Jakub Tyszkowski
2014-09-26 6:31 ` [PATCHv2 04/16] android/tester: Make GATT " Jakub Tyszkowski
2014-09-26 6:31 ` [PATCHv2 05/16] android/tester: Make HidHost " Jakub Tyszkowski
2014-09-30 9:40 ` Szymon Janc
2014-09-30 9:54 ` Luiz Augusto von Dentz
2014-09-30 10:00 ` Szymon Janc
2014-09-30 10:10 ` Luiz Augusto von Dentz
2014-09-30 12:01 ` Tyszkowski Jakub
2014-09-26 6:31 ` [PATCHv2 06/16] android/tester: Make PAN " Jakub Tyszkowski
2014-09-26 6:31 ` [PATCHv2 07/16] android/tester: Make HDP " Jakub Tyszkowski
2014-09-26 6:31 ` [PATCHv2 08/16] android/tester: Expose pdu_set structure so it can be reused Jakub Tyszkowski
2014-09-26 6:31 ` [PATCHv2 09/16] android/tester: Add generic hook to handle pdu exchange Jakub Tyszkowski
2014-09-26 6:31 ` [PATCHv2 10/16] android/tester: Make A2DP use pdu exchange mechanism Jakub Tyszkowski
2014-09-26 6:31 ` [PATCHv2 11/16] android/tester: Make AVRCP tests use generic " Jakub Tyszkowski
2014-09-26 6:31 ` [PATCHv2 12/16] android/tester: Make GATT use generic cid_data Jakub Tyszkowski
2014-09-26 6:31 ` [PATCHv2 13/16] android/tester: Make HDP tests use generic PDU exchange mechanism Jakub Tyszkowski
2014-09-26 6:31 ` [PATCHv2 14/16] android/tester: Make HIDHost " Jakub Tyszkowski
2014-09-26 6:31 ` [PATCHv2 15/16] android/tester: Make PAN " Jakub Tyszkowski
2014-09-26 6:31 ` [PATCHv2 16/16] android-tester: Use generic connect callback for simple cases Jakub Tyszkowski
2014-09-30 9:44 ` [PATCHv2 00/16] android/tester: Unifying the way PDU is handled Szymon Janc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=542A9706.6000504@tieto.com \
--to=jakub.tyszkowski@tieto.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.