Linux bluetooth development
 help / color / mirror / Atom feed
From: johan.hedberg@gmail.com
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v3 07/13] Bluetooth: Use hci_update_random_address() for enabling advertising
Date: Sun, 23 Feb 2014 19:42:23 +0200	[thread overview]
Message-ID: <1393177349-361-7-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1393177349-361-1-git-send-email-johan.hedberg@gmail.com>

From: Johan Hedberg <johan.hedberg@intel.com>

When we enable advertising we need to update the local random address if
necessary. This patch takes advantage of the hci_update_random_address()
function to set the own_address_type variable and to update the local
random address if necessary.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/mgmt.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 09316dd2cce1..14de8505c054 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -839,13 +839,17 @@ static void enable_advertising(struct hci_request *req)
 {
 	struct hci_dev *hdev = req->hdev;
 	struct hci_cp_le_set_adv_param cp;
-	u8 enable = 0x01;
+	u8 own_addr_type, enable = 0x01;
 
 	memset(&cp, 0, sizeof(cp));
+
+	if (hci_update_random_address(req, &own_addr_type) < 0)
+		return;
+
 	cp.min_interval = __constant_cpu_to_le16(0x0800);
 	cp.max_interval = __constant_cpu_to_le16(0x0800);
 	cp.type = get_adv_type(hdev);
-	cp.own_address_type = hdev->own_addr_type;
+	cp.own_address_type = own_addr_type;
 	cp.channel_map = hdev->le_adv_channel_map;
 
 	hci_req_add(req, HCI_OP_LE_SET_ADV_PARAM, sizeof(cp), &cp);
-- 
1.8.5.3


  parent reply	other threads:[~2014-02-23 17:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-23 17:42 [PATCH v3 01/13] Bluetooth: Ensure hci_conn always contains the local identity address johan.hedberg
2014-02-23 17:42 ` [PATCH v3 02/13] Bluetooth: Set the correct values for Identity Address Information johan.hedberg
2014-02-23 17:42 ` [PATCH v3 03/13] Bluetooth: Add SMP function for generating RPAs johan.hedberg
2014-02-23 17:42 ` [PATCH v3 04/13] Bluetooth: Add timer for regenerating local RPA johan.hedberg
2014-02-23 17:42 ` [PATCH v3 05/13] Bluetooth: Add hci_update_random_address() convenience function johan.hedberg
2014-02-23 17:42 ` [PATCH v3 06/13] Bluetooth: Use hci_update_random_address() when connecting LE johan.hedberg
2014-02-23 17:42 ` johan.hedberg [this message]
2014-02-23 17:42 ` [PATCH v3 08/13] Bluetooth: Use hci_update_random_address() for initiating LE scan johan.hedberg
2014-02-23 17:42 ` [PATCH v3 09/13] Bluetooth: Don't write static address during power on johan.hedberg
2014-02-23 17:42 ` [PATCH v3 10/13] Bluetooth: Add debugfs entry for RPA regeneration timeout johan.hedberg
2014-02-23 17:42 ` [PATCH v3 11/13] Bluetooth: Add support for Set Privacy command johan.hedberg
2014-02-23 17:42 ` [PATCH v3 12/13] Bluetooth: Fix setting correct src_type when connecting LE johan.hedberg
2014-02-23 17:42 ` [PATCH v3 13/13] Bluetooth: Remove unneeded hdev->own_addr_type johan.hedberg
2014-02-23 20:07 ` [PATCH v4] Bluetooth: Ensure hci_conn always contains the local identity address johan.hedberg
2014-02-23 20:44   ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393177349-361-7-git-send-email-johan.hedberg@gmail.com \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox