Skip to content

Commit e411443

Browse files
committed
Bluetooth: hci_sync: Fix not setting static address
This attempts to program the address stored in hdev->static_addr after the init sequence has been complete: @ MGMT Command: Set Static A.. (0x002b) plen 6 Address: C0:55:44:33:22:11 (Static) @ MGMT Event: Command Complete (0x0001) plen 7 Set Static Address (0x002b) plen 4 Status: Success (0x00) Current settings: 0x00008200 Low Energy Static Address @ MGMT Event: New Settings (0x0006) plen 4 Current settings: 0x00008200 Low Energy Static Address < HCI Command: LE Set Random.. (0x08|0x0005) plen 6 Address: C0:55:44:33:22:11 (Static) > HCI Event: Command Complete (0x0e) plen 4 LE Set Random Address (0x08|0x0005) ncmd 1 Status: Success (0x00) @ MGMT Event: Command Complete (0x0001) plen 7 Set Powered (0x0005) plen 4 Status: Success (0x00) Current settings: 0x00008201 Powered Low Energy Static Address @ MGMT Event: New Settings (0x0006) plen 4 Current settings: 0x00008201 Powered Low Energy Static Address Signed-off-by: Luiz Augusto von Dentz <[email protected]> Tested-by: Brian Gix <[email protected]>
1 parent b3fdb8c commit e411443

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

net/bluetooth/hci_sync.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,6 +3055,7 @@ int hci_update_name_sync(struct hci_dev *hdev)
30553055
* Enable Authentication
30563056
* lmp_bredr_capable(Set Fast Connectable -> Set Scan Type -> Set Class ->
30573057
* Set Name -> Set EIR)
3058+
* HCI_FORCE_STATIC_ADDR | BDADDR_ANY && !HCI_BREDR_ENABLED (Set Static Address)
30583059
*/
30593060
int hci_powered_update_sync(struct hci_dev *hdev)
30603061
{
@@ -3094,6 +3095,23 @@ int hci_powered_update_sync(struct hci_dev *hdev)
30943095
hci_update_eir_sync(hdev);
30953096
}
30963097

3098+
/* If forcing static address is in use or there is no public
3099+
* address use the static address as random address (but skip
3100+
* the HCI command if the current random address is already the
3101+
* static one.
3102+
*
3103+
* In case BR/EDR has been disabled on a dual-mode controller
3104+
* and a static address has been configured, then use that
3105+
* address instead of the public BR/EDR address.
3106+
*/
3107+
if (hci_dev_test_flag(hdev, HCI_FORCE_STATIC_ADDR) ||
3108+
(!bacmp(&hdev->bdaddr, BDADDR_ANY) &&
3109+
!hci_dev_test_flag(hdev, HCI_BREDR_ENABLED))) {
3110+
if (bacmp(&hdev->static_addr, BDADDR_ANY))
3111+
return hci_set_random_addr_sync(hdev,
3112+
&hdev->static_addr);
3113+
}
3114+
30973115
return 0;
30983116
}
30993117

0 commit comments

Comments
 (0)