2016-09-19 12:33:33

by Michał Narajowski

[permalink] [raw]
Subject: [PATCH] Bluetooth: Set appearance only for LE capable controllers

Setting appearance on controllers without LE support will result
in No Supported error.

Signed-off-by: Michał Narajowski <[email protected]>
---
net/bluetooth/mgmt.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 54dd218..4e37e7a 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -3153,6 +3153,10 @@ static int set_appearance(struct sock *sk, struct hci_dev *hdev, void *data,

BT_DBG("");

+ if (!lmp_le_capable(hdev))
+ return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_APPEARANCE,
+ MGMT_STATUS_NOT_SUPPORTED);
+
apperance = le16_to_cpu(cp->appearance);

hci_dev_lock(hdev);
--
2.7.4



2016-09-21 18:13:39

by Szymon Janc

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

Hi Micha=C5=82,

On Monday, 19 September 2016 14:33:34 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

This patch is applied. Second patch needs to be rebased. Thanks.

=2D-=20
pozdrawiam
Szymon Janc

2016-09-19 18:49:57

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: Set appearance only for LE capable controllers

Hi Michał,

On Mon, Sep 19, 2016, Michał Narajowski wrote:
> Setting appearance on controllers without LE support will result
> in No Supported error.
>
> Signed-off-by: Michał Narajowski <[email protected]>
> ---
> net/bluetooth/mgmt.c | 4 ++++
> 1 file changed, 4 insertions(+)

Applied to bluetooth-next. Thanks.

Johan

2016-09-19 12:33:35

by Michał Narajowski

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

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

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 91b5aa7..75736bf 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -6351,6 +6351,24 @@ static const uint8_t set_scan_rsp_data_appearance1[] = {

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_with_appearance1 = {
.setup_settings = settings_powered_le,
.setup_send_opcode = MGMT_OP_SET_APPEARANCE,
@@ -7872,6 +7890,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("Add Advertising - Scan rsp flags 1",
&add_advertising_with_local_name1,
setup_set_local_name,
--
2.7.4


2016-09-19 12:33:34

by Michał Narajowski

[permalink] [raw]
Subject: [PATCH BlueZ 1/2] 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