Commit 8f2a0601 authored by Johan Hedberg's avatar Johan Hedberg Committed by Marcel Holtmann

Bluetooth: Use hci_update_random_address() for enabling advertising

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: default avatarJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 85030be4
...@@ -839,13 +839,17 @@ static void enable_advertising(struct hci_request *req) ...@@ -839,13 +839,17 @@ static void enable_advertising(struct hci_request *req)
{ {
struct hci_dev *hdev = req->hdev; struct hci_dev *hdev = req->hdev;
struct hci_cp_le_set_adv_param cp; struct hci_cp_le_set_adv_param cp;
u8 enable = 0x01; u8 own_addr_type, enable = 0x01;
memset(&cp, 0, sizeof(cp)); 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.min_interval = __constant_cpu_to_le16(0x0800);
cp.max_interval = __constant_cpu_to_le16(0x0800); cp.max_interval = __constant_cpu_to_le16(0x0800);
cp.type = get_adv_type(hdev); 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; cp.channel_map = hdev->le_adv_channel_map;
hci_req_add(req, HCI_OP_LE_SET_ADV_PARAM, sizeof(cp), &cp); hci_req_add(req, HCI_OP_LE_SET_ADV_PARAM, sizeof(cp), &cp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment