All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaganath Kanakkassery <jaganath.k.os@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: marcel@holtmann.org, johan.hedberg@gmail.com,
	Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Subject: [PATCH BlueZ v2 5/7] mgmt-tester: Add tests for extended scanning and device found
Date: Wed, 25 Jul 2018 15:51:24 +0530	[thread overview]
Message-ID: <1532514086-14790-6-git-send-email-jaganathx.kanakkassery@intel.com> (raw)
In-Reply-To: <1532514086-14790-1-git-send-email-jaganathx.kanakkassery@intel.com>

---
 tools/mgmt-tester.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 245 insertions(+)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index c32f27a..615b968 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -8183,6 +8183,206 @@ static const struct generic_data set_phy_invalid_param = {
 	.expect_status = MGMT_STATUS_INVALID_PARAMS,
 };
 
+static const char start_discovery_valid_ext_scan_enable[] = {
+	0x01,
+	0x01,
+	0x00, 0x00,
+	0x00, 0x00
+};
+
+static const struct generic_data start_discovery_bredrle_ext_scan_enable = {
+	.setup_settings = settings_powered_le,
+	.send_opcode = MGMT_OP_START_DISCOVERY,
+	.send_param = start_discovery_bredrle_param,
+	.send_len = sizeof(start_discovery_bredrle_param),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_param = start_discovery_bredrle_param,
+	.expect_len = sizeof(start_discovery_bredrle_param),
+	.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_ENABLE,
+	.expect_hci_param = start_discovery_valid_ext_scan_enable,
+	.expect_hci_len = sizeof(start_discovery_valid_ext_scan_enable),
+	.expect_alt_ev = MGMT_EV_DISCOVERING,
+	.expect_alt_ev_param = start_discovery_evt,
+	.expect_alt_ev_len = sizeof(start_discovery_evt),
+};
+
+static const struct generic_data start_discovery_le_ext_scan_enable = {
+	.setup_settings = settings_powered_le,
+	.send_opcode = MGMT_OP_START_DISCOVERY,
+	.send_param = start_discovery_le_param,
+	.send_len = sizeof(start_discovery_le_param),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_param = start_discovery_le_param,
+	.expect_len = sizeof(start_discovery_le_param),
+	.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_ENABLE,
+	.expect_hci_param = start_discovery_valid_ext_scan_enable,
+	.expect_hci_len = sizeof(start_discovery_valid_ext_scan_enable),
+	.expect_alt_ev = MGMT_EV_DISCOVERING,
+	.expect_alt_ev_param = start_discovery_le_evt,
+	.expect_alt_ev_len = sizeof(start_discovery_le_evt),
+};
+
+static const char start_discovery_valid_ext_scan_param[] = {
+	0x01,			/* Own Addr type*/
+	0x00,			/* Scan filter policy*/
+	0x01,			/*Phys - 1m */
+	0x01,			/* Type */
+	0x12, 0x00,		/* Interval */
+	0x12, 0x00,		/* Window */
+};
+
+static const struct generic_data start_discovery_le_ext_scan_param = {
+	.setup_settings = settings_powered_le,
+	.send_opcode = MGMT_OP_START_DISCOVERY,
+	.send_param = start_discovery_le_param,
+	.send_len = sizeof(start_discovery_le_param),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_param = start_discovery_le_param,
+	.expect_len = sizeof(start_discovery_le_param),
+	.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_PARAMS,
+	.expect_hci_param = start_discovery_valid_ext_scan_param,
+	.expect_hci_len = sizeof(start_discovery_valid_ext_scan_param),
+	.expect_alt_ev = MGMT_EV_DISCOVERING,
+	.expect_alt_ev_param = start_discovery_le_evt,
+	.expect_alt_ev_len = sizeof(start_discovery_le_evt),
+};
+
+static const char stop_discovery_valid_ext_scan_disable[] = {
+	0x00,
+	0x00,
+	0x00, 0x00,
+	0x00, 0x00
+};
+
+static const struct generic_data stop_discovery_le_ext_scan_disable = {
+	.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_param,
+	.send_len = sizeof(stop_discovery_bredrle_param),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_param = stop_discovery_bredrle_param,
+	.expect_len = sizeof(stop_discovery_bredrle_param),
+	.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_ENABLE,
+	.expect_hci_param = stop_discovery_valid_ext_scan_disable,
+	.expect_hci_len = sizeof(stop_discovery_valid_ext_scan_disable),
+	.expect_alt_ev = MGMT_EV_DISCOVERING,
+	.expect_alt_ev_param = stop_discovery_evt,
+	.expect_alt_ev_len = sizeof(stop_discovery_evt),
+};
+
+static const struct generic_data start_discovery_le_2m_scan_param = {
+	.setup_settings = settings_powered_le,
+	.setup_send_opcode = MGMT_OP_SET_PHY_CONFIGURATION,
+	.setup_send_param = set_phy_2m_param,
+	.setup_send_len = sizeof(set_phy_2m_param),
+	.send_opcode = MGMT_OP_START_DISCOVERY,
+	.send_param = start_discovery_bredrle_param,
+	.send_len = sizeof(start_discovery_bredrle_param),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_param = start_discovery_bredrle_param,
+	.expect_len = sizeof(start_discovery_bredrle_param),
+	.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_PARAMS,
+	.expect_hci_param = start_discovery_valid_ext_scan_param,
+	.expect_hci_len = sizeof(start_discovery_valid_ext_scan_param),
+	.expect_alt_ev = MGMT_EV_DISCOVERING,
+	.expect_alt_ev_param = start_discovery_evt,
+	.expect_alt_ev_len = sizeof(start_discovery_evt),
+};
+
+static const char start_discovery_valid_coded_scan_param[] = {
+	0x01,			/* Own Addr type*/
+	0x00,			/* Scan filter policy*/
+	0x05,			/*Phys - 1m & coded */
+	0x01,			/* Type */
+	0x12, 0x00,		/* Interval */
+	0x12, 0x00,		/* Window */
+	0x01,			/* Type */
+	0x12, 0x00,		/* Interval */
+	0x12, 0x00,		/* Window */
+};
+
+static const struct generic_data start_discovery_le_coded_scan_param = {
+	.setup_settings = settings_powered_le,
+	.setup_send_opcode = MGMT_OP_SET_PHY_CONFIGURATION,
+	.setup_send_param = set_phy_coded_param,
+	.setup_send_len = sizeof(set_phy_coded_param),
+	.send_opcode = MGMT_OP_START_DISCOVERY,
+	.send_param = start_discovery_bredrle_param,
+	.send_len = sizeof(start_discovery_bredrle_param),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_param = start_discovery_bredrle_param,
+	.expect_len = sizeof(start_discovery_bredrle_param),
+	.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_PARAMS,
+	.expect_hci_param = start_discovery_valid_coded_scan_param,
+	.expect_hci_len = sizeof(start_discovery_valid_coded_scan_param),
+	.expect_alt_ev = MGMT_EV_DISCOVERING,
+	.expect_alt_ev_param = start_discovery_evt,
+	.expect_alt_ev_len = sizeof(start_discovery_evt),
+};
+
+static const char start_discovery_valid_1m_2m_coded_scan_param[] = {
+	0x01,			/* Own Addr type*/
+	0x00,			/* Scan filter policy*/
+	0x05,			/*Phys - 1m, coded */
+	0x01,			/* Type */
+	0x12, 0x00,		/* Interval */
+	0x12, 0x00,		/* Window */
+	0x01,			/* Type */
+	0x12, 0x00,		/* Interval */
+	0x12, 0x00,		/* Window */
+};
+
+static const struct generic_data start_discovery_le_1m_coded_scan_param = {
+	.setup_settings = settings_powered_le,
+	.setup_send_opcode = MGMT_OP_SET_PHY_CONFIGURATION,
+	.setup_send_param = set_phy_all_param,
+	.setup_send_len = sizeof(set_phy_all_param),
+	.send_opcode = MGMT_OP_START_DISCOVERY,
+	.send_param = start_discovery_bredrle_param,
+	.send_len = sizeof(start_discovery_bredrle_param),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_param = start_discovery_bredrle_param,
+	.expect_len = sizeof(start_discovery_bredrle_param),
+	.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_PARAMS,
+	.expect_hci_param = start_discovery_valid_1m_2m_coded_scan_param,
+	.expect_hci_len = sizeof(start_discovery_valid_1m_2m_coded_scan_param),
+	.expect_alt_ev = MGMT_EV_DISCOVERING,
+	.expect_alt_ev_param = start_discovery_evt,
+	.expect_alt_ev_len = sizeof(start_discovery_evt),
+};
+
+static void set_phy_callback(uint8_t status, uint16_t length,
+					const void *param, void *user_data)
+{
+	if (status != MGMT_STATUS_SUCCESS) {
+		tester_setup_failed();
+		return;
+	}
+
+	tester_print("Set PHY Success");
+
+	tester_setup_complete();
+}
+
+static void setup_phy_configuration(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct generic_data *test = data->test_data;
+	const void *send_param = test->setup_send_param;
+	uint16_t send_len = test->setup_send_len;
+	unsigned int id;
+
+	id = mgmt_register(data->mgmt, MGMT_EV_DISCOVERING, data->mgmt_index,
+			   discovering_event, NULL, NULL);
+	data->mgmt_discov_ev_id = id;
+
+	mgmt_send(data->mgmt, test->setup_send_opcode, data->mgmt_index,
+				send_len, send_param, set_phy_callback,
+				NULL, NULL);
+}
 
 static bool power_off(uint16_t index)
 {
@@ -8310,6 +8510,12 @@ static void trigger_device_found(void *user_data)
 							test->adv_data_len);
 
 		bthost_set_adv_enable(bthost, 0x01);
