From: Andrei Emeltchenko <[email protected]>
Test verifies Get play status.
---
unit/test-avrcp.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index db1a67e..4f81954 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -459,6 +459,23 @@ static ssize_t avrcp_handle_set_player_value(struct avrcp *session,
return 1;
}
+static ssize_t avrcp_handle_get_play_status(struct avrcp *session,
+ uint8_t transaction,
+ uint16_t params_len,
+ uint8_t *params,
+ void *user_data)
+{
+ DBG("");
+
+ if (params_len)
+ return -EINVAL;
+
+ avrcp_get_play_status_rsp(session, transaction, 0xaaaaaaaa, 0xbbbbbbbb,
+ 0x00);
+
+ return -EAGAIN;
+}
+
static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_CAPABILITIES,
AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
@@ -481,6 +498,9 @@ static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_SET_PLAYER_VALUE,
AVC_CTYPE_CONTROL, AVC_CTYPE_STABLE,
avrcp_handle_set_player_value },
+ { AVRCP_GET_PLAY_STATUS,
+ AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
+ avrcp_handle_get_play_status },
{ },
};
@@ -782,5 +802,16 @@ int main(int argc, char *argv[])
0x00, 0x19, 0x58, AVRCP_GET_PLAY_STATUS,
0x00, 0x00, 0x00));
+ /* Get play status - TG */
+ define_test("/TP/MDI/BV-02-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_PLAY_STATUS,
+ 0x00, 0x00, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_PLAY_STATUS,
+ 0x00, 0x00, 0x09, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xbb, 0xbb, 0xbb, 0xbb, 0x00));
+
+
return g_test_run();
}
--
1.8.3.2
Hi Andrei,
On Mon, Mar 10, 2014 at 11:09 AM, Andrei Emeltchenko
<[email protected]> wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> Test verifies Get play status.
> ---
> unit/test-avrcp.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
> index db1a67e..4f81954 100644
> --- a/unit/test-avrcp.c
> +++ b/unit/test-avrcp.c
> @@ -459,6 +459,23 @@ static ssize_t avrcp_handle_set_player_value(struct avrcp *session,
> return 1;
> }
>
> +static ssize_t avrcp_handle_get_play_status(struct avrcp *session,
> + uint8_t transaction,
> + uint16_t params_len,
> + uint8_t *params,
> + void *user_data)
> +{
> + DBG("");
> +
> + if (params_len)
> + return -EINVAL;
> +
> + avrcp_get_play_status_rsp(session, transaction, 0xaaaaaaaa, 0xbbbbbbbb,
> + 0x00);
> +
> + return -EAGAIN;
> +}
> +
> static const struct avrcp_control_handler control_handlers[] = {
> { AVRCP_GET_CAPABILITIES,
> AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
> @@ -481,6 +498,9 @@ static const struct avrcp_control_handler control_handlers[] = {
> { AVRCP_SET_PLAYER_VALUE,
> AVC_CTYPE_CONTROL, AVC_CTYPE_STABLE,
> avrcp_handle_set_player_value },
> + { AVRCP_GET_PLAY_STATUS,
> + AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
> + avrcp_handle_get_play_status },
> { },
> };
>
> @@ -782,5 +802,16 @@ int main(int argc, char *argv[])
> 0x00, 0x19, 0x58, AVRCP_GET_PLAY_STATUS,
> 0x00, 0x00, 0x00));
>
> + /* Get play status - TG */
> + define_test("/TP/MDI/BV-02-C", test_server,
> + raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
> + 0x00, 0x19, 0x58, AVRCP_GET_PLAY_STATUS,
> + 0x00, 0x00, 0x00),
> + raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
> + 0x00, 0x19, 0x58, AVRCP_GET_PLAY_STATUS,
> + 0x00, 0x00, 0x09, 0xaa, 0xaa, 0xaa,
> + 0xaa, 0xbb, 0xbb, 0xbb, 0xbb, 0x00));
> +
> +
> return g_test_run();
> }
> --
> 1.8.3.2
Applied, thanks.
--
Luiz Augusto von Dentz
From: Andrei Emeltchenko <[email protected]>
---
android/avrcp-lib.c | 13 +++++++++++++
android/avrcp-lib.h | 2 ++
2 files changed, 15 insertions(+)
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index b67fa32..5400f80 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -427,6 +427,19 @@ int avrcp_set_volume(struct avrcp *session, uint8_t volume, avctp_rsp_cb func,
func, user_data);
}
+int avrcp_get_element_attributes(struct avrcp *session, avctp_rsp_cb func,
+ void *user_data)
+{
+ uint8_t buf[9];
+
+ /* This returns all attributes */
+ memset(buf, 0, sizeof(buf));
+
+ return avrcp_send_req(session, AVC_CTYPE_STATUS, AVC_SUBUNIT_PANEL,
+ AVRCP_GET_ELEMENT_ATTRIBUTES, buf, sizeof(buf),
+ func, user_data);
+}
+
int avrcp_get_play_status_rsp(struct avrcp *session, uint8_t transaction,
uint32_t position, uint32_t duration,
uint8_t status)
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index 30d220e..4c845d3 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -150,6 +150,8 @@ int avrcp_get_play_status(struct avrcp *session, avctp_rsp_cb func,
void *user_data);
int avrcp_set_volume(struct avrcp *session, uint8_t volume, avctp_rsp_cb func,
void *user_data);
+int avrcp_get_element_attributes(struct avrcp *session, avctp_rsp_cb func,
+ void *user_data);
int avrcp_get_play_status_rsp(struct avrcp *session, uint8_t transaction,
uint32_t position, uint32_t duration,
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies Get element attributes responded by Target.
---
unit/test-avrcp.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 9b334e6..393afee 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -476,6 +476,22 @@ static ssize_t avrcp_handle_get_play_status(struct avrcp *session,
return -EAGAIN;
}
+static ssize_t avrcp_handle_get_element_attrs(struct avrcp *session,
+ uint8_t transaction,
+ uint16_t params_len,
+ uint8_t *params,
+ void *user_data)
+{
+ DBG("");
+
+ if (params_len < 9)
+ return -EINVAL;
+
+ avrcp_get_element_attrs_rsp(session, transaction, NULL, 0);
+
+ return -EAGAIN;
+}
+
static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_CAPABILITIES,
AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
@@ -501,6 +517,9 @@ static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_PLAY_STATUS,
AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
avrcp_handle_get_play_status },
+ { AVRCP_GET_ELEMENT_ATTRIBUTES,
+ AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
+ avrcp_handle_get_element_attrs },
{ },
};
@@ -822,5 +841,14 @@ int main(int argc, char *argv[])
0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
+ /* Get element attributes - TG */
+ define_test("/TP/MDI/BV-04-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
+ 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
+ 0x00, 0x00, 0x00));
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies that Register notification command is issued by
Controller.
---
unit/test-avrcp.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 496dd1b..fa4870d 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -578,6 +578,11 @@ static void test_client(gconstpointer data)
if (g_str_equal(context->data->test_name, "/TP/MDI/BV-03-C"))
avrcp_get_element_attributes(context->session, NULL, NULL);
+ if (g_str_equal(context->data->test_name, "/TP/NFY/BV-01-C"))
+ avrcp_register_notification(context->session,
+ AVRCP_EVENT_STATUS_CHANGED, 0,
+ NULL, NULL);
+
execute_context(context);
}
@@ -865,5 +870,14 @@ int main(int argc, char *argv[])
0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
0x00, 0x00, 0x00));
+ /* Notification Commands */
+
+ /* Register notification - CT */
+ define_test("/TP/NFY/BV-01-C", test_client,
+ raw_pdu(0x00, 0x11, 0x0e, 0x03, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x05, AVRCP_EVENT_STATUS_CHANGED,
+ 0x00, 0x00, 0x00, 0x00));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies that Target responds to Register notification command.
---
android/avrcp-lib.h | 3 +++
unit/test-avrcp.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+)
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index 4c845d3..91a7d47 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -86,6 +86,9 @@
/* Company IDs for vendor dependent commands */
#define IEEEID_BTSIG 0x001958
+/* Parameters legths */
+#define AVRCP_REGISTER_NOTIFICATION_PARAM_LENGTH 5
+
struct avrcp;
struct avrcp_control_handler {
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index fa4870d..0e3bb51 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -162,6 +162,8 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
ssize_t len;
int fd;
+ DBG("");
+
pdu = &context->data->pdu_list[context->pdu_offset++];
if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
@@ -495,6 +497,43 @@ static ssize_t avrcp_handle_get_element_attrs(struct avrcp *session,
return -EAGAIN;
}
+static ssize_t avrcp_handle_register_notification(struct avrcp *session,
+ uint8_t transaction,
+ uint16_t params_len,
+ uint8_t *params,
+ void *user_data)
+{
+ uint8_t event;
+ uint8_t pdu[1024];
+ size_t pdu_len;
+
+ DBG("");
+
+ if (params_len != AVRCP_REGISTER_NOTIFICATION_PARAM_LENGTH)
+ return -EINVAL;
+
+ event = params[0];
+ pdu[0] = event;
+ pdu_len = 1;
+
+ switch (event) {
+ case AVRCP_EVENT_TRACK_CHANGED:
+ memset(&pdu[1], 0xff, 8);
+ pdu_len += 8;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ avrcp_register_notification_rsp(session, transaction, AVC_CTYPE_INTERIM,
+ pdu, pdu_len);
+
+ avrcp_register_notification_rsp(session, transaction, AVC_CTYPE_CHANGED,
+ pdu, pdu_len);
+
+ return -EAGAIN;
+}
+
static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_CAPABILITIES,
AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
@@ -523,6 +562,9 @@ static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_ELEMENT_ATTRIBUTES,
AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
avrcp_handle_get_element_attrs },
+ { AVRCP_REGISTER_NOTIFICATION,
+ AVC_CTYPE_NOTIFY, AVC_CTYPE_INTERIM,
+ avrcp_handle_register_notification },
{ },
};
@@ -879,5 +921,22 @@ int main(int argc, char *argv[])
0x00, 0x00, 0x05, AVRCP_EVENT_STATUS_CHANGED,
0x00, 0x00, 0x00, 0x00));
+ /* Register notification - TG */
+ define_test("/TP/NFY/BV-02-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x03, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x05, AVRCP_EVENT_TRACK_CHANGED,
+ 0x00, 0x00, 0x00, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, AVC_CTYPE_INTERIM, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x09, AVRCP_EVENT_TRACK_CHANGED,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff),
+ raw_pdu(0x02, 0x11, 0x0e, AVC_CTYPE_CHANGED, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x09, AVRCP_EVENT_TRACK_CHANGED,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies that Target responds Register notification command with
parameter AVRCP_EVENT_SETTINGS_CHANGED.
---
unit/test-avrcp.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 0e3bb51..c442001 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -521,6 +521,12 @@ static ssize_t avrcp_handle_register_notification(struct avrcp *session,
memset(&pdu[1], 0xff, 8);
pdu_len += 8;
break;
+ case AVRCP_EVENT_SETTINGS_CHANGED:
+ pdu[1] = 0x01;
+ pdu[2] = 0x01;
+ pdu[3] = 0x02;
+ pdu_len = 4;
+ break;
default:
return -EINVAL;
}
@@ -938,5 +944,23 @@ int main(int argc, char *argv[])
0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff));
+ /* Register notification - TG */
+ define_test("/TP/NFY/BV-03-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x03, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x05,
+ AVRCP_EVENT_SETTINGS_CHANGED,
+ 0x00, 0x00, 0x00, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, AVC_CTYPE_INTERIM, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x04,
+ AVRCP_EVENT_SETTINGS_CHANGED,
+ 0x01, 0x01, 0x02),
+ raw_pdu(0x02, 0x11, 0x0e, AVC_CTYPE_CHANGED, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x04,
+ AVRCP_EVENT_SETTINGS_CHANGED,
+ 0x01, 0x01, 0x02));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies that Target responds to Get element attributes cmd.
---
unit/test-avrcp.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 393afee..496dd1b 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -482,11 +482,14 @@ static ssize_t avrcp_handle_get_element_attrs(struct avrcp *session,
uint8_t *params,
void *user_data)
{
- DBG("");
+ DBG("params_len %d params[8] %d", params_len, params[8]);
if (params_len < 9)
return -EINVAL;
+ if (params_len != 9 + params[8] * 4)
+ return -EINVAL;
+
avrcp_get_element_attrs_rsp(session, transaction, NULL, 0);
return -EAGAIN;
@@ -850,5 +853,17 @@ int main(int argc, char *argv[])
raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
0x00, 0x00, 0x00));
+
+ /* Get element attributes - TG */
+ define_test("/TP/MDI/BV-05-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
+ 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x01),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
+ 0x00, 0x00, 0x00));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies that Target responds to Register notification - Track
Changed - No Selected Track.
---
unit/test-avrcp.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index c442001..6b5f615 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -962,5 +962,17 @@ int main(int argc, char *argv[])
AVRCP_EVENT_SETTINGS_CHANGED,
0x01, 0x01, 0x02));
+ /* Register notification - Track Changed - No Selected Track - TG */
+ define_test("/TP/NFY/BV-04-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x03, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x05, AVRCP_EVENT_TRACK_CHANGED,
+ 0x00, 0x00, 0x00, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, AVC_CTYPE_INTERIM, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_REGISTER_NOTIFICATION,
+ 0x00, 0x00, 0x09, AVRCP_EVENT_TRACK_CHANGED,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
---
doc/test-coverage.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt
index 244e0c6..7dbe9b5 100644
--- a/doc/test-coverage.txt
+++ b/doc/test-coverage.txt
@@ -19,7 +19,7 @@ test-queue 1 Queue handling functionality
test-hfp 9 HFP Audio Gateway functionality
test-avdtp 60 AVDTP qualification test cases
test-avctp 9 AVCTP qualification test cases
-test-avrcp 24 AVRCP qualification test cases
+test-avrcp 37 AVRCP qualification test cases
test-gobex 31 Generic OBEX functionality
test-gobex-packet 9 OBEX packet handling
test-gobex-header 28 OBEX header handling
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies that Get element attributes issued correctly.
---
unit/test-avrcp.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 4f81954..9b334e6 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -553,6 +553,9 @@ static void test_client(gconstpointer data)
if (g_str_equal(context->data->test_name, "/TP/MDI/BV-01-C"))
avrcp_get_play_status(context->session, NULL, NULL);
+ if (g_str_equal(context->data->test_name, "/TP/MDI/BV-03-C"))
+ avrcp_get_element_attributes(context->session, NULL, NULL);
+
execute_context(context);
}
@@ -812,6 +815,12 @@ int main(int argc, char *argv[])
0x00, 0x00, 0x09, 0xaa, 0xaa, 0xaa,
0xaa, 0xbb, 0xbb, 0xbb, 0xbb, 0x00));
+ /* Get element attributes - CT */
+ define_test("/TP/MDI/BV-03-C", test_client,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58, AVRCP_GET_ELEMENT_ATTRIBUTES,
+ 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
return g_test_run();
}
--
1.8.3.2