linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH hcidump 2/2 v2] Add parsing for AVRCP GetCapabilities
@ 2011-07-12 14:50 Luiz Augusto von Dentz
  2011-07-13 18:01 ` Lucas De Marchi
  2011-07-26  7:51 ` Johan Hedberg
  0 siblings, 2 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2011-07-12 14:50 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 parser/avrcp.c |  124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 123 insertions(+), 1 deletions(-)

diff --git a/parser/avrcp.c b/parser/avrcp.c
index 43e8a8b..ff6862d 100644
--- a/parser/avrcp.c
+++ b/parser/avrcp.c
@@ -111,6 +111,21 @@
 #define AVRCP_SEARCH			0x80
 #define AVRCP_ADD_TO_NOW_PLAYING	0x90
 
+/* notification events */
+#define AVRCP_EVENT_PLAYBACK_STATUS_CHANGED		0x01
+#define AVRCP_EVENT_TRACK_CHANGED			0x02
+#define AVRCP_EVENT_TRACK_REACHED_END			0x03
+#define AVRCP_EVENT_TRACK_REACHED_START			0x04
+#define AVRCP_EVENT_PLAYBACK_POS_CHANGED		0x05
+#define AVRCP_EVENT_BATT_STATUS_CHANGED			0x06
+#define AVRCP_EVENT_SYSTEM_STATUS_CHANGED		0x07
+#define AVRCP_EVENT_PLAYER_APPLICATION_SETTING_CHANGED	0x08
+#define AVRCP_EVENT_NOW_PLAYING_CONTENT_CHANGED		0x09
+#define AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED		0x0a
+#define AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED		0x0b
+#define AVRCP_EVENT_UIDS_CHANGED			0x0c
+#define AVRCP_EVENT_VOLUME_CHANGED			0x0d
+
 static const char *ctype2str(uint8_t ctype)
 {
 	switch (ctype & 0x0f) {
@@ -213,6 +228,105 @@ static const char *pdu2str(uint8_t pduid)
 	}
 }
 
+static char *cap2str(uint8_t cap)
+{
+	switch (cap) {
+	case 0x2:
+		return "CompanyID";
+	case 0x3:
+		return "EventsID";
+	default:
+		return "Unknown";
+	}
+}
+
+static char *event2str(uint8_t event)
+{
+	switch (event) {
+	case AVRCP_EVENT_PLAYBACK_STATUS_CHANGED:
+		return "EVENT_PLAYBACK_STATUS_CHANGED";
+	case AVRCP_EVENT_TRACK_CHANGED:
+		return "EVENT_TRACK_CHANGED";
+	case AVRCP_EVENT_TRACK_REACHED_END:
+		return "EVENT_TRACK_REACHED_END";
+	case AVRCP_EVENT_TRACK_REACHED_START:
+		return "EVENT_TRACK_REACHED_START";
+	case AVRCP_EVENT_PLAYBACK_POS_CHANGED:
+		return "EVENT_PLAYBACK_POS_CHANGED";
+	case AVRCP_EVENT_BATT_STATUS_CHANGED:
+		return "EVENT_BATT_STATUS_CHANGED";
+	case AVRCP_EVENT_SYSTEM_STATUS_CHANGED:
+		return "EVENT_SYSTEM_STATUS_CHANGED";
+	case AVRCP_EVENT_PLAYER_APPLICATION_SETTING_CHANGED:
+		return "EVENT_PLAYER_APPLICATION_SETTING_CHANGED";
+	case AVRCP_EVENT_NOW_PLAYING_CONTENT_CHANGED:
+		return "EVENT_NOW_PLAYING_CONTENT_CHANGED";
+	case AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED:
+		return "EVENT_AVAILABLE_PLAYERS_CHANGED";
+	case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED:
+		return "EVENT_ADDRESSED_PLAYER_CHANGED";
+	case AVRCP_EVENT_UIDS_CHANGED:
+		return "EVENT_UIDS_CHANGED";
+	case AVRCP_EVENT_VOLUME_CHANGED:
+		return "EVENT_VOLUME_CHANGED";
+	default:
+		return "Reserved";
+	}
+}
+
+static void avrcp_get_capabilities_dump(int level, struct frame *frm, uint16_t len)
+{
+	uint8_t cap;
+	uint8_t count;
+
+	p_indent(level, frm);
+
+	if (len < 1) {
+		printf("PDU Malformed\n");
+		raw_dump(level, frm);
+		return;
+	}
+
+	cap = get_u8(frm);
+	printf("CapabilityID: 0x%02x (%s)\n", cap, cap2str(cap));
+
+	if (len == 1)
+		return;
+
+	p_indent(level, frm);
+
+	count = get_u8(frm);
+	printf("CapabilityCount: 0x%02x\n", count);
+
+	switch (cap) {
+	case 0x2:
+		for (; count > 0; count--) {
+			int i;
+
+			p_indent(level, frm);
+
+			printf("%s: 0x", cap2str(cap));
+			for (i = 0; i < 3; i++)
+				printf("%02x", get_u8(frm));
+			printf("\n");
+		}
+		break;
+	case 0x3:
+		for (; count > 0; count--) {
+			uint8_t event;
+
+			p_indent(level, frm);
+
+			event = get_u8(frm);
+			printf("%s: 0x%02x (%s)\n", cap2str(cap), event,
+							event2str(event));
+		}
+		break;
+	default:
+		raw_dump(level, frm);
+	}
+}
+
 static void avrcp_pdu_dump(int level, struct frame *frm, uint8_t ctype)
 {
 	uint8_t pduid, pt;
@@ -229,9 +343,17 @@ static void avrcp_pdu_dump(int level, struct frame *frm, uint8_t ctype)
 	if (len != frm->len) {
 		p_indent(level, frm);
 		printf("PDU Malformed\n");
+		raw_dump(level, frm);
+		return;
 	}
 
-	raw_dump(level, frm);
+	switch (pduid) {
+	case AVRCP_GET_CAPABILITIES:
+		avrcp_get_capabilities_dump(level + 1, frm, len);
+		break;
+	default:
+		raw_dump(level, frm);
+	}
 }
 
 static char *op2str(uint8_t op)
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH hcidump 2/2 v2] Add parsing for AVRCP GetCapabilities
  2011-07-12 14:50 [PATCH hcidump 2/2 v2] Add parsing for AVRCP GetCapabilities Luiz Augusto von Dentz