+	} else if (data->hciemu_type == HCIEMU_TYPE_BREDRLE50) {
+		if (test->set_adv)
+			bthost_set_ext_adv_data(bthost, test->adv_data,
+							test->adv_data_len);
+
+		bthost_set_ext_adv_enable(bthost, 0x01);
 	}
 
 	if (data->hciemu_type != HCIEMU_TYPE_LE)
@@ -9947,5 +10153,44 @@ int main(int argc, char *argv[])
 	test_bredrle50("Set PHY Invalid Param", &set_phy_invalid_param,
 					NULL, test_command_generic);
 
+	test_bredrle50("Start Discovery BREDR LE - (Ext Scan Enable)",
+					&start_discovery_bredrle_ext_scan_enable,
+					NULL,
+					test_command_generic);
+
+	test_bredrle50("Start Discovery LE - (Ext Scan Enable)",
+					&start_discovery_le_ext_scan_enable,
+					NULL,
+					test_command_generic);
+
+	test_bredrle50("Start Discovery LE - (Ext Scan Param)",
+					&start_discovery_le_ext_scan_param,
+					NULL,
+					test_command_generic);
+
+	test_bredrle50("Stop Discovery - (Ext Scan Disable)",
+				&stop_discovery_le_ext_scan_disable,
+				setup_start_discovery, test_command_generic);
+
+	test_bredrle50("Start Discovery - (2m, Scan Param)",
+				&start_discovery_le_2m_scan_param,
+				setup_phy_configuration, test_command_generic);
+
+	test_bredrle50("Start Discovery - (coded, Scan Param)",
+				&start_discovery_le_coded_scan_param,
+				setup_phy_configuration, test_command_generic);
+
+	test_bredrle50("Start Discovery - (1m, 2m, coded, Scan Param)",
+				&start_discovery_le_1m_coded_scan_param,
+				setup_phy_configuration, test_command_generic);
+
+	test_bredrle50("Ext Device Found - Advertising data - Zero padded",
+				&device_found_gtag,
+				NULL, test_device_found);
+
+	test_bredrle50("Ext Device Found - Advertising data - Invalid field",
+				&device_found_invalid_field,
+				NULL, test_device_found);
+
 	return tester_run();
 }
