aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_conn.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-07-08 08:07:52 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-07-08 08:22:06 -0400
commit376f54c171674ac1f9a2eefe67d413db4836d25a (patch)
tree746218aeca34afc9ae824ef8f826da7352b7b5e4 /net/bluetooth/hci_conn.c
parent73e082f80d990c017c695a6750f7ac96cdc6308a (diff)
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: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_conn.c')
-rw-r--r--net/bluetooth/hci_conn.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 0db2579ea6c6..1517f1549f85 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -668,9 +668,6 @@ static void hci_req_directed_advertising(struct hci_request *req,
668 u8 own_addr_type; 668 u8 own_addr_type;
669 u8 enable; 669 u8 enable;
670 670
671 enable = 0x00;
672 hci_req_add(req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable), &enable);
673
674 /* Clear the HCI_LE_ADV bit temporarily so that the 671 /* Clear the HCI_LE_ADV bit temporarily so that the
675 * hci_update_random_address knows that it's safe to go ahead 672 * hci_update_random_address knows that it's safe to go ahead
676 * and write a new random address. The flag will be set back on 673 * 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,
761 758
762 hci_req_init(&req, hdev); 759 hci_req_init(&req, hdev);
763 760
761 /* Disable advertising if we're active. For master role
762 * connections most controllers will refuse to connect if
763 * advertising is enabled, and for slave role connections we
764 * anyway have to disable it in order to start directed
765 * advertising.
766 */
767 if (test_bit(HCI_LE_ADV, &hdev->dev_flags)) {
768 u8 enable = 0x00;
769 hci_req_add(&req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(enable),
770 &enable);
771 }
772
764 /* If requested to connect as slave use directed advertising */ 773 /* If requested to connect as slave use directed advertising */
765 if (!master) { 774 if (!master) {
766 hci_req_directed_advertising(&req, conn); 775 hci_req_directed_advertising(&req, conn);