@ 2011-07-13 18:01 ` Lucas De Marchi
  2011-07-13 19:37   ` Luiz Augusto von Dentz
  2011-07-26  7:51 ` Johan Hedberg
  1 sibling, 1 reply; 5+ messages in thread
From: Lucas De Marchi @ 2011-07-13 18:01 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

On Tue, Jul 12, 2011 at 11:50 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> ---
>  parser/avrcp.c |  124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 123 insertions(+), 1 deletions(-)
>
> diff --git a/parser/avrcp.c b/parser/avrcp.c
> index 43e8a8b..ff6862d 100644
> --- a/parser/avrcp.c
> +++ b/parser/avrcp.c
> @@ -111,6 +111,21 @@
>  #define AVRCP_SEARCH                   0x80
>  #define AVRCP_ADD_TO_NOW_PLAYING       0x90
>
> +/* notification events */
> +#define AVRCP_EVENT_PLAYBACK_STATUS_CHANGED            0x01
> +#define AVRCP_EVENT_TRACK_CHANGED                      0x02
> +#define AVRCP_EVENT_TRACK_REACHED_END                  0x03
> +#define AVRCP_EVENT_TRACK_REACHED_START                        0x04
> +#define AVRCP_EVENT_PLAYBACK_POS_CHANGED               0x05
> +#define AVRCP_EVENT_BATT_STATUS_CHANGED                        0x06
> +#define AVRCP_EVENT_SYSTEM_STATUS_CHANGED              0x07
> +#define AVRCP_EVENT_PLAYER_APPLICATION_SETTING_CHANGED 0x08
> +#define AVRCP_EVENT_NOW_PLAYING_CONTENT_CHANGED                0x09
> +#define AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED          0x0a
> +#define AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED           0x0b
> +#define AVRCP_EVENT_UIDS_CHANGED                       0x0c
> +#define AVRCP_EVENT_VOLUME_CHANGED                     0x0d
> +
>  static const char *ctype2str(uint8_t ctype)
>  {
>        switch (ctype & 0x0f) {
> @@ -213,6 +228,105 @@ static const char *pdu2str(uint8_t pduid)
>        }
>  }
>
> +static char *cap2str(uint8_t cap)
> +{
> +       switch (cap) {
> +       case 0x2:
> +               return "CompanyID";
> +       case 0x3:
> +               return "EventsID";
> +       default:
> +               return "Unknown";
> +       }
> +}
> +
> +static char *event2str(uint8_t event)
> +{
> +       switch (event) {
> +       case AVRCP_EVENT_PLAYBACK_STATUS_CHANGED:
> +               return "EVENT_PLAYBACK_STATUS_CHANGED";
> +       case AVRCP_EVENT_TRACK_CHANGED:
> +               return "EVENT_TRACK_CHANGED";
> +       case AVRCP_EVENT_TRACK_REACHED_END:
> +               return "EVENT_TRACK_REACHED_END";
> +       case AVRCP_EVENT_TRACK_REACHED_START:
> +               return "EVENT_TRACK_REACHED_START";
> +       case AVRCP_EVENT_PLAYBACK_POS_CHANGED:
> +               return "EVENT_PLAYBACK_POS_CHANGED";
> +       case AVRCP_EVENT_BATT_STATUS_CHANGED:
> +               return "EVENT_BATT_STATUS_CHANGED";
> +       case AVRCP_EVENT_SYSTEM_STATUS_CHANGED:
> +               return "EVENT_SYSTEM_STATUS_CHANGED";
> +       case AVRCP_EVENT_PLAYER_APPLICATION_SETTING_CHANGED:
> +               return "EVENT_PLAYER_APPLICATION_SETTING_CHANGED";
> +       case AVRCP_EVENT_NOW_PLAYING_CONTENT_CHANGED:
> +               return "EVENT_NOW_PLAYING_CONTENT_CHANGED";
> +       case AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED:
> +               return "EVENT_AVAILABLE_PLAYERS_CHANGED";
> +       case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED:
> +               return "EVENT_ADDRESSED_PLAYER_CHANGED";
> +       case AVRCP_EVENT_UIDS_CHANGED:
> +               return "EVENT_UIDS_CHANGED";
> +       case AVRCP_EVENT_VOLUME_CHANGED:
> +               return "EVENT_VOLUME_CHANGED";
> +       default:
> +               return "Reserved";
> +       }
> +}
> +
> +static void avrcp_get_capabilities_dump(int level, struct frame *frm, uint16_t len)
> +{
> +       uint8_t cap;
> +       uint8_t count;
> +
> +       p_indent(level, frm);
> +
> +       if (len < 1) {
> +               printf("PDU Malformed\n");
> +               raw_dump(level, frm);
> +               return;
> +       }
> +
> +       cap = get_u8(frm);
> +       printf("CapabilityID: 0x%02x (%s)\n", cap, cap2str(cap));
> +
> +       if (len == 1)
> +               return;
> +
> +       p_indent(level, frm);
> +
> +       count = get_u8(frm);
> +       printf("CapabilityCount: 0x%02x\n", count);
> +
> +       switch (cap) {
> +       case 0x2:
> +               for (; count > 0; count--) {
> +                       int i;
> +
> +                       p_indent(level, frm);
> +
> +                       printf("%s: 0x", cap2str(cap));
> +                       for (i = 0; i < 3; i++)
> +                               printf("%02x", get_u8(frm));

Humn... I think this is not what you want. Since this information is
always in big endian order, you may need to convert it to host
architecture in order to see meaningful numbers. E.g.: if you do like
you're doing, when receiving a packet with COMPANY_ID == IEEE_BTSIG,
the information printed will be 0x581900 instead of the expected
0x001958.


Lucas De Marchi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH hcidump 2/2 v2] Add parsing for AVRCP GetCapabilities
  2011-07-13 18:01 ` Lucas De Marchi
