mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2025-01-15 07:53:58 +08:00
android/tester: Add HDP Connect Source Reliable Channel test case
This commit is contained in:
parent
fbc5f2c1c1
commit
a86bccc18c
@ -28,6 +28,17 @@ typedef enum {
|
||||
HDP_APP_SOURCE_STREAM,
|
||||
} hdp_app_reg_type;
|
||||
|
||||
struct emu_cid_data {
|
||||
uint16_t sdp_handle;
|
||||
uint16_t sdp_cid;
|
||||
uint16_t ctrl_handle;
|
||||
uint16_t ctrl_cid;
|
||||
uint16_t data_handle;
|
||||
uint16_t data_cid;
|
||||
};
|
||||
|
||||
struct emu_cid_data cid_data;
|
||||
|
||||
static struct queue *list; /* List of hdp test cases */
|
||||
|
||||
static bthl_reg_param_t *create_app(hdp_app_reg_type type)
|
||||
@ -173,6 +184,204 @@ static void hdp_unregister_app_action(void)
|
||||
schedule_action_verification(step);
|
||||
}
|
||||
|
||||
static uint8_t hdp_rsp_pdu[] = { 0x07, /* PDU id */
|
||||
0x00, 0x00, /* Transaction id */
|
||||
0x01, 0xc8, /* Response length */
|
||||
0x01, 0xc5, /* Attributes length */
|
||||
0x36, 0x01, 0xc2, 0x36, 0x01, 0xbf, 0x09, 0x00, 0x00,
|
||||
0x0a, 0x00, 0x01, 0x00, 0x00, 0x09, 0x00, 0x01, 0x35,
|
||||
0x03, 0x19, 0x14, 0x01, 0x09, 0x00, 0x04, 0x35, 0x10,
|
||||
0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x10, 0x01, 0x35,
|
||||
0x06, 0x19, 0x00, 0x1e, 0x09, 0x01, 0x00, 0x09, 0x00,
|
||||
0x09, 0x35, 0x08, 0x35, 0x06, 0x19, 0x14, 0x00, 0x09,
|
||||
0x01, 0x01, 0x09, 0x00, 0x0d, 0x35, 0x0f, 0x35, 0x0d,
|
||||
0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x10, 0x03, 0x35,
|
||||
0x03, 0x19, 0x00, 0x1f, 0x09, 0x01, 0x00, 0x25, 0x03,
|
||||
0x48, 0x44, 0x50, 0x09, 0x01, 0x01, 0x25, 0x28, 0x43,
|
||||
0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x2c, 0x20, 0x64,
|
||||
0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x2c, 0x20, 0x61,
|
||||
0x6e, 0x64, 0x20, 0x72, 0x65, 0x8b, 0x6c, 0x61, 0x79,
|
||||
0x20, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x20, 0x64,
|
||||
0x61, 0x74, 0x61, 0x09, 0x01, 0x02, 0x25, 0x0d, 0x42,
|
||||
0x4c, 0x55, 0x45, 0x54, 0x4f, 0x4f, 0x54, 0x48, 0x20,
|
||||
0x53, 0x49, 0x47, 0x09, 0x02, 0x00, 0x36, 0x01, 0x22,
|
||||
0x35, 0x18, 0x08, 0x01, 0x09, 0x10, 0x04, 0x08, 0x00,
|
||||
0x25, 0x0f, 0x50, 0x75, 0x6c, 0x73, 0x65, 0x20, 0x4f,
|
||||
0x78, 0x69, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x0d, 0x35,
|
||||
0x20, 0x08, 0x02, 0x09, 0x10, 0x07, 0x08, 0x00, 0x25,
|
||||
0x17, 0x42, 0x6c, 0x6f, 0x6f, 0x64, 0x20, 0x50, 0x72,
|
||||
0x65, 0x73, 0x73, 0x75, 0x72, 0x65, 0x20, 0x4d, 0x6f,
|
||||
0x6e, 0x69, 0x74, 0x6f, 0x72, 0x0d, 0x35, 0x1a, 0x08,
|
||||
0x03, 0x09, 0x10, 0x08, 0x08, 0x00, 0x25, 0x11, 0x42,
|
||||
0x6f, 0x64, 0x79, 0x20, 0x54, 0x68, 0x65, 0x72, 0x6d,
|
||||
0x6f, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x0d, 0x35, 0x1e,
|
||||
0x08, 0x04, 0x09, 0x10, 0x0f, 0x08, 0x00, 0x25, 0x15,
|
||||
0x42, 0x6f, 0x64, 0x79, 0x20, 0x57, 0x65, 0x69, 0x67,
|
||||
0x68, 0x74, 0x20, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x09,
|
||||
0x09, 0x09, 0x0d, 0x35, 0x17, 0x08, 0x05, 0x09, 0x10,
|
||||
0x11, 0x08, 0x00, 0x25, 0x0e, 0x47, 0x6c, 0x75, 0x63,
|
||||
0x6f, 0x73, 0x65, 0x20, 0x4d, 0x65, 0x74, 0x65, 0x72,
|
||||
0x0d, 0x35, 0x18, 0x08, 0x06, 0x09, 0x10, 0x04, 0x08,
|
||||
0x01, 0x25, 0x0f, 0x50, 0x75, 0x6c, 0x73, 0x65, 0x20,
|
||||
0x4f, 0x78, 0x69, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x0d,
|
||||
0x35, 0x20, 0x08, 0x07, 0x09, 0x10, 0x07, 0x08, 0x01,
|
||||
0x25, 0x17, 0x42, 0x6c, 0x6f, 0x6f, 0x64, 0x20, 0x50,
|
||||
0x72, 0x65, 0x73, 0x73, 0x75, 0x72, 0x65, 0x20, 0x4d,
|
||||
0x6f, 0x6e, 0x69, 0x74, 0x6f, 0x72, 0x0d, 0x35, 0x1a,
|
||||
0x08, 0x08, 0x09, 0x10, 0x08, 0x08, 0x01, 0x25, 0x11,
|
||||
0x42, 0x6f, 0x64, 0x79, 0x20, 0x54, 0x68, 0x65, 0x72,
|
||||
0x6d, 0x6f, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x0d, 0x35,
|
||||
0x1e, 0x08, 0x09, 0x09, 0x10, 0x0f, 0x08, 0x01, 0x25,
|
||||
0x15, 0x42, 0x6f, 0x64, 0x79, 0x20, 0x57, 0x65, 0x69,
|
||||
0x67, 0x68, 0x74, 0x20, 0x53, 0x63, 0x61, 0x6c, 0x65,
|
||||
0x09, 0x09, 0x09, 0x0d, 0x35, 0x17, 0x08, 0x0a, 0x09,
|
||||
0x10, 0x11, 0x08, 0x01, 0x25, 0x0e, 0x47, 0x6c, 0x75,
|
||||
0x63, 0x6f, 0x73, 0x65, 0x20, 0x4d, 0x65, 0x74, 0x65,
|
||||
0x72, 0x0d, 0x09, 0x03, 0x01, 0x08, 0x01, 0x09, 0x03,
|
||||
0x02, 0x08, 0x00,
|
||||
0x00 };
|
||||
|
||||
static void hdp_sdp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
|
||||
{
|
||||
struct test_data *t_data = tester_get_data();
|
||||
struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
|
||||
struct emu_cid_data *cid_data = user_data;
|
||||
|
||||
hdp_rsp_pdu[1] = ((uint8_t *) data)[1];
|
||||
hdp_rsp_pdu[2] = ((uint8_t *) data)[2];
|
||||
|
||||
bthost_send_cid(bthost, cid_data->sdp_handle, cid_data->sdp_cid,
|
||||
hdp_rsp_pdu, sizeof(hdp_rsp_pdu));
|
||||
}
|
||||
|
||||
static void hdp_sdp_search_cb(uint16_t handle, uint16_t cid, void *user_data)
|
||||
{
|
||||
struct test_data *data = tester_get_data();
|
||||
struct bthost *bthost = hciemu_client_get_host(data->hciemu);
|
||||
|
||||
cid_data.sdp_handle = handle;
|
||||
cid_data.sdp_cid = cid;
|
||||
|
||||
bthost_add_cid_hook(bthost, handle, cid, hdp_sdp_cid_hook_cb,
|
||||
&cid_data);
|
||||
}
|
||||
|
||||
static void mcap_ctrl_cid_hook_cb(const void *data, uint16_t len,
|
||||
void *user_data)
|
||||
{
|
||||
struct test_data *t_data = tester_get_data();
|
||||
struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
|
||||
uint8_t crt_rsp[5], del_rsp[4], config;
|
||||
uint8_t opcode = ((uint8_t *) data)[0];
|
||||
static bool reliable = false;
|
||||
|
||||
switch (opcode) {
|
||||
case 0x01: /* MD_CREATE_MDL_REQ */
|
||||
crt_rsp[0] = 0x02; /* MD_CREATE_MDL_RSP */
|
||||
crt_rsp[1] = 0x00; /* Response code - Success */
|
||||
crt_rsp[2] = ((uint8_t *) data)[1]; /* mdlid */
|
||||
crt_rsp[3] = ((uint8_t *) data)[2];
|
||||
config = ((uint8_t *) data)[4];
|
||||
|
||||
if (config == 0x00) {
|
||||
if (!reliable) {
|
||||
crt_rsp[4] = 0x01;
|
||||
reliable = true;
|
||||
} else {
|
||||
crt_rsp[4] = 0x02;
|
||||
reliable = false;
|
||||
}
|
||||
} else {
|
||||
crt_rsp[4] = config;
|
||||
}
|
||||
|
||||
bthost_send_cid(bthost, cid_data.ctrl_handle,
|
||||
cid_data.ctrl_cid,
|
||||
crt_rsp, sizeof(crt_rsp));
|
||||
break;
|
||||
case 0x03: /* MD_RECONNECT_MDL_REQ */
|
||||
case 0x05: /* MD_ABORT_MDL_REQ */
|
||||
break;
|
||||
case 0x07: /* MD_DELETE_MDL_REQ */
|
||||
del_rsp[0] = 0x08; /* MD_DELETE_MDL_RSP */
|
||||
del_rsp[1] = 0x00; /* Response code - Success */
|
||||
del_rsp[2] = ((uint8_t *) data)[1]; /* mdlid */
|
||||
del_rsp[3] = ((uint8_t *) data)[2];
|
||||
bthost_send_cid(bthost, cid_data.ctrl_handle,
|
||||
cid_data.ctrl_cid,
|
||||
del_rsp, sizeof(del_rsp));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void mcap_ctrl_connect_cb(uint16_t handle, uint16_t cid, void *user_data)
|
||||
{
|
||||
struct test_data *data = tester_get_data();
|
||||
struct bthost *bthost = hciemu_client_get_host(data->hciemu);
|
||||
|
||||
cid_data.ctrl_handle = handle;
|
||||
cid_data.ctrl_cid = cid;
|
||||
|
||||
bthost_add_cid_hook(bthost, handle, cid, mcap_ctrl_cid_hook_cb,
|
||||
&cid_data);
|
||||
}
|
||||
|
||||
static void mcap_data_cid_hook_cb(const void *data, uint16_t len,
|
||||
void *user_data)
|
||||
{
|
||||
}
|
||||
|
||||
static void mcap_data_connect_cb(uint16_t handle, uint16_t cid, void *user_data)
|
||||
{
|
||||
struct test_data *data = tester_get_data();
|
||||
struct bthost *bthost = hciemu_client_get_host(data->hciemu);
|
||||
|
||||
cid_data.data_handle = handle;
|
||||
cid_data.data_cid = cid;
|
||||
|
||||
bthost_add_cid_hook(bthost, handle, cid, mcap_data_cid_hook_cb,
|
||||
&cid_data);
|
||||
}
|
||||
|
||||
/* Emulate SDP (PSM = 1) */
|
||||
static struct emu_set_l2cap_data l2cap_setup_sdp_data = {
|
||||
.psm = 1,
|
||||
.func = hdp_sdp_search_cb,
|
||||
.user_data = NULL,
|
||||
};
|
||||
|
||||
/* Emulate Control Channel (PSM = 0x1001) */
|
||||
static struct emu_set_l2cap_data l2cap_setup_cc_data = {
|
||||
.psm = 0x1001,
|
||||
.func = mcap_ctrl_connect_cb,
|
||||
.user_data = NULL,
|
||||
};
|
||||
|
||||
/* Emulate Data Channel (PSM = 0x1003) */
|
||||
static struct emu_set_l2cap_data l2cap_setup_dc_data = {
|
||||
.psm = 0x1003,
|
||||
.func = mcap_data_connect_cb,
|
||||
.user_data = NULL,
|
||||
};
|
||||
|
||||
static void hdp_connect_source_reliable_action(void)
|
||||
{
|
||||
struct test_data *data = tester_get_data();
|
||||
const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
|
||||
struct step *step = g_new0(struct step, 1);
|
||||
bt_bdaddr_t bdaddr;
|
||||
int app_id, channel_id, mdep_cfg_index;
|
||||
|
||||
bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
|
||||
app_id = 1;
|
||||
mdep_cfg_index = 0;
|
||||
channel_id = 0;
|
||||
step->action_status = data->if_hdp->connect_channel(app_id, &bdaddr,
|
||||
mdep_cfg_index, &channel_id);
|
||||
|
||||
schedule_action_verification(step);
|
||||
}
|
||||
|
||||
static struct test_case test_cases[] = {
|
||||
TEST_CASE_BREDRLE("HDP Init",
|
||||
ACTION_SUCCESS(dummy_action, NULL),
|
||||
@ -205,6 +414,27 @@ static struct test_case test_cases[] = {
|
||||
CALLBACK_HDP_APP_REG_STATE(CB_HDP_APP_REG_STATE, 1,
|
||||
BTHL_APP_REG_STATE_DEREG_SUCCESS),
|
||||
),
|
||||
TEST_CASE_BREDRLE("HDP Connect Source Reliable Channel",
|
||||
ACTION_SUCCESS(bluetooth_enable_action, NULL),
|
||||
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
|
||||
ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
|
||||
ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
|
||||
ACTION_SUCCESS(emu_add_l2cap_server_action,
|
||||
&l2cap_setup_sdp_data),
|
||||
ACTION_SUCCESS(emu_add_l2cap_server_action,
|
||||
&l2cap_setup_cc_data),
|
||||
ACTION_SUCCESS(emu_add_l2cap_server_action,
|
||||
&l2cap_setup_dc_data),
|
||||
ACTION_SUCCESS(hdp_register_source_reliable_app_action, NULL),
|
||||
CALLBACK_HDP_APP_REG_STATE(CB_HDP_APP_REG_STATE, 1,
|
||||
BTHL_APP_REG_STATE_REG_SUCCESS),
|
||||
ACTION_SUCCESS(hdp_connect_source_reliable_action, NULL),
|
||||
CALLBACK_HDP_CHANNEL_STATE(CB_HDP_CHANNEL_STATE, 1, 1, 0,
|
||||
BTHL_CONN_STATE_CONNECTING),
|
||||
CALLBACK_HDP_CHANNEL_STATE(CB_HDP_CHANNEL_STATE, 1, 1, 0,
|
||||
BTHL_CONN_STATE_CONNECTED),
|
||||
),
|
||||
|
||||
};
|
||||
|
||||
struct queue *get_hdp_tests(void)
|
||||
|
Loading…
Reference in New Issue
Block a user