Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c25dfc61 authored by Marcel Holtmann's avatar Marcel Holtmann Committed by Johan Hedberg
Browse files

Bluetooth: Use random address if public address is not available



For single mode LE-only controllers, it is possible that they come
without a public address. If a public address is not available,
then use the random address for connection establishment and
scanning.

Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent e8803534
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -59,6 +59,10 @@ static void hci_le_create_connection(struct hci_conn *conn)
	cp.scan_window = __constant_cpu_to_le16(0x0030);
	cp.scan_window = __constant_cpu_to_le16(0x0030);
	bacpy(&cp.peer_addr, &conn->dst);
	bacpy(&cp.peer_addr, &conn->dst);
	cp.peer_addr_type = conn->dst_type;
	cp.peer_addr_type = conn->dst_type;
	if (bacmp(&hdev->bdaddr, BDADDR_ANY))
		cp.own_address_type = ADDR_LE_DEV_PUBLIC;
	else
		cp.own_address_type = ADDR_LE_DEV_RANDOM;
	cp.conn_interval_min = __constant_cpu_to_le16(0x0028);
	cp.conn_interval_min = __constant_cpu_to_le16(0x0028);
	cp.conn_interval_max = __constant_cpu_to_le16(0x0038);
	cp.conn_interval_max = __constant_cpu_to_le16(0x0038);
	cp.supervision_timeout = __constant_cpu_to_le16(0x002a);
	cp.supervision_timeout = __constant_cpu_to_le16(0x002a);
+4 −0
Original line number Original line Diff line number Diff line
@@ -2911,6 +2911,10 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
		param_cp.type = LE_SCAN_ACTIVE;
		param_cp.type = LE_SCAN_ACTIVE;
		param_cp.interval = cpu_to_le16(DISCOV_LE_SCAN_INT);
		param_cp.interval = cpu_to_le16(DISCOV_LE_SCAN_INT);
		param_cp.window = cpu_to_le16(DISCOV_LE_SCAN_WIN);
		param_cp.window = cpu_to_le16(DISCOV_LE_SCAN_WIN);
		if (bacmp(&hdev->bdaddr, BDADDR_ANY))
			param_cp.own_address_type = ADDR_LE_DEV_PUBLIC;
		else
			param_cp.own_address_type = ADDR_LE_DEV_RANDOM;
		hci_req_add(&req, HCI_OP_LE_SET_SCAN_PARAM, sizeof(param_cp),
		hci_req_add(&req, HCI_OP_LE_SET_SCAN_PARAM, sizeof(param_cp),
			    &param_cp);
			    &param_cp);