-- 
2.7.4

  parent reply	other threads:[~2018-07-25 10:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-25 10:21 [PATCH BlueZ v2 0/7] Add BREDR PHYs in PHY configuration commands Jaganath Kanakkassery
2018-07-25 10:21 ` [PATCH BlueZ v2 1/7] monitor: " Jaganath Kanakkassery
2018-07-25 10:21 ` [PATCH BlueZ v2 2/7] emulator: Add BREDR 2M & 3M, 3 & 5 Slot packet type support Jaganath Kanakkassery
2018-07-25 10:21 ` [PATCH BlueZ v2 3/7] mgmt-tester: Add extended advertising test cases Jaganath Kanakkassery
2018-07-25 10:21 ` [PATCH BlueZ v2 4/7] mgmt-tester: Add PHY Configuration " Jaganath Kanakkassery
2018-07-25 10:21 ` Jaganath Kanakkassery [this message]
2018-07-25 10:21 ` [PATCH BlueZ v2 6/7] mgmt-tester: Add support ext create connection and enh conn complete Jaganath Kanakkassery
2018-07-25 10:21 ` [PATCH BlueZ v2 7/7] mgmt-tester: Update Supported_settings to reflect PHY_CONFIGURATION Jaganath Kanakkassery
2018-07-26  8:02 ` [PATCH BlueZ v2 0/7] Add BREDR PHYs in PHY configuration commands Johan Hedberg
2018-07-26 11:25   ` Jaganath K
2018-07-30 12:03 ` Johan Hedberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1532514086-14790-6-git-send-email-jaganathx.kanakkassery@intel.com \
    --to=jaganath.k.os@gmail.com \
    --cc=jaganathx.kanakkassery@intel.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.