linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 0/1] Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans
@ 2020-08-19  8:28 Daan Pape
  2020-08-19  8:28 ` [PATCH BlueZ 1/1] " Daan Pape
  0 siblings, 1 reply; 4+ messages in thread
From: Daan Pape @ 2020-08-19  8:28 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Daan Pape

I had compiled bluez for OpenWRT and was running the bluetooth-meshd
daemon with a Fanstel BT680T module which implement the Bluetooth 5.0
core specification.

The daemon did not properly start and failed with error:

LE Scan enable failed (0x12)

This error is described on page 2496 of the Bluetooth Core Specification
Version 5.2 and is caused by the fact that no random address was
initialized. After the valuable input of Brian Gix on my first patch, I
have now prepared this patch.

I have now added a random address intialization after the HCI was reset
in the configure_hci function. The HCI layer is now correctly initialized
and no 0x12 errors are thrown.

This is the first time that I contribute to Bluez so please forgive me
if I made any styling mistake in the patch format. I also did not include
my details in the 'AUTHORS' file just yet as I first wanted to wait
for your reaction. In case the patch is accepted my name can be added
to the 'AUTHORS' file as:

Daan Pape <daan@dptechnics.com>

Please do not hesitate to ask any further questions if neccesary.

Kind regards,
Daan Pape

Daan Pape (1):
  Added random address in mesh HCI initialization to prevent error 0x12
    when enabling/disabling LE scans

 mesh/mesh-io-generic.c | 9 +++++++++
 1 file changed, 9 insertions(+)

-- 
2.20.1



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

* [PATCH BlueZ 1/1] Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans
  2020-08-19  8:28 [PATCH BlueZ 0/1] Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans Daan Pape
@ 2020-08-19  8:28 ` Daan Pape
  2020-08-19  8:50   ` [BlueZ,1/1] " bluez.test.bot
  2020-08-22 14:27   ` [PATCH BlueZ 1/1] " Gix, Brian
  0 siblings, 2 replies; 4+ messages in thread
From: Daan Pape @ 2020-08-19  8:28 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Daan Pape

---
 mesh/mesh-io-generic.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c
index 67b13a1b9..67304d201 100644
--- a/mesh/mesh-io-generic.c
+++ b/mesh/mesh-io-generic.c
@@ -209,6 +209,7 @@ static void configure_hci(struct mesh_io_private *io)
 	struct bt_hci_cmd_le_set_scan_parameters cmd;
 	struct bt_hci_cmd_set_event_mask cmd_sem;
 	struct bt_hci_cmd_le_set_event_mask cmd_slem;
+	struct bt_hci_cmd_le_set_random_address cmd_raddr;
 
 	/* Set scan parameters */
 	cmd.type = 0x00; /* Passive Scanning. No scanning PDUs shall be sent */
@@ -261,6 +262,10 @@ static void configure_hci(struct mesh_io_private *io)
 	cmd_slem.mask[6] = 0x00;
 	cmd_slem.mask[7] = 0x00;
 
