Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans
cover Added random address in mesh HCI initialization to prevent error 0x12 when enabling/disabling LE scans
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 <[email protected]>
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(+)
Signature · 1 line
2.20.1
PATCH 1/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(+)
mesh/mesh-io-generic.c +9 -0
@@ -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 );
Signature · 1 line
2.20.1
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
Applied with corrections to GIT policy errors
Quoted 38 lines · Daan Pape
--- mesh/mesh-io-generic.c | 9 +++++++++ 1 file changed, 9 insertions(+)mesh/mesh-io-generic.c +9
-0@@ -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 );