Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: Jakub Tyszkowski <jakub.tyszkowski@tieto.com>,
	"linux-bluetooth@vger.kernel.org"
	<linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCHv2 05/16] android/tester: Make HidHost tests use generic pdu struct
Date: Tue, 30 Sep 2014 12:00:27 +0200	[thread overview]
Message-ID: <3242273.GzTXxxgRO7@uw000953> (raw)
In-Reply-To: <CABBYNZ+fbRy1uzFQW_46q=hDG4=H7=YrH2-+POLU3VJf8aio=A@mail.gmail.com>

Hi Luiz,

On Tuesday 30 of September 2014 12:54:54 Luiz Augusto von Dentz wrote:
> Hi,
> 
> On Tue, Sep 30, 2014 at 12:40 PM, Szymon Janc <szymon.janc@tieto.com> wrote:
> > Hi Jakub,
> >
> > On Friday 26 of September 2014 08:31:06 Jakub Tyszkowski wrote:
> >> ---
> >>  android/tester-hidhost.c | 41 +++++++++++++++++------------------------
> >>  1 file changed, 17 insertions(+), 24 deletions(-)
> >>
> >> diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
> >> index c7e3a67..0fe9c0a 100644
> >> --- a/android/tester-hidhost.c
> >> +++ b/android/tester-hidhost.c
> >> @@ -21,6 +21,7 @@
> >>  #include "tester-main.h"
> >>
> >>  #include "android/utils.h"
> >> +#include "src/shared/util.h"
> >
> > Is this needed?
> >
> >>  #define HID_GET_REPORT_PROTOCOL              0x60
> >>  #define HID_GET_BOOT_PROTOCOL                0x61
> >> @@ -59,14 +60,16 @@ struct emu_cid_data {
> >>
> >>  static struct emu_cid_data cid_data;
> >>
> >> -static const uint8_t did_req_pdu[] = { 0x06, /* PDU id */
> >> +static struct pdu did_req_pdu = raw_pdu(
> >> +                     0x06, /* PDU id */
> >>                       0x00, 0x00, /* Transaction id */
> >>                       0x00, 0x0f, /* Req length */
> >>                       0x35, 0x03, /* Attributes length */
> >>                       0x19, 0x12, 0x00, 0xff, 0xff, 0x35, 0x05, 0x0a, 0x00,
> >> -                     0x00, 0xff, 0xff, 0x00 }; /* no continuation */
> >> +                     0x00, 0xff, 0xff, 0x00); /* no continuation */
> >>
> >> -static const uint8_t did_rsp_pdu[] = { 0x07, /* PDU id */
> >> +static struct pdu did_rsp_pdu = raw_pdu(
> >> +                     0x07, /* PDU id */
> >>                       0x00, 0x00, /* Transaction id */
> >>                       0x00, 0x4f, /* Response length */
> >>                       0x00, 0x4c, /* Attributes length */
> >> @@ -79,9 +82,10 @@ static const uint8_t did_rsp_pdu[] = { 0x07, /* PDU id */
> >>                       0x02, 0x02, 0x09, 0x02, 0x46, 0x09, 0x02, 0x03, 0x09,
> >>                       0x05, 0x0e, 0x09, 0x02, 0x04, 0x28, 0x01, 0x09, 0x02,
> >>                       0x05, 0x09, 0x00, 0x02,
> >> -                     0x00 }; /* no continuation */
> >> +                     0x00); /* no continuation */
> >>
> >> -static const uint8_t hid_rsp_pdu[] = { 0x07, /* PDU id */
> >> +static struct pdu hid_rsp_pdu = raw_pdu(
> >> +                     0x07, /* PDU id */
> >>                       0x00, 0x01, /* Transaction id */
> >>                       0x01, 0x71, /* Response length */
> >>                       0x01, 0x6E, /* Attributes length */
> >> @@ -126,7 +130,7 @@ static const uint8_t hid_rsp_pdu[] = { 0x07, /* PDU id */
> >>                       0x28, 0x01, 0x09, 0x02, 0x0b, 0x09, 0x01, 0x00, 0x09,
> >>                       0x02, 0x0c, 0x09, 0x0c, 0x80, 0x09, 0x02, 0x0d, 0x28,
> >>                       0x00, 0x09, 0x02, 0x0e, 0x28, 0x01,
> >> -                     0x00 }; /* no continuation */
> >> +                     0x00); /* no continuation */
> >>
> >>  static void hid_sdp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
> >>  {
> >> @@ -134,14 +138,14 @@ static void hid_sdp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
> >>       struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
> >>       struct emu_cid_data *cid_data = user_data;
> >>
> >> -     if (!memcmp(did_req_pdu, data, len)) {
> >> +     if (!memcmp(did_req_pdu.data, data, len)) {
> >>               bthost_send_cid(bthost, cid_data->sdp_handle, cid_data->sdp_cid,
> >> -                                     did_rsp_pdu, sizeof(did_rsp_pdu));
> >> +                                     did_rsp_pdu.data, did_rsp_pdu.size);
> >>               return;
> >>       }
> >>
> >>       bthost_send_cid(bthost, cid_data->sdp_handle, cid_data->sdp_cid,
> >> -                                     hid_rsp_pdu, sizeof(hid_rsp_pdu));
> >> +                                     hid_rsp_pdu.data, hid_rsp_pdu.size);
> >>  }
> >>  static void hid_sdp_search_cb(uint16_t handle, uint16_t cid, void *user_data)
> >>  {
> >> @@ -159,31 +163,20 @@ static void hid_prepare_reply_protocol_mode(struct emu_cid_data *cid_data)
> >>  {
> >>       struct test_data *t_data = tester_get_data();
> >>       struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
> >> -     uint8_t pdu[2] = { 0, 0 };
> >> -     uint16_t pdu_len = 0;
> >> -
> >> -     pdu_len = 2;
> >> -     pdu[0] = 0xa0;
> >> -     pdu[1] = 0x00;
> >> +     const struct pdu pdu = raw_pdu(0xa0, 0x00);
> >>
> >>       bthost_send_cid(bthost, cid_data->ctrl_handle, cid_data->ctrl_cid,
> >> -                                                     (void *)pdu, pdu_len);
> >> +                                                     pdu.data, pdu.size);
> 
> Something is not quite right if you have to cast to void *, it looks
> like we should pass a reference e.g. &pdu not the value itself.

That line with (void *) is removed in this patch :)

> 
> >>  }
> >>
> >>  static void hid_prepare_reply_report(struct emu_cid_data *cid_data)
> >>  {
> >>       struct test_data *t_data = tester_get_data();
> >>       struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
> >> -     uint8_t pdu[3] = { 0, 0, 0 };
> >> -     uint16_t pdu_len = 0;
> >> -
> >> -     pdu_len = 3;
> >> -     pdu[0] = 0xa2;
> >> -     pdu[1] = 0x01;
> >> -     pdu[2] = 0x00;
> >> +     const struct pdu pdu = raw_pdu(0xa2, 0x01, 0x00);
> >>
> >>       bthost_send_cid(bthost, cid_data->ctrl_handle, cid_data->ctrl_cid,
> >> -                                                     (void *)pdu, pdu_len);
> >> +                                                     pdu.data, pdu.size);
> >>  }
> >>
> >>  static void hid_ctrl_cid_hook_cb(const void *data, uint16_t len,
> >>
> >
> > --
> > Best regards,
> > Szymon Janc
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> 
> 

-- 
Best regards, 
Szymon Janc

  reply	other threads:[~2014-09-30 10:00 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
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 [this message]
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=3242273.GzTXxxgRO7@uw000953 \
    --to=szymon.janc@tieto.com \
    --cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox