2018-07-06 11:27:57

by Jaganath K

[permalink] [raw]
Subject: [PATCH BlueZ 0/8] Add BREDR PHYs in PHY configuration commands

This also has mgmt-tester patches for 5.0 implementation

Jaganath Kanakkassery (8):
monitor: Fix 2-DH5 packet type print
btmgmt: Add BREDR PHYs in PHY Configuration commands
monitor: Add BREDR PHYs in PHY configuration commands
emulator: Add BREDR 2M & 3M, 3 & 5 Slot packet type support
mgmt-tester: Add extended advertising test cases
mgmt-tester: Add PHY Configuration test cases
mgmt-tester: Add tests for extended scanning and device found
mgmt-tester: Add support ext create connection and enh conn complete

emulator/btdev.c | 10 +
lib/mgmt.h | 32 +-
monitor/packet.c | 41 +-
tools/btmgmt.c | 62 +-
tools/mgmt-tester.c | 2255 ++++++++++++++++++++++++++++++++++++++++++++++++---
5 files changed, 2248 insertions(+), 152 deletions(-)

--
2.7.4


2018-07-19 09:54:07

by Jaganath K

[permalink] [raw]
Subject: Re: [PATCH BlueZ 1/8] monitor: Fix 2-DH5 packet type print

Hi,

On Fri, Jul 6, 2018 at 4:57 PM, Jaganath Kanakkassery
<[email protected]> wrote:
> 3-DH5 is printed instaed of 2-DH5
> ---
> monitor/packet.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/monitor/packet.c b/monitor/packet.c
> index 6798373..bf69859 100644
> --- a/monitor/packet.c
> +++ b/monitor/packet.c
> @@ -762,7 +762,7 @@ static const struct {
> { 9, "3-DH3 may not be used" },
> { 10, "DM3 may be used" },
> { 11, "DH3 may be used" },
> - { 12, "3-DH5 may not be used" },
> + { 12, "2-DH5 may not be used" },
> { 13, "3-DH5 may not be used" },
> { 14, "DM5 may be used" },
> { 15, "DH5 may be used" },

This is a bug fix in the existing code and is independent of 5.0 changes.

Thanks,
Jaganath

2018-07-06 11:28:05

by Jaganath K

[permalink] [raw]
Subject: [PATCH BlueZ 8/8] mgmt-tester: Add support ext create connection and enh conn complete

---
tools/mgmt-tester.c | 49 ++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 42 insertions(+), 7 deletions(-)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index d4ebdb6..8f65478 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -5292,6 +5292,7 @@ static void client_cmd_complete(uint16_t opcode, uint8_t status,
switch (opcode) {
case BT_HCI_CMD_WRITE_SCAN_ENABLE:
case BT_HCI_CMD_LE_SET_ADV_ENABLE:
+ case BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE:
tester_print("Client set connectable: %s (0x%02x)",
mgmt_errstr(status), status);
if (!status && test->client_enable_ssp) {
@@ -5321,9 +5322,14 @@ static void setup_bthost(void)

bthost = hciemu_client_get_host(data->hciemu);
bthost_set_cmd_complete_cb(bthost, client_cmd_complete, data);
- if (data->hciemu_type == HCIEMU_TYPE_LE || test->client_enable_adv)
- bthost_set_adv_enable(bthost, 0x01);
- else
+
+ if (data->hciemu_type == HCIEMU_TYPE_LE ||
+ test->client_enable_adv) {
+ if (data->hciemu_type == HCIEMU_TYPE_BREDRLE50)
+ bthost_set_ext_adv_enable(bthost, 0x01);
+ else
+ bthost_set_adv_enable(bthost, 0x01);
+ } else
bthost_write_scan_enable(bthost, 0x03);
}

@@ -8868,9 +8874,15 @@ static void le_connected_event(uint16_t index, uint16_t length,
tester_print("Device connected");

test_add_condition(data);
- hciemu_add_hook(data->hciemu, HCIEMU_HOOK_POST_CMD,
- BT_HCI_CMD_LE_SET_ADV_ENABLE,
- test_adv_enable_hook, data);
+
+ if (data->hciemu_type == HCIEMU_TYPE_BREDRLE50)
+ hciemu_add_hook(data->hciemu, HCIEMU_HOOK_POST_CMD,
+ BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE,
+ test_adv_enable_hook, data);
+ else
+ hciemu_add_hook(data->hciemu, HCIEMU_HOOK_POST_CMD,
+ BT_HCI_CMD_LE_SET_ADV_ENABLE,
+ test_adv_enable_hook, data);

/* Make sure we get not disconnected during the testaces */
mgmt_register(data->mgmt_alt, MGMT_EV_DEVICE_DISCONNECTED,
@@ -8910,7 +8922,10 @@ static void add_device_callback(uint8_t status, uint16_t len, const void *param,
}

bthost = hciemu_client_get_host(data->hciemu);
- bthost_hci_connect(bthost, master_bdaddr, BDADDR_LE_PUBLIC);
+ if (data->hciemu_type == HCIEMU_TYPE_BREDRLE50)
+ bthost_hci_ext_connect(bthost, master_bdaddr, BDADDR_LE_PUBLIC);
+ else
+ bthost_hci_connect(bthost, master_bdaddr, BDADDR_LE_PUBLIC);
}

static void test_connected_and_advertising(const void *test_data)
@@ -10384,5 +10399,25 @@ int main(int argc, char *argv[])
&device_found_invalid_field,
NULL, test_device_found);

+ test_bredrle50_full("Ext Adv. connectable & connected (slave) - Success",
+ &conn_slave_adv_conneactable_test,
+ setup_advertise_while_connected,
+ test_connected_and_advertising, 10);
+
+ test_bredrle50_full("Ext Adv. non-connectable & connected (slave) - Success",
+ &conn_slave_adv_non_conneactable_test,
+ setup_advertise_while_connected,
+ test_connected_and_advertising, 10);
+
+ test_bredrle50_full("Ext Adv. connectable & connected (master) - Success",
+ &conn_master_adv_conneactable_test,
+ setup_advertise_while_connected,
+ test_connected_and_advertising, 10);
+
+ test_bredrle50_full("Ext Adv. non-connectable & connected (master) - Success",
+ &conn_master_adv_non_conneactable_test,
+ setup_advertise_while_connected,
+ test_connected_and_advertising, 10);
+
return tester_run();
}
--
2.7.4

2018-07-06 11:28:04

by Jaganath K

[permalink] [raw]
Subject: [PATCH BlueZ 7/8] mgmt-tester: Add tests for extended scanning and device found

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

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 20d939f..d4ebdb6 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -8375,6 +8375,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)
{
@@ -8502,6 +8702,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)
@@ -10139,5 +10345,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

2018-07-06 11:28:03

by Jaganath K

[permalink] [raw]
Subject: [PATCH BlueZ 6/8] mgmt-tester: Add PHY Configuration test cases

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

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 0136b93..20d939f 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -8216,6 +8216,166 @@ static const struct generic_data add_ext_advertising_conn_off_1m = {
.expect_hci_len = sizeof(set_connectable_off_ext_1m_adv_param),
};

+static const uint8_t get_phy_param[] = {
+ 0xff, 0x7f, 0x00, 0x00, /* All PHYs */
+ 0xfe, 0x79, 0x00, 0x00, /* All PHYs except BR 1M 1SLOT, LE 1M TX & LE 1M RX */
+ 0xff, 0x07, 0x00, 0x00, /* All BREDR PHYs and LE 1M TX & LE 1M RX */
+};
+
+static const struct generic_data get_phy_success = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_GET_PHY_CONFIGURATION,
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = get_phy_param,
+ .expect_len = sizeof(get_phy_param),
+};
+
+static const uint8_t set_phy_2m_param[] = {
+ 0xff, 0x1f, 0x00, 0x00 /* 1mtxrx 2mtxrx */
+};
+
+static const uint8_t set_default_phy_2m_param[] = {
+ 0x00, /* preference is there for tx and rx */
+ 0x03, /* 1mtx, 2mtx */
+ 0x03, /* 1mrx, 2mrx */
+};
+
+static const struct generic_data set_phy_2m_success = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_SET_PHY_CONFIGURATION,
+ .send_param = set_phy_2m_param,
+ .send_len = sizeof(set_phy_2m_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_DEFAULT_PHY,
+ .expect_hci_param = set_default_phy_2m_param,
+ .expect_hci_len = sizeof(set_default_phy_2m_param),
+ .expect_alt_ev = MGMT_EV_PHY_CONFIGURATION_CHANGED,
+ .expect_alt_ev_param = set_phy_2m_param,
+ .expect_alt_ev_len = sizeof(set_phy_2m_param),
+ .expect_settings_set = MGMT_SETTING_PHY_CONFIGURATION,
+};
+
+static const uint8_t set_phy_coded_param[] = {
+ 0xff, 0x67, 0x00, 0x00 /* 1mtx, 1m rx, codedtx codedrx */
+};
+
+static const uint8_t set_default_phy_coded_param[] = {
+ 0x00, /* preference is there for tx and rx */
+ 0x05, /* 1mtx, codedtx */
+ 0x05, /* 1mrx, codedrx */
+};
+
+static const struct generic_data set_phy_coded_success = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_SET_PHY_CONFIGURATION,
+ .send_param = set_phy_coded_param,
+ .send_len = sizeof(set_phy_coded_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_DEFAULT_PHY,
+ .expect_hci_param = set_default_phy_coded_param,
+ .expect_hci_len = sizeof(set_default_phy_coded_param),
+ .expect_alt_ev = MGMT_EV_PHY_CONFIGURATION_CHANGED,
+ .expect_alt_ev_param = set_phy_coded_param,
+ .expect_alt_ev_len = sizeof(set_phy_coded_param),
+ .expect_settings_set = MGMT_SETTING_PHY_CONFIGURATION,
+};
+
+static const uint8_t set_phy_all_param[] = {
+ 0xff, 0x7f, 0x00, 0x00 /* All PHYs */
+};
+
+static const uint8_t set_default_phy_all_param[] = {
+ 0x00, /* preference is there for tx and rx */
+ 0x07, /* 1m 2m coded tx */
+ 0x07, /* 1m 2m coded rx */
+};
+
+static const struct generic_data set_phy_all_success = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_SET_PHY_CONFIGURATION,
+ .send_param = set_phy_all_param,
+ .send_len = sizeof(set_phy_all_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_DEFAULT_PHY,
+ .expect_hci_param = set_default_phy_all_param,
+ .expect_hci_len = sizeof(set_default_phy_all_param),
+ .expect_alt_ev = MGMT_EV_PHY_CONFIGURATION_CHANGED,
+ .expect_alt_ev_param = set_phy_all_param,
+ .expect_alt_ev_len = sizeof(set_phy_all_param),
+ .expect_settings_set = MGMT_SETTING_PHY_CONFIGURATION,
+};
+
+static const uint8_t set_phy_2m_tx_param[] = {
+ 0xff, 0x0f, 0x00, 0x00 /* 1mtxrx, 2m tx */
+};
+
+static const uint8_t set_default_phy_2m_tx_param[] = {
+ 0x00,
+ 0x03, /* 1m, 2m tx */
+ 0x01, /* 1m rx */
+};
+
+static const uint8_t set_phy_2m_tx_evt_param[] = {
+ 0xff, 0x0f, 0x00, 0x00 /* 2m tx 1m rx */
+};
+
+static const struct generic_data set_phy_2m_tx_success = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_SET_PHY_CONFIGURATION,
+ .send_param = set_phy_2m_tx_param,
+ .send_len = sizeof(set_phy_2m_tx_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_DEFAULT_PHY,
+ .expect_hci_param = set_default_phy_2m_tx_param,
+ .expect_hci_len = sizeof(set_default_phy_2m_tx_param),
+ .expect_alt_ev = MGMT_EV_PHY_CONFIGURATION_CHANGED,
+ .expect_alt_ev_param = set_phy_2m_tx_evt_param,
+ .expect_alt_ev_len = sizeof(set_phy_2m_tx_evt_param),
+ .expect_settings_set = MGMT_SETTING_PHY_CONFIGURATION,
+};
+
+static const uint8_t set_phy_2m_rx_param[] = {
+ 0xff, 0x17, 0x00, 0x00 /* 1mtxrx, 2m rx */
+};
+
+static const uint8_t set_default_phy_2m_rx_param[] = {
+ 0x00,
+ 0x01,
+ 0x03, /* 2m rx */
+};
+
+static const uint8_t set_phy_2m_rx_evt_param[] = {
+ 0xff, 0x17, 0x00, 0x00 /* 2m rx 1m tx */
+};
+
+static const struct generic_data set_phy_2m_rx_success = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_SET_PHY_CONFIGURATION,
+ .send_param = set_phy_2m_rx_param,
+ .send_len = sizeof(set_phy_2m_rx_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_DEFAULT_PHY,
+ .expect_hci_param = set_default_phy_2m_rx_param,
+ .expect_hci_len = sizeof(set_default_phy_2m_rx_param),
+ .expect_alt_ev = MGMT_EV_PHY_CONFIGURATION_CHANGED,
+ .expect_alt_ev_param = set_phy_2m_rx_evt_param,
+ .expect_alt_ev_len = sizeof(set_phy_2m_rx_evt_param),
+ .expect_settings_set = MGMT_SETTING_PHY_CONFIGURATION,
+};
+
+static const uint8_t set_phy_param_invalid[] = {
+ 0x79, 0xfe, 0x00, 0x00 /* Set unconfigurable phy*/
+};
+
+static const struct generic_data set_phy_invalid_param = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_SET_PHY_CONFIGURATION,
+ .send_param = set_phy_param_invalid,
+ .send_len = sizeof(set_phy_param_invalid),
+ .expect_status = MGMT_STATUS_INVALID_PARAMS,
+};
+
+
static bool power_off(uint16_t index)
{
int sk, err;
@@ -9958,5 +10118,26 @@ int main(int argc, char *argv[])
setup_add_advertising_duration,
test_command_generic, 3);

+ test_bredrle50("Get PHY Success", &get_phy_success,
+ NULL, test_command_generic);
+
+ test_bredrle50("Set PHY 2m Success", &set_phy_2m_success,
+ NULL, test_command_generic);
+
+ test_bredrle50("Set PHY coded Succcess", &set_phy_coded_success,
+ NULL, test_command_generic);
+
+ test_bredrle50("Set PHY 1m 2m coded Succcess", &set_phy_all_success,
+ NULL, test_command_generic);
+
+ test_bredrle50("Set PHY 2m tx success", &set_phy_2m_tx_success,
+ NULL, test_command_generic);
+
+ test_bredrle50("Set PHY 2m rx success", &set_phy_2m_rx_success,
+ NULL, test_command_generic);
+
+ test_bredrle50("Set PHY Invalid Param", &set_phy_invalid_param,
+ NULL, test_command_generic);
+
return tester_run();
}
--
2.7.4

2018-07-06 11:28:02

by Jaganath K

[permalink] [raw]
Subject: [PATCH BlueZ 5/8] mgmt-tester: Add extended advertising test cases

---
tools/mgmt-tester.c | 1788 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 1697 insertions(+), 91 deletions(-)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index bc71791..0136b93 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -462,6 +462,25 @@ static void test_condition_complete(struct test_data *data)
#define test_le(name, data, setup, func) \
test_le_full(name, data, setup, func, 2)

+#define test_bredrle50_full(name, data, setup, func, timeout) \
+ do { \
+ struct test_data *user; \
+ user = new0(struct test_data, 1); \
+ user->hciemu_type = HCIEMU_TYPE_BREDRLE50; \
+ user->test_setup = setup; \
+ user->test_data = data; \
+ user->expected_version = 0x09; \
+ user->expected_manufacturer = 0x003f; \
+ user->expected_supported_settings = 0x0001bfff; \
+ user->initial_settings = 0x00000080; \
+ tester_add_full(name, data, \
+ test_pre_setup, test_setup, func, NULL, \
+ test_post_teardown, timeout, user, free); \
+ } while (0)
+
+#define test_bredrle50(name, data, setup, func) \
+ test_bredrle50_full(name, data, setup, func, 2)
+
static void controller_setup(const void *test_data)
{
tester_test_passed();
@@ -6852,120 +6871,1465 @@ static const struct generic_data set_appearance_success = {
.expect_len = 0,
};

-static bool power_off(uint16_t index)
-{
- int sk, err;
-
- sk = hci_open_dev(index);
- if (sk < 0)
- return false;
+static const uint8_t read_adv_features_rsp_3[] = {
+ 0xff, 0x03, 0x00, 0x00, /* supported flags */
+ 0x1f, /* max_adv_data_len */
+ 0x1f, /* max_scan_rsp_len */
+ 0x05, /* max_instances */
+ 0x00, /* num_instances */
+};

- err = ioctl(sk, HCIDEVDOWN, index);
+static const struct generic_data read_adv_features_success_3 = {
+ .send_opcode = MGMT_OP_READ_ADV_FEATURES,
+ .expect_param = read_adv_features_rsp_3,
+ .expect_len = sizeof(read_adv_features_rsp_3),
+ .expect_status = MGMT_STATUS_SUCCESS,
+};

- hci_close_dev(sk);
+/* add advertising with multiple phy flags */
+static const uint8_t add_ext_advertising_invalid_param_1[] = {
+ 0x01, /* adv instance */
+ 0x80, 0x01, 0x00, 0x00, /* flags: 1m and 2m*/
+ 0x00, 0x00, 0x00, 0x00, 0x09, 0x00,
+ 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03,
+};

- if (err < 0)
- return false;
+static const struct generic_data add_ext_advertising_fail_1 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_ext_advertising_invalid_param_1,
+ .send_len = sizeof(add_ext_advertising_invalid_param_1),
+ .expect_status = MGMT_STATUS_INVALID_PARAMS,
+};

- return true;
-}
+/* add advertising with multiple phy flags */
+static const uint8_t add_ext_advertising_invalid_param_2[] = {
+ 0x01, /* adv instance */
+ 0x00, 0x03, 0x00, 0x00, /* flags: 2m and coded*/
+ 0x00, 0x00, 0x00, 0x00, 0x09, 0x00,
+ 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03,
+};

-static void test_command_generic(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;
- unsigned int id;
- uint16_t index;
+static const struct generic_data add_ext_advertising_fail_2 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_ext_advertising_invalid_param_2,
+ .send_len = sizeof(add_ext_advertising_invalid_param_2),
+ .expect_status = MGMT_STATUS_INVALID_PARAMS,
+};

- index = test->send_index_none ? MGMT_INDEX_NONE : data->mgmt_index;
+/* add advertising with multiple phy flags */
+static const uint8_t add_ext_advertising_invalid_param_3[] = {
+ 0x01, /* adv instance */
+ 0x80, 0x02, 0x00, 0x00, /* flags: 1m and coded*/
+ 0x00, 0x00, 0x00, 0x00, 0x09, 0x00,
+ 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03,
+};

- if (test->expect_settings_set || test->expect_settings_unset) {
- tester_print("Registering new settings notification");
+static const struct generic_data add_ext_advertising_fail_3 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_ext_advertising_invalid_param_3,
+ .send_len = sizeof(add_ext_advertising_invalid_param_3),
+ .expect_status = MGMT_STATUS_INVALID_PARAMS,
+};

- id = mgmt_register(data->mgmt, MGMT_EV_NEW_SETTINGS, index,
- command_generic_new_settings, NULL, NULL);
- data->mgmt_settings_id = id;
+/* add advertising with multiple phy flags */
+static const uint8_t add_ext_advertising_invalid_param_4[] = {
+ 0x01, /* adv instance */
+ 0x80, 0x03, 0x00, 0x00, /* flags: 1m, 2m and coded*/
+ 0x00, 0x00, 0x00, 0x00, 0x09, 0x00,
+ 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03,
+};

- id = mgmt_register(data->mgmt_alt, MGMT_EV_NEW_SETTINGS, index,
- command_generic_new_settings_alt, NULL, NULL);
- data->mgmt_alt_settings_id = id;
- test_add_condition(data);
- }
+static const struct generic_data add_ext_advertising_fail_4 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_ext_advertising_invalid_param_4,
+ .send_len = sizeof(add_ext_advertising_invalid_param_4),
+ .expect_status = MGMT_STATUS_INVALID_PARAMS,
+};

- if (test->expect_alt_ev) {
- tester_print("Registering %s notification",
- mgmt_evstr(test->expect_alt_ev));
- id = mgmt_register(data->mgmt_alt, test->expect_alt_ev, index,
- command_generic_event_alt, NULL, NULL);
- data->mgmt_alt_ev_id = id;
- test_add_condition(data);
- }
+static const uint8_t set_ext_adv_data_uuid[] = {
+ /* handle */
+ 0x00,
+ /* complete data */
+ 0x03,
+ /* controller should not fragment */
+ 0x01,
+ /* adv data len */
+ 0x09,
+ /* advertise heart rate monitor and manufacturer specific data */
+ 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03,
+ /* padding */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00
+};

- if (test->expect_hci_command) {
- tester_print("Registering HCI command callback");
- hciemu_add_master_post_command_hook(data->hciemu,
- command_hci_callback, data);
- test_add_condition(data);
- }
+static const struct generic_data add_ext_advertising_success_1 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_uuid,
+ .send_len = sizeof(add_advertising_param_uuid),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_alt_ev = MGMT_EV_ADVERTISING_ADDED,
+ .expect_alt_ev_param = advertising_instance1_param,
+ .expect_alt_ev_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
+ .expect_hci_param = set_ext_adv_data_uuid,
+ .expect_hci_len = sizeof(set_ext_adv_data_uuid),
+};

- if (test->send_opcode == 0x0000) {
- tester_print("Executing no-op test");
- return;
- }
+static const char set_powered_ext_adv_instance_settings_param[] = {
+ 0x81, 0x02, 0x00, 0x00,
+};

- tester_print("Sending %s (0x%04x)", mgmt_opstr(test->send_opcode),
- test->send_opcode);
+static const uint8_t set_ext_adv_data_test1[] = {
+ 0x00, /* handle */
+ 0x03, /* complete data */
+ 0x01, /* controller should not fragment */
+ 0x07, /* adv data len */
+ 0x06, /* AD len */
+ 0x08, /* AD type: shortened local name */
+ 0x74, 0x65, 0x73, 0x74, 0x31, /* "test1" */
+ /* padding */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+};

- if (test->send_func)
- send_param = test->send_func(&send_len);
+static const struct generic_data add_ext_advertising_success_pwron_data = {
+ .send_opcode = MGMT_OP_SET_POWERED,
+ .send_param = set_powered_on_param,
+ .send_len = sizeof(set_powered_on_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = set_powered_adv_instance_settings_param,
+ .expect_len = sizeof(set_powered_adv_instance_settings_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
+ .expect_hci_param = set_ext_adv_data_test1,
+ .expect_hci_len = sizeof(set_ext_adv_data_test1),
+};

- if (test->force_power_off) {
- mgmt_send_nowait(data->mgmt, test->send_opcode, index,
- send_len, send_param,
- command_generic_callback, NULL, NULL);
- power_off(data->mgmt_index);
- } else {
- mgmt_send(data->mgmt, test->send_opcode, index, send_len,
- send_param, command_generic_callback,
- NULL, NULL);
- }
+static const char set_ext_adv_on_set_adv_enable_param[] = {
+ 0x01, /* Enable */
+ 0x01, /* No of sets */
+ 0x00, /* Handle */
+ 0x00, 0x00, /* Duration */
+ 0x00, /* Max events */
+};

- test_add_condition(data);
-}
+static const struct generic_data add_ext_advertising_success_pwron_enabled = {
+ .send_opcode = MGMT_OP_SET_POWERED,
+ .send_param = set_powered_on_param,
+ .send_len = sizeof(set_powered_on_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = set_powered_adv_instance_settings_param,
+ .expect_len = sizeof(set_powered_adv_instance_settings_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE,
+ .expect_hci_param = set_ext_adv_on_set_adv_enable_param,
+ .expect_hci_len = sizeof(set_ext_adv_on_set_adv_enable_param),
+};

-static void check_scan(void *user_data)
-{
- struct test_data *data = tester_get_data();
+static const uint8_t set_ext_adv_data_txpwr[] = {
+ 0x00, /* handle */
+ 0x03, /* complete data */
+ 0x01, /* controller should not fragment */
+ 0x03, /* adv data len */
+ 0x02, /* AD len */
+ 0x0a, /* AD type: tx power */
+ 0x00, /* tx power */
+ /* padding */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};

- if (hciemu_get_master_le_scan_enable(data->hciemu)) {
- tester_warn("LE scan still enabled");
- tester_test_failed();
- return;
- }
+static const struct generic_data add_ext_advertising_success_4 = {
+ .send_opcode = MGMT_OP_SET_ADVERTISING,
+ .send_param = set_adv_on_param,
+ .send_len = sizeof(set_adv_on_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = set_adv_settings_param_2,
+ .expect_len = sizeof(set_adv_settings_param_2),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
+ .expect_hci_param = set_ext_adv_data_txpwr,
+ .expect_hci_len = sizeof(set_ext_adv_data_txpwr),
+};

- if (hciemu_get_master_scan_enable(data->hciemu)) {
- tester_warn("BR/EDR scan still enabled");
- tester_test_failed();
- return;
- }
+static const struct generic_data add_ext_advertising_success_5 = {
+ .send_opcode = MGMT_OP_SET_ADVERTISING,
+ .send_param = set_adv_off_param,
+ .send_len = sizeof(set_adv_off_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = set_powered_adv_instance_settings_param,
+ .expect_len = sizeof(set_powered_adv_instance_settings_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
+ .expect_hci_param = set_ext_adv_data_test1,
+ .expect_hci_len = sizeof(set_ext_adv_data_test1),
+};

- test_condition_complete(data);
-}
+static const struct generic_data add_ext_advertising_success_6 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_scanrsp,
+ .send_len = sizeof(add_advertising_param_scanrsp),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_alt_ev = MGMT_EV_ADVERTISING_ADDED,
+ .expect_alt_ev_param = advertising_instance1_param,
+ .expect_alt_ev_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
+ .expect_hci_param = set_ext_adv_data_uuid,
+ .expect_hci_len = sizeof(set_ext_adv_data_uuid),
+};

-static void test_remove_device(const void *test_data)
-{
- struct test_data *data = tester_get_data();
+static const uint8_t set_ext_scan_rsp_uuid[] = {
+ 0x00, /* handle */
+ 0x03, /* complete data */
+ 0x01, /* controller should not fragment */
+ 0x0a, /* scan rsp data len */
+ 0x03, /* AD len */
+ 0x19, /* AD type: external appearance */
+ 0x40, 0x03, /* some custom appearance */
+ 0x05, /* AD len */
+ 0x03, /* AD type: all 16 bit service class UUIDs */
+ 0x0d, 0x18, 0x0f, 0x18, /* heart rate monitor, battery service */
+ /* padding */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00,
+};

- test_command_generic(test_data);
- tester_wait(1, check_scan, NULL);
- test_add_condition(data);
-}
+static const struct generic_data add_ext_advertising_success_7 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_scanrsp,
+ .send_len = sizeof(add_advertising_param_scanrsp),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_alt_ev = MGMT_EV_ADVERTISING_ADDED,
+ .expect_alt_ev_param = advertising_instance1_param,
+ .expect_alt_ev_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_RSP_DATA,
+ .expect_hci_param = set_ext_scan_rsp_uuid,
+ .expect_hci_len = sizeof(set_ext_scan_rsp_uuid),
+};
+
+static uint8_t set_connectable_on_ext_adv_param[] = {
+ 0x00, /* Handle */
+ 0x13, 0x00, /* Event type */
+ 0x00, 0x08, 0x00, /* min_interval */
+ 0x00, 0x08, 0x00, /* max_interval */
+ 0x07, /* channel_map */
+ 0x00, /* own_addr_type */
+ 0x00, /* peer_addr_type */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* peer_addr */
+ 0x00, /* filter_policy */
+ 127, /* Tx power */
+ 0x01, /* Primary PHY */
+ 0x00, /* primary adv max skip */
+ 0x01, /* Secondary PHY */
+ 0x00, /* adv sid*/
+ 0x00, /* Scan req notification */
+};
+
+static const struct generic_data add_ext_advertising_success_8 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_connectable,
+ .send_len = sizeof(add_advertising_param_connectable),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_on_ext_adv_param,
+ .expect_hci_len = sizeof(set_connectable_on_ext_adv_param),
+};

-static void trigger_device_found(void *user_data)
-{
- struct test_data *data = tester_get_data();
+static const uint8_t set_ext_adv_data_general_discov[] = {
+ 0x00, /* handle */
+ 0x03, /* complete data */
+ 0x01, /* controller should not fragment */
+ 0x0c, /* adv data len */
+ 0x02, /* AD len */
+ 0x01, /* AD type: flags */
+ 0x02, /* general discoverable */
+ 0x03, /* AD len */
+ 0x02, /* AD type: some 16bit service class UUIDs */
+ 0x0d, 0x18, /* heart rate monitor */
+ 0x04, /* AD len */
+ 0xff, /* AD type: manufacturer specific data */
+ 0x01, 0x02, 0x03, /* custom advertising data */
+ /* padding */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const uint8_t set_ext_adv_data_limited_discov[] = {
+ 0x00, /* handle */
+ 0x03, /* complete data */
+ 0x01, /* controller should not fragment */
+ 0x0c, /* adv data len */
+ 0x02, /* AD len */
+ 0x01, /* AD type: flags */
+ 0x01, /* limited discoverable */
+ /* rest: same as before */
+ 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03,
+ /* padding */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const uint8_t set_ext_adv_data_uuid_txpwr[] = {
+ 0x00, /* handle */
+ 0x03, /* complete data */
+ 0x01, /* controller should not fragment */
+ 0x0c, /* adv data len */
+ 0x03, /* AD len */
+ 0x02, /* AD type: some 16bit service class UUIDs */
+ 0x0d, 0x18, /* heart rate monitor */
+ 0x04, /* AD len */
+ 0xff, /* AD type: manufacturer specific data */
+ 0x01, 0x02, 0x03, /* custom advertising data */
+ 0x02, /* AD len */
+ 0x0a, /* AD type: tx power */
+ 0x00, /* tx power */
+ /* padding */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const struct generic_data add_ext_advertising_success_9 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_general_discov,
+ .send_len = sizeof(add_advertising_param_general_discov),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
+ .expect_hci_param = set_ext_adv_data_general_discov,
+ .expect_hci_len = sizeof(set_ext_adv_data_general_discov),
+};
+
+static const struct generic_data add_ext_advertising_success_10 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_limited_discov,
+ .send_len = sizeof(add_advertising_param_limited_discov),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
+ .expect_hci_param = set_ext_adv_data_limited_discov,
+ .expect_hci_len = sizeof(set_ext_adv_data_limited_discov),
+};
+
+static const struct generic_data add_ext_advertising_success_11 = {
+ .setup_settings = settings_powered_le_discoverable,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_managed,
+ .send_len = sizeof(add_advertising_param_managed),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
+ .expect_hci_param = set_ext_adv_data_general_discov,
+ .expect_hci_len = sizeof(set_ext_adv_data_general_discov),
+};
+
+static const struct generic_data add_ext_advertising_success_12 = {
+ .setup_settings = settings_powered_le_discoverable,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_txpwr,
+ .send_len = sizeof(add_advertising_param_txpwr),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
+ .expect_hci_param = set_ext_adv_data_uuid_txpwr,
+ .expect_hci_len = sizeof(set_ext_adv_data_uuid_txpwr),
+};
+
+static uint8_t set_connectable_off_scan_ext_adv_param[] = {
+ 0x00, /* Handle */
+ 0x12, 0x00, /* Event type */
+ 0x00, 0x08, 0x00, /* min_interval */
+ 0x00, 0x08, 0x00, /* max_interval */
+ 0x07, /* channel_map */
+ 0x01, /* own_addr_type */
+ 0x00, /* peer_addr_type */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* peer_addr */
+ 0x00, /* filter_policy */
+ 127, /* Tx power */
+ 0x01, /* Primary PHY */
+ 0x00, /* primary adv max skip */
+ 0x01, /* Secondary PHY */
+ 0x00, /* adv sid*/
+ 0x00, /* Scan req notification */
+};
+
+static const struct generic_data add_ext_advertising_success_13 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_scanrsp,
+ .send_len = sizeof(add_advertising_param_scanrsp),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_off_scan_ext_adv_param,
+ .expect_hci_len = sizeof(set_connectable_off_scan_ext_adv_param),
+};
+
+static uint8_t set_connectable_off_ext_adv_param[] = {
+ 0x00, /* Handle */
+ 0x10, 0x00, /* Event type */
+ 0x00, 0x08, 0x00, /* min_interval */
+ 0x00, 0x08, 0x00, /* max_interval */
+ 0x07, /* channel_map */
+ 0x01, /* own_addr_type */
+ 0x00, /* peer_addr_type */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* peer_addr */
+ 0x00, /* filter_policy */
+ 127, /* Tx power */
+ 0x01, /* Primary PHY */
+ 0x00, /* primary adv max skip */
+ 0x01, /* Secondary PHY */
+ 0x00, /* adv sid*/
+ 0x00, /* Scan req notification */
+};
+
+static const struct generic_data add_ext_advertising_success_14 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_uuid,
+ .send_len = sizeof(add_advertising_param_uuid),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_off_ext_adv_param,
+ .expect_hci_len = sizeof(set_connectable_off_ext_adv_param),
+};
+
+static const struct generic_data add_ext_advertising_success_15 = {
+ .setup_settings = settings_powered_le_connectable,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_uuid,
+ .send_len = sizeof(add_advertising_param_uuid),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_on_ext_adv_param,
+ .expect_hci_len = sizeof(set_connectable_on_ext_adv_param),
+};
+
+static const struct generic_data add_ext_advertising_success_16 = {
+ .send_opcode = MGMT_OP_SET_CONNECTABLE,
+ .send_param = set_connectable_on_param,
+ .send_len = sizeof(set_connectable_on_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = set_connectable_settings_param_3,
+ .expect_len = sizeof(set_connectable_settings_param_3),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_on_ext_adv_param,
+ .expect_hci_len = sizeof(set_connectable_on_ext_adv_param),
+};
+
+static const struct generic_data add_ext_advertising_success_17 = {
+ .send_opcode = MGMT_OP_SET_CONNECTABLE,
+ .send_param = set_connectable_off_param,
+ .send_len = sizeof(set_connectable_off_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = set_le_settings_param_2,
+ .expect_len = sizeof(set_le_settings_param_2),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_off_ext_adv_param,
+ .expect_hci_len = sizeof(set_connectable_off_ext_adv_param),
+};
+
+static const struct generic_data add_ext_advertising_power_off = {
+ .send_opcode = MGMT_OP_SET_POWERED,
+ .send_param = set_powered_off_param,
+ .send_len = sizeof(set_powered_off_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = set_powered_off_le_settings_param,
+ .expect_len = sizeof(set_powered_off_le_settings_param),
+ .expect_alt_ev = MGMT_EV_ADVERTISING_REMOVED,
+ .expect_alt_ev_param = advertising_instance1_param,
+ .expect_alt_ev_len = sizeof(advertising_instance1_param),
+};
+
+static const struct generic_data add_ext_advertising_le_off = {
+ .send_opcode = MGMT_OP_SET_LE,
+ .send_param = set_le_off_param,
+ .send_len = sizeof(set_le_off_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = set_le_settings_param_off,
+ .expect_len = sizeof(set_le_settings_param_off),
+ .expect_alt_ev = MGMT_EV_ADVERTISING_REMOVED,
+ .expect_alt_ev_param = advertising_instance1_param,
+ .expect_alt_ev_len = sizeof(advertising_instance1_param),
+};
+
+static const struct generic_data add_ext_advertising_success_18 = {
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_uuid,
+ .send_len = sizeof(add_advertising_param_uuid),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
+ .expect_hci_param = set_ext_adv_data_uuid,
+ .expect_hci_len = sizeof(set_ext_adv_data_uuid),
+};
+
+static const char set_ext_adv_disable_param[] = {
+ 0x00, 0x00,
+};
+
+static const struct generic_data add_ext_advertising_timeout_expired = {
+ .expect_alt_ev = MGMT_EV_ADVERTISING_REMOVED,
+ .expect_alt_ev_param = advertising_instance1_param,
+ .expect_alt_ev_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE,
+ .expect_hci_param = set_ext_adv_disable_param,
+ .expect_hci_len = sizeof(set_ext_adv_disable_param),
+};
+
+static const struct generic_data remove_ext_advertising_fail_1 = {
+ .send_opcode = MGMT_OP_REMOVE_ADVERTISING,
+ .send_param = remove_advertising_param_1,
+ .send_len = sizeof(remove_advertising_param_1),
+ .expect_status = MGMT_STATUS_INVALID_PARAMS,
+};
+
+static const struct generic_data remove_ext_advertising_success_1 = {
+ .send_opcode = MGMT_OP_REMOVE_ADVERTISING,
+ .send_param = remove_advertising_param_1,
+ .send_len = sizeof(remove_advertising_param_1),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = remove_advertising_param_1,
+ .expect_len = sizeof(remove_advertising_param_1),
+ .expect_alt_ev = MGMT_EV_ADVERTISING_REMOVED,
+ .expect_alt_ev_param = advertising_instance1_param,
+ .expect_alt_ev_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE,
+ .expect_hci_param = set_ext_adv_disable_param,
+ .expect_hci_len = sizeof(set_ext_adv_disable_param),
+};
+
+static const struct generic_data remove_ext_advertising_success_2 = {
+ .send_opcode = MGMT_OP_REMOVE_ADVERTISING,
+ .send_param = remove_advertising_param_2,
+ .send_len = sizeof(remove_advertising_param_2),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = remove_advertising_param_2,
+ .expect_len = sizeof(remove_advertising_param_2),
+ .expect_alt_ev = MGMT_EV_ADVERTISING_REMOVED,
+ .expect_alt_ev_param = advertising_instance1_param,
+ .expect_alt_ev_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_ENABLE,
+ .expect_hci_param = set_ext_adv_disable_param,
+ .expect_hci_len = sizeof(set_ext_adv_disable_param),
+};
+
+static const uint8_t set_ext_adv_data_test2[] = {
+ 0x00, /* handle */
+ 0x03, /* complete data */
+ 0x01, /* controller should not fragment */
+ 0x07, /* adv data len */
+ 0x06, /* AD len */
+ 0x08, /* AD type: shortened local name */
+ 0x74, 0x65, 0x73, 0x74, 0x32, /* "test2" */
+ /* padding */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+};
+
+static const struct generic_data multi_ext_advertising_switch = {
+ .expect_alt_ev = MGMT_EV_ADVERTISING_REMOVED,
+ .expect_alt_ev_param = advertising_instance1_param,
+ .expect_alt_ev_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
+ .expect_hci_param = set_ext_adv_data_test2,
+ .expect_hci_len = sizeof(set_ext_adv_data_test2),
+};
+
+static const struct generic_data multi_ext_advertising_add_second = {
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_test2,
+ .send_len = sizeof(add_advertising_param_test2),
+ .expect_param = advertising_instance2_param,
+ .expect_len = sizeof(advertising_instance2_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_alt_ev = MGMT_EV_ADVERTISING_ADDED,
+ .expect_alt_ev_param = advertising_instance2_param,
+ .expect_alt_ev_len = sizeof(advertising_instance2_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_DATA,
+ .expect_hci_param = set_ext_adv_data_test2,
+ .expect_hci_len = sizeof(set_ext_adv_data_test2),
+};
+
+static const uint8_t add_ext_advertising_param_empty[] = {
+ 0x01, /* adv instance */
+ 0x00, 0x00, 0x00, 0x00, /* flags: none */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x00, /* scan rsp len */
+};
+
+static const struct generic_data add_ext_advertising_empty_scrsp = {
+ .setup_settings = settings_powered_le,
+ .setup_send_opcode = MGMT_OP_SET_LOCAL_NAME,
+ .setup_send_param = set_local_name_param,
+ .setup_send_len = sizeof(set_local_name_param),
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_empty,
+ .send_len = sizeof(add_advertising_param_empty),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+};
+
+static const uint8_t add_ext_advertising_param_scrsp_data_only_ok[] = {
+ 0x01, /* adv instance */
+ 0x00, 0x00, 0x00, 0x00, /* flags: none */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x1f, /* scan rsp len */
+ /* adv data: */
+ /* scan rsp data: */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00,
+};
+
+static const struct generic_data add_ext_advertising_scrsp_data_only_ok = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_scrsp_data_only_ok,
+ .send_len = sizeof(add_advertising_param_scrsp_data_only_ok),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+};
+
+static const uint8_t add_ext_advertising_param_scrsp_data_only_too_long[] = {
+ 0x01, /* adv instance */
+ 0x00, 0x00, 0x00, 0x00, /* flags: none */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x20, /* scan rsp len */
+ /* adv data: */
+ /* scan rsp data: */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00,
+};
+
+static const struct generic_data add_ext_advertising_scrsp_data_only_too_long = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_scrsp_data_only_too_long,
+ .send_len = sizeof(add_advertising_param_scrsp_data_only_too_long),
+ .expect_status = MGMT_STATUS_INVALID_PARAMS,
+ .expect_param = NULL,
+ .expect_len = 0,
+};
+
+static const uint8_t add_ext_advertising_param_scrsp_appear_data_ok[] = {
+ 0x01, /* adv instance */
+ 0x20, 0x00, 0x00, 0x00, /* flags: appearance */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x1b, /* scan rsp len */
+ /* adv data: */
+ /* scan rsp data: */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const struct generic_data add_ext_advertising_scrsp_appear_data_ok = {
+ .setup_settings = settings_powered_le,
+ .setup_send_opcode = MGMT_OP_SET_APPEARANCE,
+ .setup_send_param = set_appearance_param,
+ .setup_send_len = sizeof(set_appearance_param),
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_scrsp_appear_data_ok,
+ .send_len = sizeof(add_advertising_param_scrsp_appear_data_ok),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+};
+
+static const uint8_t add_ext_advertising_param_scrsp_appear_data_too_long[] = {
+ 0x01, /* adv instance */
+ 0x20, 0x00, 0x00, 0x00, /* flags: appearance */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x1c, /* scan rsp len */
+ /* adv data: */
+ /* scan rsp data: */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const struct generic_data add_ext_advertising_scrsp_appear_data_too_long = {
+ .setup_settings = settings_powered_le,
+ .setup_send_opcode = MGMT_OP_SET_APPEARANCE,
+ .setup_send_param = set_appearance_param,
+ .setup_send_len = sizeof(set_appearance_param),
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_scrsp_appear_data_too_long,
+ .send_len = sizeof(add_advertising_param_scrsp_appear_data_too_long),
+ .expect_status = MGMT_STATUS_INVALID_PARAMS,
+ .expect_param = NULL,
+ .expect_len = 0,
+};
+
+static const uint8_t add_ext_advertising_param_scrsp_appear_null[] = {
+ 0x01, /* adv instance */
+ 0x20, 0x00, 0x00, 0x00, /* flags: appearance */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x01, /* scan rsp len */
+ /* adv data: */
+ /* scan rsp data: */
+ 0x00,
+};
+
+static const struct generic_data add_ext_advertising_scrsp_appear_null = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_scrsp_appear_null,
+ .send_len = sizeof(add_advertising_param_scrsp_appear_null),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+};
+
+static const uint8_t add_ext_advertising_empty_param[] = {
+ 0x01, /* adv instance */
+ 0x40, 0x00, 0x00, 0x00, /* flags: local name*/
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x01, /* scan rsp len */
+ /* scan rsp data: */
+ 0x00,
+};
+
+static const uint8_t ext_scan_rsp_data_empty[] = {
+ 0x00, /* handle */
+ 0x03, /* complete data */
+ 0x01, /* controller should not fragment */
+ 0x01, /* scan rsp data len */
+ 0x00, /* scan rsp data */
+ /* placeholder data */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const struct generic_data add_ext_advertising_no_name_set = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_empty_param,
+ .send_len = sizeof(add_advertising_empty_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_RSP_DATA,
+ .expect_hci_param = ext_scan_rsp_data_empty,
+ .expect_hci_len = sizeof(ext_scan_rsp_data_empty),
+};
+
+static const uint8_t add_ext_advertising_param_name[] = {
+ 0x01, /* adv instance */
+ 0x40, 0x00, 0x00, 0x00, /* flags: Add local name to scan_rsp */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x00, /* scan rsp len */
+};
+
+static const uint8_t set_ext_scan_rsp_data_name_fits_in_scrsp[] = {
+ 0x00, /* handle */
+ 0x03, /* complete data */
+ 0x01, /* controller should not fragment */
+ 0x0c, /* Scan rsp data len */
+ 0x0b, /* Local name data len */
+ 0x09, /* Complete name */
+ 0x54, 0x65, 0x73, 0x74, 0x20, 0x6e, 0x61, 0x6d, 0x65, /* "Test name" */
+ /* padding */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const struct generic_data add_ext_advertising_name_fits_in_scrsp = {
+ .setup_settings = settings_powered_le,
+ .setup_send_opcode = MGMT_OP_SET_LOCAL_NAME,
+ .setup_send_param = &set_local_name_cp,
+ .setup_send_len = sizeof(set_local_name_cp),
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_name,
+ .send_len = sizeof(add_advertising_param_name),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_RSP_DATA,
+ .expect_hci_param = set_ext_scan_rsp_data_name_fits_in_scrsp,
+ .expect_hci_len = sizeof(set_ext_scan_rsp_data_name_fits_in_scrsp),
+};
+
+static const uint8_t set_ext_scan_rsp_data_shortened_name_fits[] = {
+ 0x00, /* handle */
+ 0x03, /* complete data */
+ 0x01, /* controller should not fragment */
+ 0x0d, /* Scan rsp data len */
+ 0x0c, /* Local name data len */
+ 0x08, /* Short name */
+ 0x54, 0x65, 0x73, 0x74, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x31,
+ /* "Test name1" */
+ /* padding */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const struct generic_data add_ext_advertising_shortened_name_in_scrsp = {
+ .setup_settings = settings_powered_le,
+ .setup_send_opcode = MGMT_OP_SET_LOCAL_NAME,
+ .setup_send_param = &set_local_name_longer_cp,
+ .setup_send_len = sizeof(set_local_name_longer_cp),
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_name,
+ .send_len = sizeof(add_advertising_param_name),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_RSP_DATA,
+ .expect_hci_param = set_ext_scan_rsp_data_shortened_name_fits,
+ .expect_hci_len = sizeof(set_ext_scan_rsp_data_shortened_name_fits),
+};
+
+static const uint8_t set_ext_scan_rsp_data_short_name_fits[] = {
+ 0x00, /* handle */
+ 0x03, /* complete data */
+ 0x01, /* controller should not fragment */
+ 0x07, /* Scan rsp data len */
+ 0x06, /* Local name data len */
+ 0x08, /* Short name */
+ 0x54, 0x65, 0x73, 0x74,
+ /* "Test*/
+ /* padding */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const uint8_t add_ext_advertising_param_name_data_ok[] = {
+ 0x01, /* adv instance */
+ 0x40, 0x00, 0x00, 0x00, /* flags: local name */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x12, /* scan rsp len */
+ /* adv data: */
+ /* scan rsp data: */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static const uint8_t set_ext_scan_rsp_data_param_name_data_ok[] = {
+ 0x00, /* handle */
+ 0x03, /* complete data */
+ 0x01, /* controller should not fragment */
+ 0x1e, /* Scan rsp data len */
+ /* scan rsp data */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0b, /* Local name data len */
+ 0x09, /* Complete name */
+ 0x54, 0x65, 0x73, 0x74, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x00,
+ /* "Test name" */
+ /* padding */
+ 0x00,
+};
+
+static const struct generic_data add_ext_advertising_name_data_ok = {
+ .setup_settings = settings_powered_le,
+ .setup_send_opcode = MGMT_OP_SET_LOCAL_NAME,
+ .setup_send_param = &set_local_name_cp,
+ .setup_send_len = sizeof(set_local_name_cp),
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_name_data_ok,
+ .send_len = sizeof(add_advertising_param_name_data_ok),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_RSP_DATA,
+ .expect_hci_param = set_ext_scan_rsp_data_param_name_data_ok,
+ .expect_hci_len = sizeof(set_ext_scan_rsp_data_param_name_data_ok),
+};
+
+static const uint8_t add_ext_advertising_param_name_data_inv[] = {
+ 0x01, /* adv instance */
+ 0x40, 0x00, 0x00, 0x00, /* flags: local name */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x14, /* scan rsp len */
+ /* adv data: */
+ /* scan rsp data: */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static const struct generic_data add_ext_advertising_name_data_inv = {
+ .setup_settings = settings_powered_le,
+ .setup_send_opcode = MGMT_OP_SET_LOCAL_NAME,
+ .setup_send_param = &set_local_name_cp,
+ .setup_send_len = sizeof(set_local_name_cp),
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_name_data_inv,
+ .send_len = sizeof(add_advertising_param_name_data_inv),
+ .expect_status = MGMT_STATUS_INVALID_PARAMS,
+ .expect_param = NULL,
+ .expect_len = 0,
+};
+
+static const uint8_t add_ext_advertising_param_name_data_appear[] = {
+ 0x01, /* adv instance */
+ 0x60, 0x00, 0x00, 0x00, /* flags: local name + appearance */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x0e, /* scan rsp len */
+ /* adv data: */
+ /* scan rsp data: */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+};
+
+static const struct setup_mgmt_cmd add_ext_advertising_mgmt_cmd_arr[] = {
+ {
+ .send_opcode = MGMT_OP_SET_APPEARANCE,
+ .send_param = set_appearance_param,
+ .send_len = sizeof(set_appearance_param),
+ },
+ {
+ .send_opcode = MGMT_OP_SET_LOCAL_NAME,
+ .send_param = &set_local_name_cp,
+ .send_len = sizeof(set_local_name_cp),
+ },
+ { /* last element should always have opcode 0x00 */
+ .send_opcode = 0x00,
+ .send_param = NULL,
+ .send_len = 0,
+ }
+};
+
+static const uint8_t set_ext_scan_rsp_data_name_data_appear[] = {
+ 0x00, /* handle */
+ 0x03, /* complete data */
+ 0x01, /* controller should not fragment */
+ 0x1e, /* Scan rsp data len */
+ 0x03, /* appearance len */
+ 0x19, /* EIR_APPEARANCE */
+ 0x54, 0x65, /* appearance value */
+ /* scan rsp data */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x0b, /* Local name data len */
+ 0x09, /* Complete name */
+ 0x54, 0x65, 0x73, 0x74, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x00,
+ /* "Test name" */
+ /* padding */
+ 0x00,
+};
+
+static const struct generic_data add_ext_advertising_name_data_appear = {
+ .setup_settings = settings_powered_le,
+ .setup_mgmt_cmd_arr = add_advertising_mgmt_cmd_arr,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_name_data_appear,
+ .send_len = sizeof(add_advertising_param_name_data_appear),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_RSP_DATA,
+ .expect_hci_param = set_ext_scan_rsp_data_name_data_appear,
+ .expect_hci_len = sizeof(set_ext_scan_rsp_data_name_data_appear),
+};
+
+/* simple add advertising command */
+static const uint8_t add_advertising_1m_param_uuid[] = {
+ 0x01, /* adv instance */
+ 0x80, 0x00, 0x00, 0x00, /* flags: 1m */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x09, /* adv data len */
+ 0x00, /* scan rsp len */
+ /* adv data: */
+ 0x03, /* AD len */
+ 0x02, /* AD type: some 16 bit service class UUIDs */
+ 0x0d, 0x18, /* heart rate monitor */
+ 0x04, /* AD len */
+ 0xff, /* AD type: manufacturer specific data */
+ 0x01, 0x02, 0x03, /* custom advertising data */
+};
+
+static uint8_t set_connectable_off_ext_1m_adv_param[] = {
+ 0x00, /* Handle */
+ 0x00, 0x00, /* Event type */
+ 0x00, 0x08, 0x00, /* min_interval */
+ 0x00, 0x08, 0x00, /* max_interval */
+ 0x07, /* channel_map */
+ 0x01, /* own_addr_type */
+ 0x00, /* peer_addr_type */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* peer_addr */
+ 0x00, /* filter_policy */
+ 127, /* Tx power */
+ 0x01, /* Primary PHY */
+ 0x00, /* primary adv max skip */
+ 0x01, /* Secondary PHY */
+ 0x00, /* adv sid*/
+ 0x00, /* Scan req notification */
+};
+
+static const struct generic_data add_ext_advertising_success_1m = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_1m_param_uuid,
+ .send_len = sizeof(add_advertising_1m_param_uuid),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_off_ext_1m_adv_param,
+ .expect_hci_len = sizeof(set_connectable_off_ext_1m_adv_param),
+};
+
+/* simple add advertising command */
+static const uint8_t add_advertising_2m_param_uuid[] = {
+ 0x01, /* adv instance */
+ 0x00, 0x01, 0x00, 0x00, /* flags: 2m */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x09, /* adv data len */
+ 0x00, /* scan rsp len */
+ /* adv data: */
+ 0x03, /* AD len */
+ 0x02, /* AD type: some 16 bit service class UUIDs */
+ 0x0d, 0x18, /* heart rate monitor */
+ 0x04, /* AD len */
+ 0xff, /* AD type: manufacturer specific data */
+ 0x01, 0x02, 0x03, /* custom advertising data */
+};
+
+static uint8_t set_connectable_off_ext_2m_adv_param[] = {
+ 0x00, /* Handle */
+ 0x00, 0x00, /* Event type */
+ 0x00, 0x08, 0x00, /* min_interval */
+ 0x00, 0x08, 0x00, /* max_interval */
+ 0x07, /* channel_map */
+ 0x01, /* own_addr_type */
+ 0x00, /* peer_addr_type */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* peer_addr */
+ 0x00, /* filter_policy */
+ 127, /* Tx power */
+ 0x01, /* Primary PHY */
+ 0x00, /* primary adv max skip */
+ 0x02, /* Secondary PHY */
+ 0x00, /* adv sid*/
+ 0x00, /* Scan req notification */
+};
+
+static const struct generic_data add_ext_advertising_success_2m = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_2m_param_uuid,
+ .send_len = sizeof(add_advertising_2m_param_uuid),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_off_ext_2m_adv_param,
+ .expect_hci_len = sizeof(set_connectable_off_ext_2m_adv_param),
+};
+
+/* simple add advertising command */
+static const uint8_t add_advertising_coded_param_uuid[] = {
+ 0x01, /* adv instance */
+ 0x00, 0x02, 0x00, 0x00, /* flags: coded */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x09, /* adv data len */
+ 0x00, /* scan rsp len */
+ /* adv data: */
+ 0x03, /* AD len */
+ 0x02, /* AD type: some 16 bit service class UUIDs */
+ 0x0d, 0x18, /* heart rate monitor */
+ 0x04, /* AD len */
+ 0xff, /* AD type: manufacturer specific data */
+ 0x01, 0x02, 0x03, /* custom advertising data */
+};
+
+static uint8_t set_connectable_off_ext_coded_adv_param[] = {
+ 0x00, /* Handle */
+ 0x00, 0x00, /* Event type */
+ 0x00, 0x08, 0x00, /* min_interval */
+ 0x00, 0x08, 0x00, /* max_interval */
+ 0x07, /* channel_map */
+ 0x01, /* own_addr_type */
+ 0x00, /* peer_addr_type */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* peer_addr */
+ 0x00, /* filter_policy */
+ 127, /* Tx power */
+ 0x03, /* Primary PHY */
+ 0x00, /* primary adv max skip */
+ 0x03, /* Secondary PHY */
+ 0x00, /* adv sid*/
+ 0x00, /* Scan req notification */
+};
+
+static const struct generic_data add_ext_advertising_success_coded = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_coded_param_uuid,
+ .send_len = sizeof(add_advertising_coded_param_uuid),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_off_ext_coded_adv_param,
+ .expect_hci_len = sizeof(set_connectable_off_ext_coded_adv_param),
+};
+
+/* add advertising with scan response data */
+static const uint8_t add_advertising_param_scanrsp_1m[] = {
+ 0x01, /* Instance */
+ 0x80, 0x00, 0x00, 0x00, /* Flags: 1m*/
+ 0x00, 0x00, /* Duration */
+ 0x00, 0x00, /* Timeout */
+ 0x09, /* Adv data len */
+ 0x0a, /* scan rsp len */
+ /* adv data: same as before */
+ 0x03, 0x02, 0x0d, 0x18, 0x04, 0xff, 0x01, 0x02, 0x03,
+ /* scan rsp data: */
+ 0x03, /* AD len */
+ 0x19, /* AD type: external appearance */
+ 0x40, 0x03, /* some custom appearance */
+ 0x05, /* AD len */
+ 0x03, /* AD type: all 16 bit service class UUIDs */
+ 0x0d, 0x18, /* heart rate monitor */
+ 0x0f, 0x18, /* battery service */
+};
+
+static uint8_t set_connectable_off_scan_ext_pdu_adv_param[] = {
+ 0x00, /* Handle */
+ 0x02, 0x00, /* Event type */
+ 0x00, 0x08, 0x00, /* min_interval */
+ 0x00, 0x08, 0x00, /* max_interval */
+ 0x07, /* channel_map */
+ 0x01, /* own_addr_type */
+ 0x00, /* peer_addr_type */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* peer_addr */
+ 0x00, /* filter_policy */
+ 127, /* Tx power */
+ 0x01, /* Primary PHY */
+ 0x00, /* primary adv max skip */
+ 0x01, /* Secondary PHY */
+ 0x00, /* adv sid*/
+ 0x00, /* Scan req notification */
+};
+
+static const struct generic_data add_ext_advertising_success_scannable = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_scanrsp_1m,
+ .send_len = sizeof(add_advertising_param_scanrsp_1m),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_off_scan_ext_pdu_adv_param,
+ .expect_hci_len = sizeof(set_connectable_off_scan_ext_pdu_adv_param),
+};
+
+static uint8_t set_connectable_on_ext_pdu_adv_param[] = {
+ 0x00, /* Handle */
+ 0x01, 0x00, /* Event type */
+ 0x00, 0x08, 0x00, /* min_interval */
+ 0x00, 0x08, 0x00, /* max_interval */
+ 0x07, /* channel_map */
+ 0x00, /* own_addr_type */
+ 0x00, /* peer_addr_type */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* peer_addr */
+ 0x00, /* filter_policy */
+ 127, /* Tx power */
+ 0x01, /* Primary PHY */
+ 0x00, /* primary adv max skip */
+ 0x01, /* Secondary PHY */
+ 0x00, /* adv sid*/
+ 0x00, /* Scan req notification */
+};
+
+static const struct generic_data add_ext_advertising_success_connectable = {
+ .setup_settings = settings_powered_le_connectable,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_1m_param_uuid,
+ .send_len = sizeof(add_advertising_1m_param_uuid),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_on_ext_pdu_adv_param,
+ .expect_hci_len = sizeof(set_connectable_on_ext_pdu_adv_param),
+};
+
+static const struct generic_data add_ext_advertising_success_conn_scan = {
+ .setup_settings = settings_powered_le_connectable,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_scanrsp_1m,
+ .send_len = sizeof(add_advertising_param_scanrsp_1m),
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_on_ext_pdu_adv_param,
+ .expect_hci_len = sizeof(set_connectable_on_ext_pdu_adv_param),
+};
+
+static void setup_add_adv_param_1m(struct mgmt_cp_add_advertising *cp,
+ uint8_t instance)
+{
+ memset(cp, 0, sizeof(*cp));
+ cp->instance = instance;
+ cp->flags = cpu_to_le32(MGMT_ADV_FLAG_SEC_1M);
+ cp->adv_data_len = TESTER_ADD_ADV_DATA_LEN;
+ cp->data[0] = TESTER_ADD_ADV_DATA_LEN - 1; /* AD len */
+ cp->data[1] = 0x08; /* AD type: shortened local name */
+ cp->data[2] = 't'; /* adv data ... */
+ cp->data[3] = 'e';
+ cp->data[4] = 's';
+ cp->data[5] = 't';
+ cp->data[6] = '0' + instance;
+}
+
+static void setup_add_advertising_1m(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct mgmt_cp_add_advertising *cp;
+ unsigned char adv_param[sizeof(*cp) + TESTER_ADD_ADV_DATA_LEN];
+ unsigned char param[] = { 0x01 };
+
+ tester_print("Adding advertising instance while powered");
+
+ cp = (struct mgmt_cp_add_advertising *) adv_param;
+ setup_add_adv_param_1m(cp, 1);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index,
+ sizeof(param), &param,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), &param,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_ADVERTISING, data->mgmt_index,
+ sizeof(adv_param), adv_param,
+ setup_add_advertising_callback,
+ NULL, NULL);
+}
+
+static const struct generic_data add_ext_advertising_conn_on_1m = {
+ .send_opcode = MGMT_OP_SET_CONNECTABLE,
+ .send_param = set_connectable_on_param,
+ .send_len = sizeof(set_connectable_on_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = set_connectable_settings_param_3,
+ .expect_len = sizeof(set_connectable_settings_param_3),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_on_ext_pdu_adv_param,
+ .expect_hci_len = sizeof(set_connectable_on_ext_pdu_adv_param),
+};
+
+static void setup_add_advertising_connectable_1m(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct mgmt_cp_add_advertising *cp;
+ unsigned char adv_param[sizeof(*cp) + TESTER_ADD_ADV_DATA_LEN];
+ unsigned char param[] = { 0x01 };
+
+ tester_print("Adding advertising instance while connectable");
+
+ cp = (struct mgmt_cp_add_advertising *) adv_param;
+ setup_add_adv_param_1m(cp, 1);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index,
+ sizeof(param), &param,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), &param,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_CONNECTABLE, data->mgmt_index,
+ sizeof(param), &param,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_ADVERTISING, data->mgmt_index,
+ sizeof(adv_param), adv_param,
+ setup_add_advertising_callback,
+ NULL, NULL);
+}
+
+static const struct generic_data add_ext_advertising_conn_off_1m = {
+ .send_opcode = MGMT_OP_SET_CONNECTABLE,
+ .send_param = set_connectable_off_param,
+ .send_len = sizeof(set_connectable_off_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = set_le_settings_param_2,
+ .expect_len = sizeof(set_le_settings_param_2),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS,
+ .expect_hci_param = set_connectable_off_ext_1m_adv_param,
+ .expect_hci_len = sizeof(set_connectable_off_ext_1m_adv_param),
+};
+
+static bool power_off(uint16_t index)
+{
+ int sk, err;
+
+ sk = hci_open_dev(index);
+ if (sk < 0)
+ return false;
+
+ err = ioctl(sk, HCIDEVDOWN, index);
+
+ hci_close_dev(sk);
+
+ if (err < 0)
+ return false;
+
+ return true;
+}
+
+static void test_command_generic(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;
+ unsigned int id;
+ uint16_t index;
+
+ index = test->send_index_none ? MGMT_INDEX_NONE : data->mgmt_index;
+
+ if (test->expect_settings_set || test->expect_settings_unset) {
+ tester_print("Registering new settings notification");
+
+ id = mgmt_register(data->mgmt, MGMT_EV_NEW_SETTINGS, index,
+ command_generic_new_settings, NULL, NULL);
+ data->mgmt_settings_id = id;
+
+ id = mgmt_register(data->mgmt_alt, MGMT_EV_NEW_SETTINGS, index,
+ command_generic_new_settings_alt, NULL, NULL);
+ data->mgmt_alt_settings_id = id;
+ test_add_condition(data);
+ }
+
+ if (test->expect_alt_ev) {
+ tester_print("Registering %s notification",
+ mgmt_evstr(test->expect_alt_ev));
+ id = mgmt_register(data->mgmt_alt, test->expect_alt_ev, index,
+ command_generic_event_alt, NULL, NULL);
+ data->mgmt_alt_ev_id = id;
+ test_add_condition(data);
+ }
+
+ if (test->expect_hci_command) {
+ tester_print("Registering HCI command callback");
+ hciemu_add_master_post_command_hook(data->hciemu,
+ command_hci_callback, data);
+ test_add_condition(data);
+ }
+
+ if (test->send_opcode == 0x0000) {
+ tester_print("Executing no-op test");
+ return;
+ }
+
+ tester_print("Sending %s (0x%04x)", mgmt_opstr(test->send_opcode),
+ test->send_opcode);
+
+ if (test->send_func)
+ send_param = test->send_func(&send_len);
+
+ if (test->force_power_off) {
+ mgmt_send_nowait(data->mgmt, test->send_opcode, index,
+ send_len, send_param,
+ command_generic_callback, NULL, NULL);
+ power_off(data->mgmt_index);
+ } else {
+ mgmt_send(data->mgmt, test->send_opcode, index, send_len,
+ send_param, command_generic_callback,
+ NULL, NULL);
+ }
+
+ test_add_condition(data);
+}
+
+static void check_scan(void *user_data)
+{
+ struct test_data *data = tester_get_data();
+
+ if (hciemu_get_master_le_scan_enable(data->hciemu)) {
+ tester_warn("LE scan still enabled");
+ tester_test_failed();
+ return;
+ }
+
+ if (hciemu_get_master_scan_enable(data->hciemu)) {
+ tester_warn("BR/EDR scan still enabled");
+ tester_test_failed();
+ return;
+ }
+
+ test_condition_complete(data);
+}
+
+static void test_remove_device(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+
+ test_command_generic(test_data);
+ tester_wait(1, check_scan, NULL);
+ test_add_condition(data);
+}
+
+static void trigger_device_found(void *user_data)
+{
+ struct test_data *data = tester_get_data();
const struct generic_data *test = data->test_data;
struct bthost *bthost;

@@ -8352,5 +9716,247 @@ int main(int argc, char *argv[])
&device_found_invalid_field,
NULL, test_device_found);

+ test_bredrle50("Read Ext Advertising Features - Success 3 (PHY flags)",
+ &read_adv_features_success_3,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Invalid Params 1 (Multiple Phys)",
+ &add_ext_advertising_fail_1,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Invalid Params 2 (Multiple PHYs)",
+ &add_ext_advertising_fail_2,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Invalid Params 3 (Multiple PHYs)",
+ &add_ext_advertising_fail_3,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Invalid Params 4 (Multiple PHYs)",
+ &add_ext_advertising_fail_4,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 1 (Powered, Add Adv Inst)",
+ &add_ext_advertising_success_1,
+ NULL, test_command_generic);
+
+
+ test_bredrle50("Add Ext Advertising - Success 2 (!Powered, Add Adv Inst)",
+ &add_ext_advertising_success_pwron_data,
+ setup_add_advertising_not_powered,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 3 (!Powered, Adv Enable)",
+ &add_ext_advertising_success_pwron_enabled,
+ setup_add_advertising_not_powered,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 4 (Set Adv on override)",
+ &add_ext_advertising_success_4,
+ setup_add_advertising,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 5 (Set Adv off override)",
+ &add_ext_advertising_success_5,
+ setup_set_and_add_advertising,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 6 (Scan Rsp Dta, Adv ok)",
+ &add_ext_advertising_success_6,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 7 (Scan Rsp Dta, Scan ok) ",
+ &add_ext_advertising_success_7,
+ NULL, test_command_generic);
+ test_bredrle50("Add Ext Advertising - Success 8 (Connectable Flag)",
+ &add_ext_advertising_success_8,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 9 (General Discov Flag)",
+ &add_ext_advertising_success_9,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 10 (Limited Discov Flag)",
+ &add_ext_advertising_success_10,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 11 (Managed Flags)",
+ &add_ext_advertising_success_11,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 12 (TX Power Flag)",
+ &add_ext_advertising_success_12,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 13 (ADV_SCAN_IND)",
+ &add_ext_advertising_success_13,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 14 (ADV_NONCONN_IND)",
+ &add_ext_advertising_success_14,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 15 (ADV_IND)",
+ &add_ext_advertising_success_15,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 16 (Connectable -> on)",
+ &add_ext_advertising_success_16,
+ setup_add_advertising,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success 17 (Connectable -> off)",
+ &add_ext_advertising_success_17,
+ setup_add_advertising_connectable,
+ test_command_generic);
+
+ /* Changing an advertising instance while it is still being
+ * advertised will immediately update the advertised data if
+ * there is no other instance to switch to.
+ */
+ test_bredrle50("Add Ext Advertising - Success 20 (Add Adv override)",
+ &add_ext_advertising_success_18,
+ setup_add_advertising,
+ test_command_generic);
+
+ /* An instance should be removed when its timeout has been reached.
+ * Advertising will also be disabled if this was the last instance.
+ */
+ test_bredrle50_full("Add Ext Advertising - Success 21 (Timeout expires)",
+ &add_ext_advertising_timeout_expired,
+ setup_add_advertising_timeout,
+ test_command_generic, 3);
+
+ /* LE off will clear (remove) all instances. */
+ test_bredrle50("Add Ext Advertising - Success 22 (LE -> off, Remove)",
+ &add_ext_advertising_le_off,
+ setup_add_advertising,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (Empty ScRsp)",
+ &add_ext_advertising_empty_scrsp,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (ScRsp only)",
+ &add_ext_advertising_scrsp_data_only_ok,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Invalid Params (ScRsp too long)",
+ &add_ext_advertising_scrsp_data_only_too_long,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (ScRsp appear)",
+ &add_ext_advertising_scrsp_appear_data_ok,
+ setup_command_generic, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Invalid Params (ScRsp appear long)",
+ &add_ext_advertising_scrsp_appear_data_too_long,
+ setup_command_generic, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (Appear is null)",
+ &add_ext_advertising_scrsp_appear_null,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (Name is null)",
+ &add_ext_advertising_no_name_set,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (Complete name)",
+ &add_ext_advertising_name_fits_in_scrsp,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (Shortened name)",
+ &add_ext_advertising_shortened_name_in_scrsp,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (Short name)",
+ &add_ext_advertising_shortened_name_in_scrsp,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (Name + data)",
+ &add_ext_advertising_name_data_ok,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Invalid Params (Name + data)",
+ &add_ext_advertising_name_data_inv,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (Name+data+appear)",
+ &add_ext_advertising_name_data_appear,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (PHY -> 1M)",
+ &add_ext_advertising_success_1m,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (PHY -> 2M)",
+ &add_ext_advertising_success_2m,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (PHY -> Coded)",
+ &add_ext_advertising_success_coded,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (Ext Pdu Scannable)",
+ &add_ext_advertising_success_scannable,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (Ext Pdu Connectable)",
+ &add_ext_advertising_success_connectable,
+ NULL, test_command_generic);
+
+ /* In Ext pdu it shall not be both scannable and connectable */
+ test_bredrle50("Add Ext Advertising - Success (Ext Pdu Conn Scan)",
+ &add_ext_advertising_success_conn_scan,
+ NULL, test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (1m Connectable -> on)",
+ &add_ext_advertising_conn_on_1m,
+ setup_add_advertising_1m,
+ test_command_generic);
+
+ test_bredrle50("Add Ext Advertising - Success (1m Connectable -> off)",
+ &add_ext_advertising_conn_off_1m,
+ setup_add_advertising_connectable_1m,
+ test_command_generic);
+
+ test_bredrle50("Remove Ext Advertising - Invalid Params 1",
+ &remove_ext_advertising_fail_1,
+ NULL, test_command_generic);
+
+ test_bredrle50("Remove Ext Advertising - Success 1",
+ &remove_ext_advertising_success_1,
+ setup_add_advertising,
+ test_command_generic);
+
+ test_bredrle50("Remove Ext Advertising - Success 2",
+ &remove_ext_advertising_success_2,
+ setup_add_advertising,
+ test_command_generic);
+
+ /* When advertising two instances, the instances should be
+ * advertised in a round-robin fashion.
+ */
+ test_bredrle50("Multi Ext Advertising - Success 1 (Instance Switch)",
+ &multi_ext_advertising_switch,
+ setup_multi_adv,
+ test_command_generic);
+
+ /* Adding a new instance when one is already being advertised
+ * will switch to the new instance after the first has reached
+ * its duration. A long timeout has been set to
+ */
+ test_bredrle50_full("Multi Ext Advertising - Success 2 (Add Second Inst)",
+ &multi_ext_advertising_add_second,
+ setup_add_advertising_duration,
+ test_command_generic, 3);
+
return tester_run();
}
--
2.7.4

2018-07-06 11:28:01

by Jaganath K

[permalink] [raw]
Subject: [PATCH BlueZ 4/8] emulator: Add BREDR 2M & 3M, 3 & 5 Slot packet type support

---
emulator/btdev.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/emulator/btdev.c b/emulator/btdev.c
index f8289d0..9f07527 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -535,6 +535,16 @@ static void set_bredrle_features(struct btdev *btdev)
btdev->features[7] |= 0x80; /* Extended features */

if (btdev->type >= BTDEV_TYPE_BREDRLE50) {
+ /* These BREDR features are added to test new configuration
+ * command. If this is added above it will break existing tests
+ */
+ btdev->features[0] |= 0x01; /* 3 slot Packets */
+ btdev->features[0] |= 0x02; /* 5 slot Packets */
+ btdev->features[3] |= 0x02; /* EDR ACL 2M mode */
+ btdev->features[3] |= 0x04; /* EDR ACL 3M mode */
+ btdev->features[4] |= 0x80; /* 3 slot EDR ACL packets */
+ btdev->features[5] |= 0x01; /* 5 slot EDR ACL packets */
+
btdev->le_features[1] |= 0x01; /* LE 2M PHY */
btdev->le_features[1] |= 0x08; /* LE Coded PHY */
btdev->le_features[1] |= 0x10; /* LE EXT ADV */
--
2.7.4

2018-07-06 11:28:00

by Jaganath K

[permalink] [raw]
Subject: [PATCH BlueZ 3/8] monitor: Add BREDR PHYs in PHY configuration commands

---
monitor/packet.c | 39 +++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)

diff --git a/monitor/packet.c b/monitor/packet.c
index bf69859..6e31044 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -11995,12 +11995,21 @@ static const struct {
uint8_t bit;
const char *str;
} mgmt_phy_table[] = {
- { 0, "1MTX" },
- { 1, "1MRX" },
- { 2, "2MTX" },
- { 3, "2MRX" },
- { 4, "CODEDTX" },
- { 5, "CODEDRX" },
+ { 0, "BR 1M 1SLOT" },
+ { 1, "BR 1M 3SLOT" },
+ { 2, "BR 1M 5SLOT" },
+ { 3, "EDR 2M 1SLOT" },
+ { 4, "EDR 2M 3SLOT" },
+ { 5, "EDR 2M 5SLOT" },
+ { 6, "EDR 3M 1SLOT" },
+ { 7, "EDR 3M 3SLOT" },
+ { 8, "EDR 3M 5SLOT" },
+ { 9, "LE 1M TX" },
+ { 10, "LE 1M RX" },
+ { 11, "LE 2M TX" },
+ { 12, "LE 2M RX" },
+ { 13, "LE CODED TX" },
+ { 14, "LE CODED RX" },
{ }
};

@@ -12025,18 +12034,20 @@ static void mgmt_print_phys(const char *label, uint16_t phys)

static void mgmt_get_phy_rsp(const void *data, uint16_t size)
{
- uint16_t supported_phys = get_le16(data);
- uint16_t selected_phys = get_le16(data + 2);
+ uint32_t supported_phys = get_le32(data);
+ uint32_t configurable_phys = get_le32(data + 4);
+ uint32_t selected_phys = get_le32(data + 8);

mgmt_print_phys("Supported PHYs", supported_phys);
+ mgmt_print_phys("Configurable PHYs", configurable_phys);
mgmt_print_phys("Selected PHYs", selected_phys);
}

static void mgmt_set_phy_cmd(const void *data, uint16_t size)
{
- uint16_t default_phys = get_le16(data);
+ uint32_t selected_phys = get_le32(data);

- mgmt_print_phys("Default PHYs", default_phys);
+ mgmt_print_phys("Selected PHYs", selected_phys);
}

struct mgmt_data {
@@ -12254,9 +12265,9 @@ static const struct mgmt_data mgmt_command_table[] = {
mgmt_null_rsp, 0, true },
{ 0x0044, "Get PHY Configuration",
mgmt_null_cmd, 0, true,
- mgmt_get_phy_rsp, 4, true },
+ mgmt_get_phy_rsp, 12, true },
{ 0x0045, "Set PHY Configuration",
- mgmt_set_phy_cmd, 2, true,
+ mgmt_set_phy_cmd, 4, true,
mgmt_null_rsp, 0, true },
{ }
};
@@ -12638,7 +12649,7 @@ static void mgmt_ext_controller_info_changed_evt(const void *data, uint16_t size

static void mgmt_phy_changed_evt(const void *data, uint16_t size)
{
- uint16_t selected_phys = get_le16(data);
+ uint32_t selected_phys = get_le32(data);

mgmt_print_phys("Selected PHYs", selected_phys);
}
@@ -12719,7 +12730,7 @@ static const struct mgmt_data mgmt_event_table[] = {
{ 0x0025, "Extended Controller Information Changed",
mgmt_ext_controller_info_changed_evt, 2, false },
{ 0x0026, "PHY Configuration Changed",
- mgmt_phy_changed_evt, 2, true },
+ mgmt_phy_changed_evt, 4, true },
{ }
};

--
2.7.4

2018-07-06 11:27:59

by Jaganath K

[permalink] [raw]
Subject: [PATCH BlueZ 2/8] btmgmt: Add BREDR PHYs in PHY Configuration commands

---
lib/mgmt.h | 32 +++++++++++++++++++-----------
tools/btmgmt.c | 62 ++++++++++++++++++++++++++++------------------------------
2 files changed, 51 insertions(+), 43 deletions(-)

diff --git a/lib/mgmt.h b/lib/mgmt.h
index ec6a380..570dec9 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -552,16 +552,26 @@ struct mgmt_cp_set_appearance {

#define MGMT_OP_GET_PHY_CONFIGURATION 0x0044
struct mgmt_rp_get_phy_confguration {
- uint16_t supported_phys;
- uint16_t selected_phys;
-} __packed;
-
-#define MGMT_PHY_LE_1M_TX 0x0001
-#define MGMT_PHY_LE_1M_RX 0x0002
-#define MGMT_PHY_LE_2M_TX 0x0004
-#define MGMT_PHY_LE_2M_RX 0x0008
-#define MGMT_PHY_LE_CODED_TX 0x0010
-#define MGMT_PHY_LE_CODED_RX 0x0020
+ uint32_t supported_phys;
+ uint32_t configurable_phys;
+ uint32_t selected_phys;
+} __packed;
+
+#define MGMT_PHY_BR_1M_1SLOT 0x00000001
+#define MGMT_PHY_BR_1M_3SLOT 0x00000002
+#define MGMT_PHY_BR_1M_5SLOT 0x00000004
+#define MGMT_PHY_EDR_2M_1SLOT 0x00000008
+#define MGMT_PHY_EDR_2M_3SLOT 0x00000010
+#define MGMT_PHY_EDR_2M_5SLOT 0x00000020
+#define MGMT_PHY_EDR_3M_1SLOT 0x00000040
+#define MGMT_PHY_EDR_3M_3SLOT 0x00000080
+#define MGMT_PHY_EDR_3M_5SLOT 0x00000100
+#define MGMT_PHY_LE_1M_TX 0x00000200
+#define MGMT_PHY_LE_1M_RX 0x00000400
+#define MGMT_PHY_LE_2M_TX 0x00000800
+#define MGMT_PHY_LE_2M_RX 0x00001000
+#define MGMT_PHY_LE_CODED_TX 0x00002000
+#define MGMT_PHY_LE_CODED_RX 0x00004000

#define MGMT_PHY_LE_TX_MASK (MGMT_PHY_LE_1M_TX | MGMT_PHY_LE_2M_TX | \
MGMT_PHY_LE_CODED_TX)
@@ -570,7 +580,7 @@ struct mgmt_rp_get_phy_confguration {

#define MGMT_OP_SET_PHY_CONFIGURATION 0x0045
struct mgmt_cp_set_phy_confguration {
- uint16_t default_phys;
+ uint32_t selected_phys;
} __packed;


diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index f5bef63..9dc6712 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -4181,15 +4181,24 @@ static void cmd_appearance(int argc, char **argv)
}

static const char *phys_str[] = {
- "1MTX",
- "1MRX",
- "2MTX",
- "2MRX",
- "CODEDTX",
- "CODEDRX",
+ "BR_1M_1SLOT",
+ "BR_1M_3SLOT",
+ "BR_1M_5SLOT",
+ "EDR_2M_1SLOT",
+ "EDR_2M_3SLOT",
+ "EDR_2M_5SLOT",
+ "EDR_3M_1SLOT",
+ "EDR_3M_3SLOT",
+ "EDR_3M_5SLOT",
+ "LE_1M_TX",
+ "LE_1M_RX",
+ "LE_2M_TX",
+ "LE_2M_RX",
+ "LE_CODED_TX",
+ "LE_CODED_RX",
};

-static const char *phys2str(uint16_t phys)
+static const char *phys2str(uint32_t phys)
{
static char str[256];
unsigned int i;
@@ -4211,7 +4220,7 @@ static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
void *user_data)
{
const struct mgmt_rp_get_phy_confguration *rp = param;
- uint16_t supported_flags, selected_phys;
+ uint32_t supported_phys, selected_phys, configurable_phys;

if (status != 0) {
error("Get PHY Configuration failed with status 0x%02x (%s)",
@@ -4224,10 +4233,12 @@ static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
return bt_shell_noninteractive_quit(EXIT_FAILURE);
}

- supported_flags = get_le16(&rp->supported_phys);
- selected_phys = get_le16(&rp->selected_phys);
+ supported_phys = get_le32(&rp->supported_phys);
+ configurable_phys = get_le32(&rp->configurable_phys);
+ selected_phys = get_le32(&rp->selected_phys);

- print("Supported phys: %s", phys2str(supported_flags));
+ print("Supported phys: %s", phys2str(supported_phys));
+ print("Configurable phys: %s", phys2str(configurable_phys));
print("Selected phys: %s", phys2str(selected_phys));

bt_shell_noninteractive_quit(EXIT_SUCCESS);
@@ -4265,34 +4276,21 @@ static void set_phy_rsp(uint8_t status, uint16_t len, const void *param,
static void cmd_phy(int argc, char **argv)
{
struct mgmt_cp_set_phy_confguration cp;
- int i;
- uint16_t phys = 0;
+ int i, j;
+ uint32_t phys = 0;
uint16_t index;

if (argc < 2)
return get_phy();

for (i = 1; i < argc; i++) {
- if (strcasecmp(argv[i], "1MTX") == 0)
- phys |= MGMT_PHY_LE_1M_TX;
-
- if (strcasecmp(argv[i], "1MRX") == 0)
- phys |= MGMT_PHY_LE_1M_RX;
-
- if (strcasecmp(argv[i], "2MTX") == 0)
- phys |= MGMT_PHY_LE_2M_TX;
-
- if (strcasecmp(argv[i], "2MRX") == 0)
- phys |= MGMT_PHY_LE_2M_RX;
-
- if (strcasecmp(argv[i], "CODEDTX") == 0)
- phys |= MGMT_PHY_LE_CODED_TX;
-
- if (strcasecmp(argv[i], "CODEDRX") == 0)
- phys |= MGMT_PHY_LE_CODED_RX;
+ for (j = 0; j < NELEM(phys_str); j++) {
+ if (strcasecmp(argv[i], phys_str[j]) == 0)
+ phys |= (1 << j);
+ }
}

- cp.default_phys = cpu_to_le16(phys);
+ cp.selected_phys = cpu_to_le32(phys);

index = mgmt_index;
if (index == MGMT_INDEX_NONE)
@@ -4501,7 +4499,7 @@ static const struct bt_shell_menu main_menu = {
cmd_clr_adv, "Clear advertising instances" },
{ "appearance", "<appearance>",
cmd_appearance, "Set appearance" },
- { "phy", "[phys]",
+ { "phy", "[phys ...]",
cmd_phy, "Get/Set PHY Configuration" },
{} },
};
--
2.7.4

2018-07-06 11:27:58

by Jaganath K

[permalink] [raw]
Subject: [PATCH BlueZ 1/8] monitor: Fix 2-DH5 packet type print

3-DH5 is printed instaed of 2-DH5
---
monitor/packet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/monitor/packet.c b/monitor/packet.c
index 6798373..bf69859 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -762,7 +762,7 @@ static const struct {
{ 9, "3-DH3 may not be used" },
{ 10, "DM3 may be used" },
{ 11, "DH3 may be used" },
- { 12, "3-DH5 may not be used" },
+ { 12, "2-DH5 may not be used" },
{ 13, "3-DH5 may not be used" },
{ 14, "DM5 may be used" },
{ 15, "DH5 may be used" },
--
2.7.4

2018-08-23 09:24:51

by Jaganath K

[permalink] [raw]
Subject: Re: [PATCH BlueZ 2/8] btmgmt: Add BREDR PHYs in PHY Configuration commands

Hi,


On Fri, Jul 6, 2018 at 5:03 PM Jaganath Kanakkassery
<[email protected]> wrote:
>
> ---
> lib/mgmt.h | 32 +++++++++++++++++++-----------
> tools/btmgmt.c | 62 ++++++++++++++++++++++++++++------------------------------
> 2 files changed, 51 insertions(+), 43 deletions(-)
>
> diff --git a/lib/mgmt.h b/lib/mgmt.h
> index ec6a380..570dec9 100644
> --- a/lib/mgmt.h
> +++ b/lib/mgmt.h
> @@ -552,16 +552,26 @@ struct mgmt_cp_set_appearance {
>
> #define MGMT_OP_GET_PHY_CONFIGURATION 0x0044
> struct mgmt_rp_get_phy_confguration {
> - uint16_t supported_phys;
> - uint16_t selected_phys;
> -} __packed;
> -
> -#define MGMT_PHY_LE_1M_TX 0x0001
> -#define MGMT_PHY_LE_1M_RX 0x0002
> -#define MGMT_PHY_LE_2M_TX 0x0004
> -#define MGMT_PHY_LE_2M_RX 0x0008
> -#define MGMT_PHY_LE_CODED_TX 0x0010
> -#define MGMT_PHY_LE_CODED_RX 0x0020
> + uint32_t supported_phys;
> + uint32_t configurable_phys;
> + uint32_t selected_phys;
> +} __packed;
> +
> +#define MGMT_PHY_BR_1M_1SLOT 0x00000001
> +#define MGMT_PHY_BR_1M_3SLOT 0x00000002
> +#define MGMT_PHY_BR_1M_5SLOT 0x00000004
> +#define MGMT_PHY_EDR_2M_1SLOT 0x00000008
> +#define MGMT_PHY_EDR_2M_3SLOT 0x00000010
> +#define MGMT_PHY_EDR_2M_5SLOT 0x00000020
> +#define MGMT_PHY_EDR_3M_1SLOT 0x00000040
> +#define MGMT_PHY_EDR_3M_3SLOT 0x00000080
> +#define MGMT_PHY_EDR_3M_5SLOT 0x00000100
> +#define MGMT_PHY_LE_1M_TX 0x00000200
> +#define MGMT_PHY_LE_1M_RX 0x00000400
> +#define MGMT_PHY_LE_2M_TX 0x00000800
> +#define MGMT_PHY_LE_2M_RX 0x00001000
> +#define MGMT_PHY_LE_CODED_TX 0x00002000
> +#define MGMT_PHY_LE_CODED_RX 0x00004000
>
> #define MGMT_PHY_LE_TX_MASK (MGMT_PHY_LE_1M_TX | MGMT_PHY_LE_2M_TX | \
> MGMT_PHY_LE_CODED_TX)
> @@ -570,7 +580,7 @@ struct mgmt_rp_get_phy_confguration {
>
> #define MGMT_OP_SET_PHY_CONFIGURATION 0x0045
> struct mgmt_cp_set_phy_confguration {
> - uint16_t default_phys;
> + uint32_t selected_phys;
> } __packed;
>
>
> diff --git a/tools/btmgmt.c b/tools/btmgmt.c
> index f5bef63..9dc6712 100644
> --- a/tools/btmgmt.c
> +++ b/tools/btmgmt.c
> @@ -4181,15 +4181,24 @@ static void cmd_appearance(int argc, char **argv)
> }
>
> static const char *phys_str[] = {
> - "1MTX",
> - "1MRX",
> - "2MTX",
> - "2MRX",
> - "CODEDTX",
> - "CODEDRX",
> + "BR_1M_1SLOT",
> + "BR_1M_3SLOT",
> + "BR_1M_5SLOT",
> + "EDR_2M_1SLOT",
> + "EDR_2M_3SLOT",
> + "EDR_2M_5SLOT",
> + "EDR_3M_1SLOT",
> + "EDR_3M_3SLOT",
> + "EDR_3M_5SLOT",
> + "LE_1M_TX",
> + "LE_1M_RX",
> + "LE_2M_TX",
> + "LE_2M_RX",
> + "LE_CODED_TX",
> + "LE_CODED_RX",
> };
>
> -static const char *phys2str(uint16_t phys)
> +static const char *phys2str(uint32_t phys)
> {
> static char str[256];
> unsigned int i;
> @@ -4211,7 +4220,7 @@ static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
> void *user_data)
> {
> const struct mgmt_rp_get_phy_confguration *rp = param;
> - uint16_t supported_flags, selected_phys;
> + uint32_t supported_phys, selected_phys, configurable_phys;
>
> if (status != 0) {
> error("Get PHY Configuration failed with status 0x%02x (%s)",
> @@ -4224,10 +4233,12 @@ static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
> return bt_shell_noninteractive_quit(EXIT_FAILURE);
> }
>
> - supported_flags = get_le16(&rp->supported_phys);
> - selected_phys = get_le16(&rp->selected_phys);
> + supported_phys = get_le32(&rp->supported_phys);
> + configurable_phys = get_le32(&rp->configurable_phys);
> + selected_phys = get_le32(&rp->selected_phys);
>
> - print("Supported phys: %s", phys2str(supported_flags));
> + print("Supported phys: %s", phys2str(supported_phys));
> + print("Configurable phys: %s", phys2str(configurable_phys));
> print("Selected phys: %s", phys2str(selected_phys));
>
> bt_shell_noninteractive_quit(EXIT_SUCCESS);
> @@ -4265,34 +4276,21 @@ static void set_phy_rsp(uint8_t status, uint16_t len, const void *param,
> static void cmd_phy(int argc, char **argv)
> {
> struct mgmt_cp_set_phy_confguration cp;
> - int i;
> - uint16_t phys = 0;
> + int i, j;
> + uint32_t phys = 0;
> uint16_t index;
>
> if (argc < 2)
> return get_phy();
>
> for (i = 1; i < argc; i++) {
> - if (strcasecmp(argv[i], "1MTX") == 0)
> - phys |= MGMT_PHY_LE_1M_TX;
> -
> - if (strcasecmp(argv[i], "1MRX") == 0)
> - phys |= MGMT_PHY_LE_1M_RX;
> -
> - if (strcasecmp(argv[i], "2MTX") == 0)
> - phys |= MGMT_PHY_LE_2M_TX;
> -
> - if (strcasecmp(argv[i], "2MRX") == 0)
> - phys |= MGMT_PHY_LE_2M_RX;
> -
> - if (strcasecmp(argv[i], "CODEDTX") == 0)
> - phys |= MGMT_PHY_LE_CODED_TX;
> -
> - if (strcasecmp(argv[i], "CODEDRX") == 0)
> - phys |= MGMT_PHY_LE_CODED_RX;
> + for (j = 0; j < NELEM(phys_str); j++) {
> + if (strcasecmp(argv[i], phys_str[j]) == 0)
> + phys |= (1 << j);
> + }
> }
>
> - cp.default_phys = cpu_to_le16(phys);
> + cp.selected_phys = cpu_to_le32(phys);
>
> index = mgmt_index;
> if (index == MGMT_INDEX_NONE)
> @@ -4501,7 +4499,7 @@ static const struct bt_shell_menu main_menu = {
> cmd_clr_adv, "Clear advertising instances" },
> { "appearance", "<appearance>",
> cmd_appearance, "Set appearance" },
> - { "phy", "[phys]",
> + { "phy", "[phys ...]",
> cmd_phy, "Get/Set PHY Configuration" },
> {} },
> };
> --
> 2.7.4
>

This patch somehow got missed in the latest patchset which got merged.
Plz review this as well as this without this it cannot be tested with btmgmt.

Thanks,
Jaganath