@ 2011-07-13 19:37   ` Luiz Augusto von Dentz
  2011-07-13 19:47     ` Lucas De Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2011-07-13 19:37 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: linux-bluetooth

Hi Lucas,

On Wed, Jul 13, 2011 at 9:01 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> On Tue, Jul 12, 2011 at 11:50 AM, Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
>> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>>
>> ---
>>  parser/avrcp.c |  124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>>  1 files changed, 123 insertions(+), 1 deletions(-)
>>
>> diff --git a/parser/avrcp.c b/parser/avrcp.c
>> index 43e8a8b..ff6862d 100644
>> --- a/parser/avrcp.c
>> +++ b/parser/avrcp.c
>> @@ -111,6 +111,21 @@
>>  #define AVRCP_SEARCH                   0x80
>>  #define AVRCP_ADD_TO_NOW_PLAYING       0x90
>>
>> +/* notification events */
>> +#define AVRCP_EVENT_PLAYBACK_STATUS_CHANGED            0x01
>> +#define AVRCP_EVENT_TRACK_CHANGED                      0x02
>> +#define AVRCP_EVENT_TRACK_REACHED_END                  0x03
>> +#define AVRCP_EVENT_TRACK_REACHED_START                        0x04
>> +#define AVRCP_EVENT_PLAYBACK_POS_CHANGED               0x05
>> +#define AVRCP_EVENT_BATT_STATUS_CHANGED                        0x06
>> +#define AVRCP_EVENT_SYSTEM_STATUS_CHANGED              0x07
>> +#define AVRCP_EVENT_PLAYER_APPLICATION_SETTING_CHANGED 0x08
>> +#define AVRCP_EVENT_NOW_PLAYING_CONTENT_CHANGED                0x09
>> +#define AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED          0x0a
>> +#define AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED           0x0b
>> +#define AVRCP_EVENT_UIDS_CHANGED                       0x0c
>> +#define AVRCP_EVENT_VOLUME_CHANGED                     0x0d
>> +
>>  static const char *ctype2str(uint8_t ctype)
>>  {
>>        switch (ctype & 0x0f) {
>> @@ -213,6 +228,105 @@ static const char *pdu2str(uint8_t pduid)
>>        }
>>  }
>>
>> +static char *cap2str(uint8_t cap)
>> +{
>> +       switch (cap) {
>> +       case 0x2:
>> +               return "CompanyID";
>> +       case 0x3:
>> +               return "EventsID";
>> +       default:
>> +               return "Unknown";
>> +       }
>> +}
>> +
>> +static char *event2str(uint8_t event)
>> +{
>> +       switch (event) {
>> +       case AVRCP_EVENT_PLAYBACK_STATUS_CHANGED:
>> +               return "EVENT_PLAYBACK_STATUS_CHANGED";
>> +       case AVRCP_EVENT_TRACK_CHANGED:
>> +               return "EVENT_TRACK_CHANGED";
>> +       case AVRCP_EVENT_TRACK_REACHED_END:
>> +               return "EVENT_TRACK_REACHED_END";
>> +       case AVRCP_EVENT_TRACK_REACHED_START:
>> +               return "EVENT_TRACK_REACHED_START";
>> +       case AVRCP_EVENT_PLAYBACK_POS_CHANGED:
>> +               return "EVENT_PLAYBACK_POS_CHANGED";
>> +       case AVRCP_EVENT_BATT_STATUS_CHANGED:
>> +               return "EVENT_BATT_STATUS_CHANGED";
>> +       case AVRCP_EVENT_SYSTEM_STATUS_CHANGED:
>> +               return "EVENT_SYSTEM_STATUS_CHANGED";
>> +       case AVRCP_EVENT_PLAYER_APPLICATION_SETTING_CHANGED:
>> +               return "EVENT_PLAYER_APPLICATION_SETTING_CHANGED";
>> +       case AVRCP_EVENT_NOW_PLAYING_CONTENT_CHANGED:
>> +               return "EVENT_NOW_PLAYING_CONTENT_CHANGED";
>> +       case AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED:
>> +               return "EVENT_AVAILABLE_PLAYERS_CHANGED";
>> +       case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED:
>> +               return "EVENT_ADDRESSED_PLAYER_CHANGED";
>> +       case AVRCP_EVENT_UIDS_CHANGED:
>> +               return "EVENT_UIDS_CHANGED";
>> +       case AVRCP_EVENT_VOLUME_CHANGED:
>> +               return "EVENT_VOLUME_CHANGED";
>> +       default:
>> +               return "Reserved";
>> +       }
>> +}
>> +
>> +static void avrcp_get_capabilities_dump(int level, struct frame *frm, uint16_t len)
>> +{
>> +       uint8_t cap;
>> +       uint8_t count;
>> +
>> +       p_indent(level, frm);
>> +
>> +       if (len < 1) {
>> +               printf("PDU Malformed\n");
>> +               raw_dump(level, frm);
>> +               return;
>> +       }
>> +
>> +       cap = get_u8(frm);
>> +       printf("CapabilityID: 0x%02x (%s)\n", cap, cap2str(cap));
>> +
>> +       if (len == 1)
>> +               return;
>> +
>> +       p_indent(level, frm);
>> +
>> +       count = get_u8(frm);
>> +       printf("CapabilityCount: 0x%02x\n", count);
>> +
>> +       switch (cap) {
>> +       case 0x2:
>> +               for (; count > 0; count--) {
>> +                       int i;
>> +
>> +                       p_indent(level, frm);
>> +
>> +                       printf("%s: 0x", cap2str(cap));
>> +                       for (i = 0; i < 3; i++)
>> +                               printf("%02x", get_u8(frm));
>
> Humn... I think this is not what you want. Since this information is
> always in big endian order, you may need to convert it to host
> architecture in order to see meaningful numbers. E.g.: if you do like
> you're doing, when receiving a packet with COMPANY_ID == IEEE_BTSIG,
> the information printed will be 0x581900 instead of the expected
> 0x001958.

It works just fine, we are printing byte by byte as it comes e.g. sony mw600:

> AVCTP: Command : pt 0x00 transaction 5 pid 0x110e
    AV/C: Status: address 0x48 opcode 0x00
      Subunit: Panel
      Opcode: Vendor Dependent
      Company ID: 0x001958
      AVRCP: GetCapabilities: pt 0x00 len 0x0001
        CapabilityID: 0x02 (CompanyID)

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH hcidump 2/2 v2] Add parsing for AVRCP GetCapabilities
  2011-07-13 19:37   ` Luiz Augusto von Dentz
@ 2011-07-13 19:47     ` Lucas De Marchi
  0 siblings, 0 replies; 5+ messages in thread
From: Lucas De Marchi @ 2011-07-13 19:47 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi, Luiz

On Wed, Jul 13, 2011 at 4:37 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>>> +                       printf("%s: 0x", cap2str(cap));
>>> +                       for (i = 0; i < 3; i++)
>>> +                               printf("%02x", get_u8(frm));
>>
>> Humn... I think this is not what you want. Since this information is
>> always in big endian order, you may need to convert it to host
>> architecture in order to see meaningful numbers. E.g.: if you do like
>> you're doing, when receiving a packet with COMPANY_ID == IEEE_BTSIG,
>> the information printed will be 0x581900 instead of the expected
>> 0x001958.
>
> It works just fine, we are printing byte by byte as it comes e.g. sony mw600:
>
>> AVCTP: Command : pt 0x00 transaction 5 pid 0x110e
>    AV/C: Status: address 0x48 opcode 0x00
>      Subunit: Panel
>      Opcode: Vendor Dependent
>      Company ID: 0x001958
>      AVRCP: GetCapabilities: pt 0x00 len 0x0001
>        CapabilityID: 0x02 (CompanyID)

Right... After all it comes as big endian, so you indeed shouldn't
have any issue.

Sorry, for the noise. It looks good now.



Lucas De Marchi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH hcidump 2/2 v2] Add parsing for AVRCP GetCapabilities
  2011-07-12 14:50 [PATCH hcidump 2/2 v2] Add parsing for AVRCP GetCapabilities Luiz Augusto von Dentz
  2011-07-13 18:01 ` Lucas De Marchi
@ 2011-07-26  7:51 ` Johan Hedberg
  1 sibling, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2011-07-26  7:51 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Tue, Jul 12, 2011, Luiz Augusto von Dentz wrote:
> ---
>  parser/avrcp.c |  124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 123 insertions(+), 1 deletions(-)

Both of these patches have been pushed upstream. Thanks.

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-07-26  7:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-12 14:50 [PATCH hcidump 2/2 v2] Add parsing for AVRCP GetCapabilities Luiz Augusto von Dentz
2011-07-13 18:01 ` Lucas De Marchi
2011-07-13 19:37   ` Luiz Augusto von Dentz
2011-07-13 19:47     ` Lucas De Marchi
2011-07-26  7:51 ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).