Commit f14d8f64 authored by Marcel Holtmann's avatar Marcel Holtmann Committed by Johan Hedberg

Bluetooth: Set the scan response data when needed

On controller power on and when enabling LE functionality,
make sure that also the scan response data is correctly set.
Signed-off-by: default avatarMarcel Holtmann <>
Signed-off-by: default avatarJohan Hedberg <>
parent f8e808bd
......@@ -1094,6 +1094,12 @@ struct hci_cp_le_set_adv_data {
__u8 data[HCI_MAX_AD_LENGTH];
} __packed;
#define HCI_OP_LE_SET_SCAN_RSP_DATA 0x2009
struct hci_cp_le_set_scan_rsp_data {
__u8 length;
__u8 data[HCI_MAX_AD_LENGTH];
} __packed;
#define HCI_OP_LE_SET_ADV_ENABLE 0x200a
#define LE_SCAN_PASSIVE 0x00
......@@ -536,6 +536,36 @@ static u8 *create_uuid128_list(struct hci_dev *hdev, u8 *data, ptrdiff_t len)
return ptr;
static u8 create_scan_rsp_data(struct hci_dev *hdev, u8 *ptr)
return 0;
static void update_scan_rsp_data(struct hci_request *req)
struct hci_dev *hdev = req->hdev;
struct hci_cp_le_set_scan_rsp_data cp;
u8 len;
if (!lmp_le_capable(hdev))
memset(&cp, 0, sizeof(cp));
len = create_scan_rsp_data(hdev,;
if (hdev->adv_data_len == len &&
memcmp(, hdev->adv_data, len) == 0)
memcpy(hdev->adv_data,, sizeof(;
hdev->adv_data_len = len;
cp.length = len;
hci_req_add(req, HCI_OP_LE_SET_SCAN_RSP_DATA, sizeof(cp), &cp);
static u8 create_adv_data(struct hci_dev *hdev, u8 *ptr)
u8 ad_len = 0, flags = 0;
......@@ -1715,6 +1745,7 @@ static void le_enable_complete(struct hci_dev *hdev, u8 status)
hci_req_init(&req, hdev);
hci_req_run(&req, NULL);
......@@ -3898,6 +3929,9 @@ static int set_bredr(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags))
/* Since only the advertising data flags will change, there
* is no need to update the scan response data.
err = hci_req_run(&req, set_bredr_complete);
......@@ -4211,8 +4245,10 @@ static int powered_update_hci(struct hci_dev *hdev)
* advertising data. This also applies to the case
* where BR/EDR was toggled during the AUTO_OFF phase.
if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) {
if (test_bit(HCI_ADVERTISING, &hdev->dev_flags))
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