2016-09-20 12:02:06

by Michał Narajowski

[permalink] [raw]
Subject: [PATCH BlueZ 1/5] doc/mgmt-api: Allow set appearance only for LE capable controllers

---
doc/mgmt-api.txt | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 334c884..a7bd6e4 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -2908,7 +2908,11 @@ Set Appearance Command
This command generates a Command Complete event on success
or a Command Status event on failure.

- Possible errors: Invalid Parameters
+ This command is only available for LE capable controllers.
+ It will return Not Supported otherwise.
+
+ Possible errors: Not Supported
+ Invalid Parameters
Invalid Index


--
2.7.4



2016-09-21 18:20:30

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCH BlueZ 1/5] doc/mgmt-api: Allow set appearance only for LE capable controllers

Hi Micha=C5=82,

On Tuesday, 20 September 2016 14:02:06 CEST Micha=C5=82 Narajowski wrote:
> ---
> doc/mgmt-api.txt | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>=20
> diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
> index 334c884..a7bd6e4 100644
> --- a/doc/mgmt-api.txt
> +++ b/doc/mgmt-api.txt
> @@ -2908,7 +2908,11 @@ Set Appearance Command
> This command generates a Command Complete event on success
> or a Command Status event on failure.
>=20
> - Possible errors: Invalid Parameters
> + This command is only available for LE capable controllers.
> + It will return Not Supported otherwise.
> +
> + Possible errors: Not Supported
> + Invalid Parameters
> Invalid Index

All patches applied, thanks.

=2D-=20
pozdrawiam
Szymon Janc

2016-09-20 12:02:10

by Michał Narajowski

[permalink] [raw]
Subject: [PATCH BlueZ 5/5] tools/mgmt-tester: Add appearance to Read Ext Controller Info