+	/* Set LE random address */
+	l_getrandom(cmd_raddr.addr, 6);
+	cmd_raddr.addr[5] |= 0xc0;
+
 	/* TODO: Move to suitable place. Set suitable masks */
 	/* Reset Command */
 	bt_hci_send(io->hci, BT_HCI_CMD_RESET, NULL, 0, hci_generic_callback,
@@ -282,6 +287,10 @@ static void configure_hci(struct mesh_io_private *io)
 	bt_hci_send(io->hci, BT_HCI_CMD_LE_SET_EVENT_MASK, &cmd_slem,
 			sizeof(cmd_slem), hci_generic_callback, NULL, NULL);
 
+	/* Set LE random address */
+	bt_hci_send(io->hci, BT_HCI_CMD_LE_SET_RANDOM_ADDRESS, &cmd_raddr,
+			sizeof(cmd_raddr), hci_generic_callback, NULL, NULL);
+
 	/* Scan Params */
 	bt_hci_send(io->hci, BT_HCI_CMD_LE_SET_SCAN_PARAMETERS, &cmd,
 				sizeof(cmd), hci_generic_callback, NULL, NULL);
-- 
2.20.1



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

* RE: [BlueZ,1/1] Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans
  2020-08-19  8:28 ` [PATCH BlueZ 1/1] " Daan Pape
@ 2020-08-19  8:50   ` bluez.test.bot
  2020-08-22 14:27   ` [PATCH BlueZ 1/1] " Gix, Brian
  1 sibling, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2020-08-19  8:50 UTC (permalink / raw)
  To: linux-bluetooth, daan

[-- Attachment #1: Type: text/plain, Size: 496 bytes --]


This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While we are preparing for reviewing the patches, we found the following
issue/warning.

Test Result:
checkgitlint Failed

Outputs:
1: T1 Title exceeds max length (102>72): "Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans"
3: B6 Body message is missing



---
Regards,
Linux Bluetooth

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

* Re: [PATCH BlueZ 1/1] Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans
  2020-08-19  8:28 ` [PATCH BlueZ 1/1] " Daan Pape
  2020-08-19  8:50   ` [BlueZ,1/1] " bluez.test.bot
@ 2020-08-22 14:27   ` Gix, Brian
  1 sibling, 0 replies; 4+ messages in thread
From: Gix, Brian @ 2020-08-22 14:27 UTC (permalink / raw)
  To: daan@dptechnics.com, linux-bluetooth@vger.kernel.org

Applied with corrections to GIT policy errors
On Wed, 2020-08-19 at 10:28 +0200, Daan Pape wrote:
> ---
>  mesh/mesh-io-generic.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/mesh/mesh-io-generic.c b/mesh/mesh-io-generic.c
> index 67b13a1b9..67304d201 100644
> --- a/mesh/mesh-io-generic.c
> +++ b/mesh/mesh-io-generic.c
> @@ -209,6 +209,7 @@ static void configure_hci(struct mesh_io_private *io)
>  	struct bt_hci_cmd_le_set_scan_parameters cmd;
>  	struct bt_hci_cmd_set_event_mask cmd_sem;
>  	struct bt_hci_cmd_le_set_event_mask cmd_slem;
> +	struct bt_hci_cmd_le_set_random_address cmd_raddr;
>  
>  	/* Set scan parameters */
>  	cmd.type = 0x00; /* Passive Scanning. No scanning PDUs shall be sent */
> @@ -261,6 +262,10 @@ static void configure_hci(struct mesh_io_private *io)
>  	cmd_slem.mask[6] = 0x00;
>  	cmd_slem.mask[7] = 0x00;
>  
> +	/* Set LE random address */
> +	l_getrandom(cmd_raddr.addr, 6);
> +	cmd_raddr.addr[5] |= 0xc0;
> +
>  	/* TODO: Move to suitable place. Set suitable masks */
>  	/* Reset Command */
>  	bt_hci_send(io->hci, BT_HCI_CMD_RESET, NULL, 0, hci_generic_callback,
> @@ -282,6 +287,10 @@ static void configure_hci(struct mesh_io_private *io)
>  	bt_hci_send(io->hci, BT_HCI_CMD_LE_SET_EVENT_MASK, &cmd_slem,
>  			sizeof(cmd_slem), hci_generic_callback, NULL, NULL);
>  
> +	/* Set LE random address */
> +	bt_hci_send(io->hci, BT_HCI_CMD_LE_SET_RANDOM_ADDRESS, &cmd_raddr,
> +			sizeof(cmd_raddr), hci_generic_callback, NULL, NULL);
> +
>  	/* Scan Params */
>  	bt_hci_send(io->hci, BT_HCI_CMD_LE_SET_SCAN_PARAMETERS, &cmd,
>  				sizeof(cmd), hci_generic_callback, NULL, NULL);

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

end of thread, other threads:[~2020-08-22 14:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-19  8:28 [PATCH BlueZ 0/1] Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans Daan Pape
2020-08-19  8:28 ` [PATCH BlueZ 1/1] " Daan Pape
2020-08-19  8:50   ` [BlueZ,1/1] " bluez.test.bot
2020-08-22 14:27   ` [PATCH BlueZ 1/1] " Gix, Brian

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