linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Set appearance only for LE capable controllers
@ 2016-09-19 12:33 Michał Narajowski
  2016-09-19 12:33 ` [PATCH BlueZ 1/2] doc/mgmt-api: Allow set " Michał Narajowski
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Michał Narajowski @ 2016-09-19 12:33 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Michał Narajowski

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

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ 1/2] doc/mgmt-api: Allow set appearance only for LE capable controllers
  2016-09-19 12:33 [PATCH] Bluetooth: Set appearance only for LE capable controllers Michał Narajowski
@ 2016-09-19 12:33 ` Michał Narajowski
  2016-09-21 18:13   ` Szymon Janc
  2016-09-19 12:33 ` [PATCH BlueZ 2/2] tools/mgmt-tester: Test Set Appearance support in different modes Michał Narajowski
  2016-09-19 18:49 ` [PATCH] Bluetooth: Set appearance only for LE capable controllers Johan Hedberg
  2 siblings, 1 reply; 5+ messages in thread
From: Michał Narajowski @ 2016-09-19 12:33 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Michał Narajowski

---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ 2/2] tools/mgmt-tester: Test Set Appearance support in different modes
  2016-09-19 12:33 [PATCH] Bluetooth: Set appearance only for LE capable controllers Michał Narajowski
  2016-09-19 12:33 ` [PATCH BlueZ 1/2] doc/mgmt-api: Allow set " Michał Narajowski
@ 2016-09-19 12:33 ` Michał Narajowski
  2016-09-19 18:49 ` [PATCH] Bluetooth: Set appearance only for LE capable controllers Johan Hedberg
  2 siblings, 0 replies; 5+ messages in thread
From: Michał Narajowski @ 2016-09-19 12:33 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Michał Narajowski

---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Bluetooth: Set appearance only for LE capable controllers
  2016-09-19 12:33 [PATCH] Bluetooth: Set appearance only for LE capable controllers Michał Narajowski
  2016-09-19 12:33 ` [PATCH BlueZ 1/2] doc/mgmt-api: Allow set " Michał Narajowski
  2016-09-19 12:33 ` [PATCH BlueZ 2/2] tools/mgmt-tester: Test Set Appearance support in different modes Michał Narajowski
@ 2016-09-19 18:49 ` Johan Hedberg
  2 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2016-09-19 18:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Michał Narajowski

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 <michal.narajowski@codecoup.pl>
> ---
>  net/bluetooth/mgmt.c | 4 ++++
>  1 file changed, 4 insertions(+)

Applied to bluetooth-next. Thanks.

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH BlueZ 1/2] doc/mgmt-api: Allow set appearance only for LE capable controllers
  2016-09-19 12:33 ` [PATCH BlueZ 1/2] doc/mgmt-api: Allow set " Michał Narajowski
@ 2016-09-21 18:13   ` Szymon Janc
  0 siblings, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2016-09-21 18:13 UTC (permalink / raw)
  To: Michał Narajowski; +Cc: linux-bluetooth

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-21 18:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-19 12:33 [PATCH] Bluetooth: Set appearance only for LE capable controllers Michał Narajowski
2016-09-19 12:33 ` [PATCH BlueZ 1/2] doc/mgmt-api: Allow set " Michał Narajowski
2016-09-21 18:13   ` Szymon Janc
2016-09-19 12:33 ` [PATCH BlueZ 2/2] tools/mgmt-tester: Test Set Appearance support in different modes Michał Narajowski
2016-09-19 18:49 ` [PATCH] Bluetooth: Set appearance only for LE capable controllers Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).