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 8682e63..46ddde9 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
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 2df3d6c..baff66d 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 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 45ac798..2df3d6c 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]>
---
android/avrcp-lib.c | 14 ++++++++++++++
android/avrcp-lib.h | 6 ++++++
2 files changed, 20 insertions(+)
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index fbaa48d..1663218 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -416,6 +416,20 @@ int avrcp_get_element_attributes(struct avrcp *session, avctp_rsp_cb func,
func, user_data);
}
+int avrcp_register_notification(struct avrcp *session, uint8_t event,
+ uint32_t interval, avctp_rsp_cb func,
+ void *user_data)
+{
+ uint8_t pdu[AVRCP_REGISTER_NOTIFICATION_PARAM_LENGTH];
+
+ pdu[0] = event;
+ bt_put_be32(interval, &pdu[1]);
+
+ return avrcp_send_req(session, AVC_CTYPE_NOTIFY, AVC_SUBUNIT_PANEL,
+ AVRCP_REGISTER_NOTIFICATION, pdu, sizeof(pdu),
+ 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 5e90ea1..b0a1025 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 {
@@ -147,6 +150,9 @@ int avrcp_get_play_status(struct avrcp *session, avctp_rsp_cb func,
void *user_data);
int avrcp_get_element_attributes(struct avrcp *session, avctp_rsp_cb func,
void *user_data);
+int avrcp_register_notification(struct avrcp *session, uint8_t event,
+ uint32_t interval, 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 d50b1ad..45ac798 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]>
---
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 cd39071..fbaa48d 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -403,6 +403,19 @@ int avrcp_get_play_status(struct avrcp *session, avctp_rsp_cb 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 ba1d84a..5e90ea1 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -145,6 +145,8 @@ int avrcp_get_current_player_value(struct avrcp *session, uint8_t *attrs,
void *user_data);
int avrcp_get_play_status(struct avrcp *session, 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 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 46ddde9..d50b1ad 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