uint16_t setup_expect_hci_command;
const void *setup_expect_hci_param;
uint8_t setup_expect_hci_len;
+ uint16_t setup_send_opcode;
+ const void *setup_send_param;
+ uint16_t setup_send_len;
bool send_index_none;
uint16_t send_opcode;
const void *send_param;
static const struct generic_data stop_discovery_success_test_1 = {
.setup_settings = settings_powered_le,
+ .setup_send_opcode = MGMT_OP_START_DISCOVERY,
.send_opcode = MGMT_OP_STOP_DISCOVERY,
.send_param = stop_discovery_bredrle_param,
.send_len = sizeof(stop_discovery_bredrle_param),
static const struct generic_data stop_discovery_bredr_success_test_1 = {
.setup_settings = settings_powered,
+ .setup_send_opcode = MGMT_OP_START_DISCOVERY,
+ .setup_send_param = start_discovery_bredr_param,
+ .setup_send_len = sizeof(start_discovery_bredr_param),
.send_opcode = MGMT_OP_STOP_DISCOVERY,
.send_param = stop_discovery_bredr_param,
.send_len = sizeof(stop_discovery_bredr_param),
static const struct generic_data stop_discovery_invalid_param_test_1 = {
.setup_settings = settings_powered_le,
+ .setup_send_opcode = MGMT_OP_START_DISCOVERY,
+ .setup_send_param = start_discovery_bredrle_param,
+ .setup_send_len = sizeof(start_discovery_bredrle_param),
.send_opcode = MGMT_OP_STOP_DISCOVERY,
.send_param = stop_discovery_bredrle_invalid_param,
.send_len = sizeof(stop_discovery_bredrle_invalid_param),
tester_setup_complete();
}
-static bool setup_command_hci_callback(const void *data, uint16_t len,
- void *user_data)
-{
- struct test_data *tdata = tester_get_data();
- const struct generic_data *test = tdata->test_data;
-
- tester_print("HCI Command 0x%04x length %u (setup)",
- test->setup_expect_hci_command, len);
-
- if (len != test->setup_expect_hci_len) {
- tester_warn("Invalid parameter size for HCI command (setup)");
- tester_setup_failed();
- goto done;
- }
-
- if (memcmp(data, test->setup_expect_hci_param, len) != 0) {
- tester_warn("Unexpected HCI command parameter value (setup)");
- tester_setup_failed();
- goto done;
- }
-
- tester_setup_complete();
-
-done:
- hciemu_del_hook(tdata->hciemu, HCIEMU_HOOK_PRE_EVT,
- test->setup_expect_hci_command);
-
- return false;
-}
-
static void setup_start_discovery(const void *test_data)
{
struct test_data *data = tester_get_data();
const struct generic_data *test = data->test_data;
- const void *send_param = test->send_param;
- uint16_t send_len = test->send_len;
+ const void *send_param = test->setup_send_param;
+ uint16_t send_len = test->setup_send_len;
+ unsigned char disc_param[] = { 0x07 };
- if (test->setup_expect_hci_command) {
- tester_print("Registering HCI command callback (setup)");
- hciemu_add_hook(data->hciemu, HCIEMU_HOOK_PRE_EVT,
- test->setup_expect_hci_command,
- setup_command_hci_callback,
- NULL);
-
- mgmt_send(data->mgmt, MGMT_OP_START_DISCOVERY, data->mgmt_index,
- send_len, send_param, NULL, NULL, NULL);
- } else {
- unsigned char disc_param[] = { 0x07 };
-
- mgmt_send(data->mgmt, MGMT_OP_START_DISCOVERY, data->mgmt_index,
- sizeof(disc_param), disc_param,
- setup_discovery_callback, NULL, NULL);
+ if (!send_param) {
+ send_param = disc_param;
+ send_len = 1;
}
+
+ mgmt_send(data->mgmt, test->setup_send_opcode, data->mgmt_index,
+ send_len, send_param, setup_discovery_callback,
+ NULL, NULL);
}
static void setup_multi_uuid32(const void *test_data)