linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jaganath Kanakkassery <jaganath.k.os@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
Subject: [PATCH BlueZ v2 10/11] mgmt-tester: Add tests for extended scanning and device found
Date: Tue, 24 Apr 2018 19:30:46 +0530	[thread overview]
Message-ID: <1524578447-17347-11-git-send-email-jaganathx.kanakkassery@intel.com> (raw)
In-Reply-To: <1524578447-17347-1-git-send-email-jaganathx.kanakkassery@intel.com>

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

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 7485318..e5076b5 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -8374,6 +8374,205 @@ 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*/
+	0x04,			/*Phys - coded */
+	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 set_phy_1m_2m_coded_param[] = { 0x3f, 0x00 };
+
+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_1m_2m_coded_param,
+	.setup_send_len = sizeof(set_phy_1m_2m_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_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)
 {
@@ -8501,6 +8700,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)
@@ -10138,5 +10343,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-04-24 14:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-24 14:00 [PATCH BlueZ v2 00/11] Extended Adv, Scan, Connection and PHY support Jaganath Kanakkassery
2018-04-24 14:00 ` [PATCH BlueZ v2 01/11] doc/mgmt-api: Add support for Set Phy Configuration command Jaganath Kanakkassery
2018-04-24 14:00 ` [PATCH BlueZ v2 02/11] doc/mgmt-api: Add advertising phys support to flags Jaganath Kanakkassery
2018-04-24 14:00 ` [PATCH BlueZ v2 03/11] monitor: Add support PHY management commands and event Jaganath Kanakkassery
2018-04-24 14:00 ` [PATCH BlueZ v2 04/11] btmgmt: Add PHY configuration get/set commands Jaganath Kanakkassery
2018-06-13  8:43   ` Luiz Augusto von Dentz
2018-04-24 14:00 ` [PATCH BlueZ v2 05/11] monitor: Add support for Secondary PHY flags in Add Advertising Jaganath Kanakkassery
2018-04-24 14:00 ` [PATCH BlueZ v2 06/11] btmgmt: Add support for setting PHY in add-adv Jaganath Kanakkassery
2018-04-24 14:00 ` [PATCH BlueZ v2 07/11] emulator: Add 5.0 feature support Jaganath Kanakkassery
2018-06-13  8:19   ` Luiz Augusto von Dentz
2018-04-24 14:00 ` [PATCH BlueZ v2 08/11] mgmt-tester: Add extended advertising test cases Jaganath Kanakkassery
2018-04-24 14:00 ` [PATCH BlueZ v2 09/11] mgmt-tester: Add PHY Configuration " Jaganath Kanakkassery
2018-04-24 14:00 ` Jaganath Kanakkassery [this message]
2018-04-24 14:00 ` [PATCH BlueZ v2 11/11] mgmt-tester: Add support ext create connection and enh conn complete Jaganath Kanakkassery
2018-06-06  5:50 ` [PATCH BlueZ v2 00/11] Extended Adv, Scan, Connection and PHY support Jaganath K
2018-06-13  8:09   ` Luiz Augusto von Dentz
2018-06-13  8:22     ` Luiz Augusto von Dentz

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=1524578447-17347-11-git-send-email-jaganathx.kanakkassery@intel.com \
    --to=jaganath.k.os@gmail.com \
    --cc=jaganathx.kanakkassery@intel.com \
    --cc=linux-bluetooth@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).