Return-Path: From: Szymon Janc To: Jakub Tyszkowski Cc: linux-bluetooth@vger.kernel.org Subject: Re: [PATCHv2 05/16] android/tester: Make HidHost tests use generic pdu struct Date: Tue, 30 Sep 2014 11:40:01 +0200 Message-ID: <8408756.jLWkblRn5T@uw000953> In-Reply-To: <1411713077-19757-6-git-send-email-jakub.tyszkowski@tieto.com> References: <1411713077-19757-1-git-send-email-jakub.tyszkowski@tieto.com> <1411713077-19757-6-git-send-email-jakub.tyszkowski@tieto.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Sender: linux-bluetooth-owner@vger.kernel.org List-ID: 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); > } > > 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