2014-11-12 08:53:14

by Vikrampal Yadav

[permalink] [raw]
Subject: [PATCH 1/3] monitor: Adjust for ERTM control bytes

Adjustment for ERTM control bytes fixed.
---
monitor/l2cap.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/monitor/l2cap.c b/monitor/l2cap.c
index ebdd20f..b37f20f 100644
--- a/monitor/l2cap.c
+++ b/monitor/l2cap.c
@@ -2621,6 +2621,9 @@ static void l2cap_frame(uint16_t index, bool in, uint16_t handle,
connless_packet(index, in, handle, cid, data, size);
break;
case 0x0003:
+ /* Adjust for ERTM control bytes */
+ data += 2;
+ size -= 2;
amp_packet(index, in, handle, cid, data, size);
break;
case 0x0004:
@@ -2635,6 +2638,9 @@ static void l2cap_frame(uint16_t index, bool in, uint16_t handle,
default:
l2cap_frame_init(&frame, index, in, handle, cid, data, size);

+ if (frame.mode > 0)
+ l2cap_frame_pull(&frame, &frame, 2);
+
print_indent(6, COLOR_CYAN, "Channel:", "", COLOR_OFF,
" %d len %d [PSM %d mode %d] {chan %d}",
cid, size, frame.psm,
--
1.9.1



2014-11-12 13:24:29

by Vikrampal Yadav

[permalink] [raw]
Subject: RE: [PATCH 1/3] monitor: Adjust for ERTM control bytes

Hi Luiz,

> -----Original Message-----
> From: Luiz Augusto von Dentz [mailto:[email protected]]
> Sent: Wednesday, November 12, 2014 5:49 PM
> To: Vikrampal Yadav
> Cc: [email protected]; Dmitry Kasatkin; [email protected]
> Subject: Re: [PATCH 1/3] monitor: Adjust for ERTM control bytes
>
> Hi Vikram,
>
> On Wed, Nov 12, 2014 at 10:53 AM, Vikrampal Yadav
> <[email protected]> wrote:
> > Adjustment for ERTM control bytes fixed.
> > ---
> > monitor/l2cap.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/monitor/l2cap.c b/monitor/l2cap.c index ebdd20f..b37f20f
> > 100644
> > --- a/monitor/l2cap.c
> > +++ b/monitor/l2cap.c
> > @@ -2621,6 +2621,9 @@ static void l2cap_frame(uint16_t index, bool in,
> uint16_t handle,
> > connless_packet(index, in, handle, cid, data, size);
> > break;
> > case 0x0003:
> > + /* Adjust for ERTM control bytes */
> > + data += 2;
> > + size -= 2;
> > amp_packet(index, in, handle, cid, data, size);
> > break;
> > case 0x0004:
> > @@ -2635,6 +2638,9 @@ static void l2cap_frame(uint16_t index, bool in,
> uint16_t handle,
> > default:
> > l2cap_frame_init(&frame, index, in, handle, cid, data,
> > size);
> >
> > + if (frame.mode > 0)
> > + l2cap_frame_pull(&frame, &frame, 2);
> > +
> > print_indent(6, COLOR_CYAN, "Channel:", "", COLOR_OFF,
> > " %d len %d [PSM %d mode %d] {chan %d}",
> > cid, size, frame.psm,
> > --
> > 1.9.1
>
> This is probably not enough if we really want to do it right, please check
> tools/parser/l2cap.c:l2cap_ctrl_ext_parse we most likely need to do
> something similar but this time we should actually not pass s-frames to be
> decoded further, only i-frames should contain data relevant to profiles.
>
>
>
> --
> Luiz Augusto von Dentz

Ok, I'll look into that.

Regards,
Vikram


2014-11-12 12:18:47

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 1/3] monitor: Adjust for ERTM control bytes

Hi Vikram,

On Wed, Nov 12, 2014 at 10:53 AM, Vikrampal Yadav
<[email protected]> wrote:
> Adjustment for ERTM control bytes fixed.
> ---
> monitor/l2cap.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/monitor/l2cap.c b/monitor/l2cap.c
> index ebdd20f..b37f20f 100644
> --- a/monitor/l2cap.c
> +++ b/monitor/l2cap.c
> @@ -2621,6 +2621,9 @@ static void l2cap_frame(uint16_t index, bool in, uint16_t handle,
> connless_packet(index, in, handle, cid, data, size);
> break;
> case 0x0003:
> + /* Adjust for ERTM control bytes */
> + data += 2;
> + size -= 2;
> amp_packet(index, in, handle, cid, data, size);
> break;
> case 0x0004:
> @@ -2635,6 +2638,9 @@ static void l2cap_frame(uint16_t index, bool in, uint16_t handle,
> default:
> l2cap_frame_init(&frame, index, in, handle, cid, data, size);
>
> + if (frame.mode > 0)
> + l2cap_frame_pull(&frame, &frame, 2);
> +
> print_indent(6, COLOR_CYAN, "Channel:", "", COLOR_OFF,
> " %d len %d [PSM %d mode %d] {chan %d}",
> cid, size, frame.psm,
> --
> 1.9.1

This is probably not enough if we really want to do it right, please
check tools/parser/l2cap.c:l2cap_ctrl_ext_parse we most likely need to
do something similar but this time we should actually not pass
s-frames to be decoded further, only i-frames should contain data
relevant to profiles.



--
Luiz Augusto von Dentz

2014-11-12 08:53:16

by Vikrampal Yadav

[permalink] [raw]
Subject: [PATCH 3/3] monitor: Add AVRCP SetBrowsedPlayer support

Support for decoding AVRCP SetBrowsedPlayer added in Bluetooth monitor.

> ACL Data RX: Handle 69 flags 0x02 dlen 16 [hci0] 43.952518
Channel: 65 len 12 [PSM 27 mode 3] {chan 1}
AVCTP Browsing: Command: type 0x00 label 0 PID 0x110e
AVRCP: SetBrowsedPlayer: len 0x0002
PlayerID: 0x0001 (1)
---
monitor/avctp.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 85 insertions(+), 1 deletion(-)

diff --git a/monitor/avctp.c b/monitor/avctp.c
index af91ecc..0a1e92d 100644
--- a/monitor/avctp.c
+++ b/monitor/avctp.c
@@ -1637,11 +1637,95 @@ static bool avrcp_control_packet(struct avctp_frame *avctp_frame)
}
}

+static bool avrcp_set_browsed_player(struct avctp_frame *avctp_frame)
+{
+ struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
+ uint32_t items;
+ uint16_t id, uids, charset;
+ uint8_t status, folders, indent = 2;
+
+ if (avctp_frame->hdr & 0x02)
+ goto response;
+
+ if (!l2cap_frame_get_be16(frame, &id))
+ return false;
+
+ print_field("%*cPlayerID: 0x%04x (%u)", indent, ' ', id, id);
+ return true;
+
+response:
+ if (!l2cap_frame_get_u8(frame, &status))
+ return false;
+
+ print_field("%*cStatus: 0x%02x (%s)", indent, ' ', status,
+ error2str(status));
+
+ if (!l2cap_frame_get_be16(frame, &uids))
+ return false;
+
+ print_field("%*cUIDCounter: 0x%04x (%u)", indent, ' ', uids, uids);
+
+ if (!l2cap_frame_get_be32(frame, &items))
+ return false;
+
+ print_field("%*cNumber of Items: 0x%08x (%u)", indent, ' ',
+ items, items);
+
+ if (!l2cap_frame_get_be16(frame, &charset))
+ return false;
+
+ print_field("%*cCharsetID: 0x%04x (%s)", indent, ' ', charset,
+ charset2str(charset));
+
+ if (!l2cap_frame_get_u8(frame, &folders))
+ return false;
+
+ print_field("%*cFolder Depth: 0x%02x (%u)", indent, ' ', folders,
+ folders);
+
+ for (; folders > 0; folders--) {
+ uint8_t len;
+
+ if (!l2cap_frame_get_u8(frame, &len))
+ return false;
+
+ printf("Folder: ");
+ for (; len > 0; len--) {
+ uint8_t c;
+
+ if (!l2cap_frame_get_u8(frame, &c))
+ return false;
+
+ printf("%1c", isprint(c) ? c : '.');
+ }
+ printf("\n");
+ }
+
+ return true;
+}
+
static bool avrcp_browsing_packet(struct avctp_frame *avctp_frame)
{
struct l2cap_frame *frame = &avctp_frame->l2cap_frame;
+ uint16_t len;
+ uint8_t pduid;
+
+ if (!l2cap_frame_get_u8(frame, &pduid))
+ return false;
+
+ if (!l2cap_frame_get_be16(frame, &len))
+ return false;
+
+ print_field("AVRCP: %s: len 0x%04x", pdu2str(pduid), len);
+
+ switch (pduid) {
+ case AVRCP_SET_BROWSED_PLAYER:
+ avrcp_set_browsed_player(avctp_frame);
+ break;
+ default:
+ packet_hexdump(frame->data, frame->size);
+ }

- packet_hexdump(frame->data, frame->size);
return true;
}

--
1.9.1


2014-11-12 08:53:15

by Vikrampal Yadav

[permalink] [raw]
Subject: [PATCH 2/3] monitor: Fix for GetElementAttributes when AttributeValueLength zero

AVCTP Control: Response: type 0x00 label 0 PID 0x110e
AV/C: Stable: address 0x48 opcode 0x00
Subunit: Panel
Opcode: Vendor Dependent
Company ID: 0x001958
AVRCP: GetElementAttributes pt Single len 0x0019
AttributeCount: 0x03
Attribute: 0x00000001 (Title)
CharsetID: 0x006a (UTF-8)
AttributeValueLength: 0x0000
AttributeValue:
Attribute: 0x00000002 (Artist)
CharsetID: 0x006a (UTF-8)
AttributeValueLength: 0x0000
AttributeValue:
Attribute: 0x00000003 (Album)
CharsetID: 0x006a (UTF-8)
AttributeValueLength: 0x0000
AttributeValue:
---
monitor/avctp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/monitor/avctp.c b/monitor/avctp.c
index 11dc9b2..af91ecc 100644
--- a/monitor/avctp.c
+++ b/monitor/avctp.c
@@ -1122,7 +1122,7 @@ response:
num = avrcp_continuing.num;

if (avrcp_continuing.size > 0) {
- char attrval[UINT8_MAX];
+ char attrval[UINT8_MAX] = {0};
uint16_t size;
uint8_t idx;

@@ -1157,7 +1157,7 @@ response:
uint32_t attr;
uint16_t charset, attrlen;
uint8_t idx;
- char attrval[UINT8_MAX];
+ char attrval[UINT8_MAX] = {0};

if (!l2cap_frame_get_be32(frame, &attr))
goto failed;
--
1.9.1