---
tools/mgmt-tester.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index a253f84..b052570 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -4920,12 +4920,16 @@ static const char ext_ctrl_info2[] = {
0x3f, 0x00, /* manufacturer */
0xff, 0xbf, 0x00, 0x00, /* supported settings */
0x81, 0x02, 0x00, 0x00, /* current settings */
- 0x09, 0x00, /* eir length */
+ 0x0D, 0x00, /* eir length */
0x04, /* dev class length */
0x0d, /* dev class info */
0xe0, /* minor */
0x03, /* major */
0x00, /* service classes */
+ 0x03, /* appearance length */
+ 0x19, /* EIR_APPEARANCE */
+ 0x00, /* Appearance value */
+ 0x00,
0x01, /* complete name data length */
0x09, /* complete name flag */
0x01, /* short name data length */
@@ -4947,12 +4951,16 @@ static const char ext_ctrl_info3[] = {
0x3f, 0x00, /* manufacturer */
0xff, 0xbf, 0x00, 0x00, /* supported settings */
0x80, 0x02, 0x00, 0x00, /* current settings */
- 0x12, 0x00, /* eir length */
+ 0x16, 0x00, /* eir length */
0x04, /* dev class length */
0x0d, /* dev class info */
0x00, /* minor */
0x00, /* major */
0x00, /* service classes */
+ 0x03, /* appearance length */
+ 0x19, /* EIR_APPEARANCE */
+ 0x00, /* Appearance value */
+ 0x00,
0x0A, /* Local name length */
0x09, /* Complete name */
0x54, 0x65, 0x73, 0x74,
@@ -4983,12 +4991,16 @@ static const char ext_ctrl_info4[] = {
0x3f, 0x00, /* manufacturer */
0xff, 0xbf, 0x00, 0x00, /* supported settings */
0x80, 0x02, 0x00, 0x00, /* current settings */
- 0x16, 0x00, /* eir length */
+ 0x1a, 0x00, /* eir length */
0x04, /* dev class length */
0x0d, /* dev class info */
0x00, /* minor */
0x00, /* major */
0x00, /* service classes */
+ 0x03, /* appearance length */
+ 0x19, /* EIR_APPEARANCE */
+ 0x00, /* Appearance value */
+ 0x00,
0x0A, /* Complete Local name len */
0x09, /* Complete name */
0x54, 0x65, 0x73, 0x74,
@@ -5038,12 +5050,16 @@ static const char ext_ctrl_info5[] = {
0x3f, 0x00, /* manufacturer */
0xff, 0xbf, 0x00, 0x00, /* supported settings */
0x81, 0x02, 0x00, 0x00, /* current settings */
- 0x16, 0x00, /* eir len */
+ 0x1a, 0x00, /* eir len */
0x04, /* dev class len */
0x0d, /* dev class info */
0xe0, /* minor */
0x03, /* major */
0x00, /* service classes */
+ 0x03, /* appearance length */
+ 0x19, /* EIR_APPEARANCE */
+ 0x00, /* Appearance value */
+ 0x00,
0x0A, /* Complete Local name len */
0x09, /* Complete name */
0x54, 0x65, 0x73, 0x74,
--
2.7.4


2016-09-20 12:02:09

by Michał Narajowski

[permalink] [raw]
Subject: [PATCH BlueZ 4/5] tools/mgmt-tester: Test Set Appearance support in different modes

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

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 8d85cd4..a253f84 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -7862,6 +7862,21 @@ int main(int argc, char *argv[])
setup_add_advertising_duration,
test_command_generic, 3);

+ test_bredr("Set appearance - BR/EDR only",
+ &set_appearance_not_supported,
+ NULL,
+ test_command_generic);
+
+ test_bredrle("Set appearance - BR/EDR LE",
+ &set_appearance_success,
+ NULL,
+ test_command_generic);
+
+ test_le("Set appearance - LE only",
+ &set_appearance_success,
+ NULL,
+ test_command_generic);
+
test_bredrle("Read Ext Controller Info 1",
&read_ext_ctrl_info1,
setup_command_generic, test_command_generic);
--
2.7.4


2016-09-20 12:02:08

by Michał Narajowski

[permalink] [raw]
Subject: [PATCH BlueZ 3/5] tools/mgmt-tester: Test add appearance in scan rsp data

---
tools/mgmt-tester.c | 292 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 290 insertions(+), 2 deletions(-)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 547249e..8d85cd4 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -4005,7 +4005,7 @@ static const struct generic_data read_adv_features_invalid_index_test = {
};

static const uint8_t read_adv_features_rsp_1[] = {
- 0x5f, 0x00, 0x00, 0x00, /* supported flags */
+ 0x7f, 0x00, 0x00, 0x00, /* supported flags */
0x1f, /* max_adv_data_len */
0x1f, /* max_scan_rsp_len */
0x05, /* max_instances */
@@ -4020,7 +4020,7 @@ static const struct generic_data read_adv_features_success_1 = {
};

static const uint8_t read_adv_features_rsp_2[] = {
- 0x5f, 0x00, 0x00, 0x00, /* supported flags */
+ 0x7f, 0x00, 0x00, 0x00, /* supported flags */
0x1f, /* max_adv_data_len */
0x1f, /* max_scan_rsp_len */
0x05, /* max_instances */
@@ -6329,6 +6329,264 @@ static const struct generic_data add_advertising_dta_name_scrsp = {
.expect_hci_len = sizeof(set_scan_rsp_data_shortened_name),
};

+static const uint8_t add_advertising_param_appearance1[] = {
+ 0x01, /* adv instance */
+ 0x20, 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_scan_rsp_data_appearance1[] = {
+ 0x04, /* Scan rsp data len */
+ 0x03, /* appearance data len */
+ 0x19, /* EIR_APPEARANCE */
+ 0x054, 0x65, /* appearance value */
+ /* 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 uint8_t set_appearance_param[2] = { 0x54, 0x65 };
+
+static const struct generic_data set_appearance_not_supported = {
+ .send_opcode = MGMT_OP_SET_APPEARANCE,
+ .send_param = set_appearance_param,
+ .send_len = sizeof(set_appearance_param),
+ .expect_status = MGMT_STATUS_NOT_SUPPORTED,
+ .expect_param = NULL,
+ .expect_len = 0,
+};
+
+static const struct generic_data set_appearance_success = {
+ .send_opcode = MGMT_OP_SET_APPEARANCE,
+ .send_param = set_appearance_param,
+ .send_len = sizeof(set_appearance_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = NULL,
+ .expect_len = 0,
+};
+
+static const struct generic_data add_advertising_appearance_scrsp = {
+ .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_appearance1,
+ .send_len = sizeof(add_advertising_param_appearance1),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_SCAN_RSP_DATA,
+ .expect_hci_param = set_scan_rsp_data_appearance1,
+ .expect_hci_len = sizeof(set_scan_rsp_data_appearance1),
+};
+
+static const uint8_t add_advertising_param_appearance2_data[] = {
+ 0x01, /* adv instance */
+ 0x20, 0x00, 0x00, 0x00, /* flags: Add local name to scan_rsp */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x19, /* scan rsp len */
+ /* 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,
+};
+
+static const uint8_t set_scan_rsp_data_only_data[] = {
+ 0x19, /* 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, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00,
+ /*padding */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static const struct generic_data add_advertising_appear_data_scrsp = {
+ .setup_settings = settings_powered_le,
+ .setup_expect_hci_command = BT_HCI_CMD_LE_SET_SCAN_RSP_DATA,
+ .setup_expect_hci_param = set_scan_rsp_data_only_data,
+ .setup_expect_hci_len = sizeof(set_scan_rsp_data_only_data),
+ .setup_send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .setup_send_param = add_advertising_param_appearance2_data,
+ .setup_send_len = sizeof(add_advertising_param_appearance2_data),
+ .send_opcode = MGMT_OP_SET_APPEARANCE,
+ .send_param = set_appearance_param,
+ .send_len = sizeof(set_appearance_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = NULL,
+ .expect_len = 0,
+};
+
+static const uint8_t add_advertising_param_appearance_data_too_long[] = {
+ 0x01, /* adv instance */
+ 0x20, 0x00, 0x00, 0x00, /* flags: Add local name to scan_rsp */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x30, /* 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,
+};
+
+static const struct generic_data add_advertising_scrsp_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_appearance_data_too_long,
+ .send_len = sizeof(add_advertising_param_appearance_data_too_long),
+ .expect_status = MGMT_STATUS_INVALID_PARAMS,
+ .expect_param = NULL,
+ .expect_len = 0,
+};
+
+static const struct setup_mgmt_cmd add_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_param,
+ .send_len = sizeof(set_local_name_param),
+ },
+ { /* last element should always have opcode 0x00 */
+ .send_opcode = 0x00,
+ .send_param = NULL,
+ .send_len = 0,
+ }
+};
+
+static const uint8_t add_advertising_param_local_name_and_appearance[] = {
+ 0x01, /* adv instance */
+ 0x60, 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_scan_rsp_data_local_name_and_appearance[] = {
+ 0x0F, /* Scan rsp data len */
+ 0x03, /* Appearance data len */
+ 0x19, /* EIR_APPEARANCE */
+ 0x54, 0x65, /* appearance value */
+ 0x0A, /* 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
+};
+
+static const struct generic_data add_advertising_name_appear_scrsp = {
+ .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_local_name_and_appearance,
+ .send_len = sizeof(add_advertising_param_local_name_and_appearance),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_SCAN_RSP_DATA,
+ .expect_hci_param = set_scan_rsp_data_local_name_and_appearance,
+ .expect_hci_len = sizeof(set_scan_rsp_data_local_name_and_appearance),
+};
+
+static const uint8_t add_advertising_param_local_name_and_appearance_dta[] = {
+ 0x01, /* adv instance */
+ 0x60, 0x00, 0x00, 0x00, /* flags: Add local name to scan_rsp */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x15, /* scan rsp len */
+ /* scan rsp data: */
+ 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 set_scan_rsp_local_name_and_appearance_dta[] = {
+ 0x1f, /* Scan rsp len */
+ 0x03, /* Appearance data len */
+ 0x19, /* EIR_APPEARANCE */
+ 0x54, 0x65, /* appearance value */
+ /* placeholder data */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00,
+ 0x05, /* Local name length */
+ 0x08, /* Shortened name */
+ 0x54, 0x65, 0x73, 0x74, /* "Test" */
+};
+
+static const struct generic_data add_advertising_appear_data_name = {
+ .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_local_name_and_appearance_dta,
+ .send_len = sizeof(add_advertising_param_local_name_and_appearance_dta),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_SCAN_RSP_DATA,
+ .expect_hci_param = set_scan_rsp_local_name_and_appearance_dta,
+ .expect_hci_len = sizeof(set_scan_rsp_local_name_and_appearance_dta),
+};
+
+static const uint8_t add_advertising_param_short_name_and_appearance_dta[] = {
+ 0x01, /* adv instance */
+ 0x60, 0x00, 0x00, 0x00, /* flags: Add local name to scan_rsp */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x00, /* adv data len */
+ 0x18, /* scan rsp len */
+ /* 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,
+};
+
+static const uint8_t set_scan_rsp_short_name_and_appearance_dta[] = {
+ 0x1f, /* Scan rsp len */
+ 0x03, /* Appearance data len */
+ 0x19, /* EIR_APPEARANCE */
+ 0x54, 0x65, /* appearance value */
+ /* 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,
+ 0x02, /* Local name data length */
+ 0x08, /* Shortened name */
+ 0x54, /* "T" */
+};
+
+static const struct generic_data add_advertising_appear_data_short = {
+ .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_short_name_and_appearance_dta,
+ .send_len = sizeof(add_advertising_param_short_name_and_appearance_dta),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_SCAN_RSP_DATA,
+ .expect_hci_param = set_scan_rsp_short_name_and_appearance_dta,
+ .expect_hci_len = sizeof(set_scan_rsp_short_name_and_appearance_dta),
+};
+
static bool power_off(uint16_t index)
{
int sk, err;
@@ -7545,6 +7803,36 @@ int main(int argc, char *argv[])
setup_command_generic,
test_command_generic);

+ test_bredrle("Add Advertising - Success 5 (Appearance in ScRsp)",
+ &add_advertising_appearance_scrsp,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Success 6 (Appear + Dta in ScRsp)",
+ &add_advertising_appear_data_scrsp,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Invalid Params 1 (ScRsp Too long)",
+ &add_advertising_scrsp_too_long,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Success 1 (Name + appear in ScRsp)",
+ &add_advertising_name_appear_scrsp,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Success 2 (Appear + Dta + name)",
+ &add_advertising_appear_data_name,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Success 3 (Appear + Dta + short)",
+ &add_advertising_appear_data_short,
+ setup_command_generic,
+ test_command_generic);
+

test_bredrle("Remove Advertising - Invalid Params 1",
&remove_advertising_fail_1,
--
2.7.4


2016-09-20 12:02:07

by Michał Narajowski

[permalink] [raw]
Subject: [PATCH BlueZ 2/5] tools/mgmt-tester: Test add local name in scan rsp data

Appropriate HCI command is expected in setup section because
as soon as new local name is registered in the kernel the
HCI_OP_LE_SET_SCAN_RSP_DATA is triggered. Then when we pass
Add_local_name_to_Scan_rsp_data flag in Add advertising
command the HCI command is not triggered because
Scan response data has not changed.
---
tools/mgmt-tester.c | 202 +++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 194 insertions(+), 8 deletions(-)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 1533cc1..547249e 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -4005,7 +4005,7 @@ static const struct generic_data read_adv_features_invalid_index_test = {
};

static const uint8_t read_adv_features_rsp_1[] = {
- 0x1f, 0x00, 0x00, 0x00, /* supported flags */
+ 0x5f, 0x00, 0x00, 0x00, /* supported flags */
0x1f, /* max_adv_data_len */
0x1f, /* max_scan_rsp_len */
0x05, /* max_instances */
@@ -4020,7 +4020,7 @@ static const struct generic_data read_adv_features_success_1 = {
};

static const uint8_t read_adv_features_rsp_2[] = {
- 0x1f, 0x00, 0x00, 0x00, /* supported flags */
+ 0x5f, 0x00, 0x00, 0x00, /* supported flags */
0x1f, /* max_adv_data_len */
0x1f, /* max_scan_rsp_len */
0x05, /* max_instances */
@@ -6115,7 +6115,7 @@ static void setup_mgmt_cmd_callback(uint8_t status, uint16_t length,
tester_setup_complete();
}

-static void setup_set_local_name(const void *test_data)
+static void setup_command_generic(const void *test_data)
{
struct test_data *data = tester_get_data();
const struct generic_data *test = data->test_data;
@@ -6163,6 +6163,172 @@ static void setup_set_local_name(const void *test_data)
tester_setup_complete();
}

+static const uint8_t add_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_scan_rsp_data_name[] = {
+ 0x0b, /* Scan rsp data len */
+ 0x0a, /* 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_advertising_name_in_scrsp = {
+ .setup_settings = settings_powered_le,
+ .setup_expect_hci_command = BT_HCI_CMD_LE_SET_SCAN_RSP_DATA,
+ .setup_expect_hci_param = set_scan_rsp_data_name,
+ .setup_expect_hci_len = sizeof(set_scan_rsp_data_name),
+ .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_name,
+ .send_len = sizeof(add_advertising_param_name),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+};
+
+static const uint8_t add_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 uint8_t set_scan_rsp_data_empty[] = {
+ 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_advertising_empty_scrsp = {
+ .setup_settings = settings_powered_le,
+ .setup_expect_hci_command = BT_HCI_CMD_LE_SET_SCAN_RSP_DATA,
+ .setup_expect_hci_param = set_scan_rsp_data_name,
+ .setup_expect_hci_len = sizeof(set_scan_rsp_data_name),
+ .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),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_SCAN_RSP_DATA,
+ .expect_hci_param = set_scan_rsp_data_empty,
+ .expect_hci_len = sizeof(set_scan_rsp_data_empty),
+};
+
+static const uint8_t add_advertising_param_name_data_scrsp[] = {
+ 0x01, /* adv instance */
+ 0x40, 0x00, 0x00, 0x00, /* flags: Add local name to scan_rsp */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x09, /* adv data len */
+ 0x14, /* 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 */
+ /* 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 uint8_t set_scan_rsp_data_name_data[] = {
+ 0x1f, /* Scan rsp data len */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0a, /* Local name data len */
+ 0x09, /* Complete name */
+ 0x54, 0x65, 0x73, 0x74, 0x20, 0x6e, 0x61, 0x6d, 0x65, /* "Test name" */
+};
+
+static const struct generic_data add_advertising_name_data_scrsp = {
+ .setup_settings = settings_powered_le,
+ .setup_expect_hci_command = BT_HCI_CMD_LE_SET_SCAN_RSP_DATA,
+ .setup_expect_hci_param = set_scan_rsp_data_name,
+ .setup_expect_hci_len = sizeof(set_scan_rsp_data_name),
+ .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_name_data_scrsp,
+ .send_len = sizeof(add_advertising_param_name_data_scrsp),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_SCAN_RSP_DATA,
+ .expect_hci_param = set_scan_rsp_data_name_data,
+ .expect_hci_len = sizeof(set_scan_rsp_data_name_data),
+};
+
+static const uint8_t add_advertising_param_data_name_scan_rsp[] = {
+ 0x01, /* adv instance */
+ 0x40, 0x00, 0x00, 0x00, /* flags: Add local name to scan_rsp */
+ 0x00, 0x00, /* duration: default */
+ 0x00, 0x00, /* timeout: none */
+ 0x09, /* adv data len */
+ 0x19, /* 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 */
+ /* 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,
+};
+
+static const uint8_t set_scan_rsp_data_shortened_name[] = {
+ 0x1f, /* Scan rsp len */
+ 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, /* placeholder data */
+ 0x05, /* Local name length */
+ 0x08, /* Shortened name */
+ 0x54, 0x65, 0x73, 0x74, /* "Test" */
+};
+
+static const struct generic_data add_advertising_dta_name_scrsp = {
+ .setup_settings = settings_powered_le,
+ .setup_expect_hci_command = BT_HCI_CMD_LE_SET_SCAN_RSP_DATA,
+ .setup_expect_hci_param = set_scan_rsp_data_name,
+ .setup_expect_hci_len = sizeof(set_scan_rsp_data_name),
+ .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_data_name_scan_rsp,
+ .send_len = sizeof(add_advertising_param_data_name_scan_rsp),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_SCAN_RSP_DATA,
+ .expect_hci_param = set_scan_rsp_data_shortened_name,
+ .expect_hci_len = sizeof(set_scan_rsp_data_shortened_name),
+};
+
static bool power_off(uint16_t index)
{
int sk, err;
@@ -7359,6 +7525,26 @@ int main(int argc, char *argv[])
setup_add_advertising,
test_command_generic);

+ test_bredrle("Add Advertising - Success 1 (Name in ScRsp)",
+ &add_advertising_name_in_scrsp,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Success 2 (Empty ScRsp)",
+ &add_advertising_empty_scrsp,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Success 3 (Name + data in ScRsp)",
+ &add_advertising_name_data_scrsp,
+ setup_command_generic,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Success 4 (Dta + name in ScRsp)",
+ &add_advertising_dta_name_scrsp,
+ setup_command_generic,
+ test_command_generic);
+

test_bredrle("Remove Advertising - Invalid Params 1",
&remove_advertising_fail_1,
@@ -7390,23 +7576,23 @@ int main(int argc, char *argv[])

test_bredrle("Read Ext Controller Info 1",
&read_ext_ctrl_info1,
- setup_set_local_name, test_command_generic);
+ setup_command_generic, test_command_generic);

test_bredrle("Read Ext Controller Info 2",
&read_ext_ctrl_info2,
- setup_set_local_name, test_command_generic);
+ setup_command_generic, test_command_generic);

test_bredrle("Read Ext Controller Info 3",
&read_ext_ctrl_info3,
- setup_set_local_name, test_command_generic);
+ setup_command_generic, test_command_generic);

test_bredrle("Read Ext Controller Info 4",
&read_ext_ctrl_info4,
- setup_set_local_name, test_command_generic);
+ setup_command_generic, test_command_generic);

test_bredrle("Read Ext Controller Info 5",
&read_ext_ctrl_info5,
- setup_set_local_name, test_command_generic);
+ setup_command_generic, test_command_generic);

test_bredrle("Read Local OOB Data - Not powered",
&read_local_oob_not_powered_test,
--
2.7.4