From: Michał Narajowski <[email protected]>
---
doc/mgmt-api.txt | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 2b8a81d..ed0cb99 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -2885,6 +2885,31 @@ Read Extended Controller Information Command
Invalid Index
+Set Appearance Command
+======================
+
+ Command Code: 0x0042
+ Controller Index: <controller id>
+ Command Parameters: Appearance (2 Octets)
+ Return Parameters: Appearance (2 Octets)
+
+ This command is used to set the appearance value of a controller.
+
+ This command can be used when the controller is not
+ powered and all settings will be programmed once powered.
+
+ The value of appearance will be remembered when switching
+ the controller off and back on again. So the appearance only
+ have to be set once when a new controller is found and will
+ stay until removed.
+
+ This command generates a Command Complete event on success
+ or a Command Status event on failure.
+
+ Possible errors: Invalid Parameters
+ Invalid Index
+
+
Command Complete Event
======================
--
2.7.4
Hi Marcel,
On Thursday, 8 September 2016 00:02:59 CEST Marcel Holtmann wrote:
> Hi Szymon,
>
> > ---
> > doc/mgmt-api.txt | 25 +++++++++++++++++++++++++
> > 1 file changed, 25 insertions(+)
> >
> > diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
> > index 2b8a81d..ed0cb99 100644
> > --- a/doc/mgmt-api.txt
> > +++ b/doc/mgmt-api.txt
> > @@ -2885,6 +2885,31 @@ Read Extended Controller Information Command
> >
> > Invalid Index
> >
> > +Set Appearance Command
> > +======================
> > +
> > + Command Code: 0x0042
> > + Controller Index: <controller id>
> > + Command Parameters: Appearance (2 Octets)
> > + Return Parameters: Appearance (2 Octets)
>
> hmmm. While I get that Set Local Name returns the input parameters, the Set
> Device ID does not. For Set Device Class is that we match major and minor
> class into class of device.
>
> So my thinking is that we should not return any result values. Thoughts?
I'll remove Appearance from return parameters.
--
pozdrawiam
Szymon Janc
Hi Szymon,
> ---
> doc/mgmt-api.txt | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
> index 2b8a81d..ed0cb99 100644
> --- a/doc/mgmt-api.txt
> +++ b/doc/mgmt-api.txt
> @@ -2885,6 +2885,31 @@ Read Extended Controller Information Command
> Invalid Index
>
>
> +Set Appearance Command
> +======================
> +
> + Command Code: 0x0042
> + Controller Index: <controller id>
> + Command Parameters: Appearance (2 Octets)
> + Return Parameters: Appearance (2 Octets)
hmmm. While I get that Set Local Name returns the input parameters, the Set Device ID does not. For Set Device Class is that we match major and minor class into class of device.
So my thinking is that we should not return any result values. Thoughts?
Regards
Marcel
This allows to set local-name and appearance flags for add advertising
command.
---
tools/btmgmt.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 38e959f..43b73f2 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -4071,6 +4071,8 @@ static void add_adv_usage(void)
"\t -c, --connectable \"connectable\" flag\n"
"\t -g, --general-discov \"general-discoverable\" flag\n"
"\t -l, --limited-discov \"limited-discoverable\" flag\n"
+ "\t -n, --scan-rsp-local-name \"local-name\" flag\n"
+ "\t -a, --scan-rsp-appearance \"appearance\" flag\n"
"\t -m, --managed-flags \"managed-flags\" flag\n"
"\t -p, --tx-power \"tx-power\" flag\n"
"e.g.:\n"
@@ -4231,6 +4233,12 @@ static void cmd_add_adv(struct mgmt *mgmt, uint16_t index,
case 'p':
flags |= MGMT_ADV_FLAG_TX_POWER;
break;
+ case 'n':
+ flags |= MGMT_ADV_FLAG_LOCAL_NAME;
+ break;
+ case 'a':
+ flags |= MGMT_ADV_FLAG_APPEARANCE;
+ break;
case 'h':
success = true;
default:
--
2.7.4
From: Michał Narajowski <[email protected]>
---
tools/mgmt-tester.c | 362 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 360 insertions(+), 2 deletions(-)
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 9a06fa3..91b5aa7 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,324 @@ static const struct generic_data add_advertising_with_local_name4 = {
.expect_hci_len = sizeof(set_scan_rsp_data_local_name4),
};
+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,
+ 0x02,
+ 0x054, 0x65,
+ /* 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 add_advertising_with_appearance1 = {
+ .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[] = {
+ 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_appearance2[] = {
+ 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_with_appearance2 = {
+ .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_appearance2,
+ .setup_expect_hci_len = sizeof(set_scan_rsp_data_appearance2),
+ .setup_send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .setup_send_param = add_advertising_param_appearance2,
+ .setup_send_len = sizeof(add_advertising_param_appearance2),
+ .send_opcode = MGMT_OP_SET_APPEARANCE,
+ .send_param = set_appearance_param,
+ .send_len = sizeof(set_appearance_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = set_appearance_param,
+ .expect_len = sizeof(set_appearance_param),
+};
+
+static const uint8_t add_advertising_param_appearance3[] = {
+ 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_with_appearance3 = {
+ .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_appearance3,
+ .send_len = sizeof(add_advertising_param_appearance3),
+ .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_appearance1[] = {
+ 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_appearance1[] = {
+ 0x0F, /* Scan rsp data len */
+ 0x03, /* Appearance data len */
+ 0x02, /* Appearance len */
+ 0x54, 0x65,
+ 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_local_name_appearance1 = {
+ .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_appearance1,
+ .send_len = sizeof(add_advertising_param_local_name_and_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_local_name_and_appearance1,
+ .expect_hci_len = sizeof(set_scan_rsp_data_local_name_and_appearance1),
+};
+
+static const uint8_t add_advertising_param_local_name_and_appearance2[] = {
+ 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_data_local_name_and_appearance2[] = {
+ 0x1f, /* Scan rsp len */
+ 0x03, /* Appearance data len */
+ 0x02, /* Appearance len */
+ 0x54, 0x65,
+ /* 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_local_name_appearance2 = {
+ .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_appearance2,
+ .send_len = sizeof(add_advertising_param_local_name_and_appearance2),
+ .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_appearance2,
+ .expect_hci_len = sizeof(set_scan_rsp_data_local_name_and_appearance2),
+};
+
+static const uint8_t add_advertising_param_local_name_and_appearance3[] = {
+ 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 */
+ 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_local_name_and_appearance3[] = {
+ 0x1d, /* Scan rsp len */
+ 0x03, /* Appearance data len */
+ 0x02, /* Appearance len */
+ 0x54, 0x65,
+ /* 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,
+ /* padding */
+ 0x00, 0x00,
+};
+
+static const struct generic_data add_advertising_local_name_appearance3 = {
+ .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_appearance3,
+ .send_len = sizeof(add_advertising_param_local_name_and_appearance3),
+ .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_appearance3,
+ .expect_hci_len = sizeof(set_scan_rsp_data_local_name_and_appearance3),
+};
+
+static const uint8_t add_advertising_param_local_name_and_appearance4[] = {
+ 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 */
+ 0x1b, /* 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, 0x00, 0x00
+};
+
+static const uint8_t set_scan_rsp_data_local_name_and_appearance4[] = {
+ 0x1f, /* Scan rsp len */
+ 0x03, /* Appearance data len */
+ 0x02, /* Appearance len */
+ 0x54, 0x65,
+ /* 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,
+};
+
+static const struct generic_data add_advertising_local_name_appearance4 = {
+ .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_appearance4,
+ .send_len = sizeof(add_advertising_param_local_name_and_appearance4),
+ .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_appearance4,
+ .expect_hci_len = sizeof(set_scan_rsp_data_local_name_and_appearance4),
+};
+
+static const uint8_t add_advertising_param_local_name_and_appearance5[] = {
+ 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_data_local_name_and_appearance5[] = {
+ 0x1f, /* Scan rsp len */
+ 0x03, /* Appearance data len */
+ 0x02, /* Appearance len */
+ 0x54, 0x65,
+ /* 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_local_name_appearance5 = {
+ .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_appearance5,
+ .send_len = sizeof(add_advertising_param_local_name_and_appearance5),
+ .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_appearance5,
+ .expect_hci_len = sizeof(set_scan_rsp_data_local_name_and_appearance5),
+};
+
static bool power_off(uint16_t index)
{
int sk, err;
@@ -7574,6 +7892,46 @@ int main(int argc, char *argv[])
setup_set_local_name,
test_command_generic);
+ test_bredrle("Add Advertising - Scan rsp flags 5",
+ &add_advertising_with_appearance1,
+ setup_set_local_name,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Scan rsp flags 6",
+ &add_advertising_with_appearance2,
+ setup_set_local_name,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Scan rsp flags 7",
+ &add_advertising_with_appearance3,
+ setup_set_local_name,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Scan rsp flags 8",
+ &add_advertising_local_name_appearance1,
+ setup_set_local_name,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Scan rsp flags 9",
+ &add_advertising_local_name_appearance2,
+ setup_set_local_name,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Scan rsp flags 10",
+ &add_advertising_local_name_appearance3,
+ setup_set_local_name,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Scan rsp flags 11",
+ &add_advertising_local_name_appearance4,
+ setup_set_local_name,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Scan rsp flags 12",
+ &add_advertising_local_name_appearance5,
+ setup_set_local_name,
+ test_command_generic);
+
test_bredrle("Read Ext Controller Info 1",
&read_ext_ctrl_info1,
setup_set_local_name, test_command_generic);
--
2.7.4
From: Michał Narajowski <[email protected]>
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 | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 188 insertions(+), 2 deletions(-)
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 1533cc1..9a06fa3 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 */
@@ -6163,6 +6163,172 @@ static void setup_set_local_name(const void *test_data)
tester_setup_complete();
}
+static const uint8_t add_advertising_param_local_name1[] = {
+ 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_local_name1[] = {
+ 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_with_local_name1 = {
+ .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_local_name1,
+ .setup_expect_hci_len = sizeof(set_scan_rsp_data_local_name1),
+ .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_local_name1,
+ .send_len = sizeof(add_advertising_param_local_name1),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = advertising_instance1_param,
+ .expect_len = sizeof(advertising_instance1_param),
+};
+
+static const uint8_t add_advertising_param_local_name2[] = {
+ 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_local_name2[] = {
+ 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_with_local_name2 = {
+ .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_local_name1,
+ .setup_expect_hci_len = sizeof(set_scan_rsp_data_local_name1),
+ .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_local_name2,
+ .send_len = sizeof(add_advertising_param_local_name2),
+ .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_name2,
+ .expect_hci_len = sizeof(set_scan_rsp_data_local_name2),
+};
+
+static const uint8_t add_advertising_param_local_name3[] = {
+ 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_local_name3[] = {
+ 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_with_local_name3 = {
+ .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_local_name1,
+ .setup_expect_hci_len = sizeof(set_scan_rsp_data_local_name1),
+ .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_local_name3,
+ .send_len = sizeof(add_advertising_param_local_name3),
+ .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_name3,
+ .expect_hci_len = sizeof(set_scan_rsp_data_local_name3),
+};
+
+static const uint8_t add_advertising_param_local_name4[] = {
+ 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_local_name4[] = {
+ 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_with_local_name4 = {
+ .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_local_name1,
+ .setup_expect_hci_len = sizeof(set_scan_rsp_data_local_name1),
+ .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_local_name4,
+ .send_len = sizeof(add_advertising_param_local_name4),
+ .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_name4,
+ .expect_hci_len = sizeof(set_scan_rsp_data_local_name4),
+};
+
static bool power_off(uint16_t index)
{
int sk, err;
@@ -7388,6 +7554,26 @@ int main(int argc, char *argv[])
setup_add_advertising_duration,
test_command_generic, 3);
+ test_bredrle("Add Advertising - Scan rsp flags 1",
+ &add_advertising_with_local_name1,
+ setup_set_local_name,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Scan rsp flags 2",
+ &add_advertising_with_local_name2,
+ setup_set_local_name,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Scan rsp flags 3",
+ &add_advertising_with_local_name3,
+ setup_set_local_name,
+ test_command_generic);
+
+ test_bredrle("Add Advertising - Scan rsp flags 4",
+ &add_advertising_with_local_name4,
+ setup_set_local_name,
+ test_command_generic);
+
test_bredrle("Read Ext Controller Info 1",
&read_ext_ctrl_info1,
setup_set_local_name, test_command_generic);
--
2.7.4
From: Michał Narajowski <[email protected]>
---
lib/mgmt.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/mgmt.h b/lib/mgmt.h
index 8de2616..798a05e 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -541,6 +541,11 @@ struct mgmt_rp_read_ext_info {
uint8_t eir[0];
} __packed;
+#define MGMT_OP_SET_APPEARANCE 0x0043
+struct mgmt_cp_set_appearance {
+ uint16_t appearance;
+} __packed;
+
#define MGMT_EV_CMD_COMPLETE 0x0001
struct mgmt_ev_cmd_complete {
uint16_t opcode;
@@ -827,6 +832,7 @@ static const char *mgmt_op[] = {
"Get Advertising Size Information", /* 0x0040 */
"Start Limited Discovery",
"Read Extended Controller Information",
+ "Set Appearance",
};
static const char *mgmt_ev[] = {
--
2.7.4