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

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

Bluetooth: Stop advertising always before initiating a connection



Most controllers do not support advertising while initiating an LE
connection. We also have to first disable current advertising if the
initiation is going to happen through direct advertising. Therefore,
simply stop advertising as the first thing when starting to issue
commands to establish an LE connection.

Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 73e082f8
Loading
Loading
Loading
Loading
+12 −3
Original line number Original line Diff line number Diff line
@@ -668,9 +668,6 @@ static void hci_req_directed_advertising(struct hci_request *req,
	u8 own_addr_type;
	u8 own_addr_type;
	u8 enable;
	u8 enable;


	enable = 0x00;
	hci_req_add(req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), &enable);

	/* Clear the HCI_LE_ADV bit temporarily so that the
	/* Clear the HCI_LE_ADV bit temporarily so that the
	 * hci_update_random_address knows that it's safe to go ahead
	 * hci_update_random_address knows that it's safe to go ahead
	 * and write a new random address. The flag will be set back on
	 * and write a new random address. The flag will be set back on
@@ -761,6 +758,18 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,


	hci_req_init(&req, hdev);
	hci_req_init(&req, hdev);


	/* Disable advertising if we're active. For master role
	 * connections most controllers will refuse to connect if
	 * advertising is enabled, and for slave role connections we
	 * anyway have to disable it in order to start directed
	 * advertising.
	 */
	if (test_bit(HCI_LE_ADV, &hdev->dev_flags)) {
		u8 enable = 0x00;
		hci_req_add(&req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable),
			    &enable);
	}

	/* If requested to connect as slave use directed advertising */
	/* If requested to connect as slave use directed advertising */
	if (!master) {
	if (!master) {
		hci_req_directed_advertising(&req, conn);
		hci_req_directed_advertising(&req, conn);