diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2013-09-25 06:26:09 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2013-09-25 13:30:11 -0400 |
commit | eeca6f891305a80378da978f803821c2a0b648b6 (patch) | |
tree | 0961704b5808456a824ccab2eabee73c4ead9bdd | |
parent | 416a4ae56b7a37407ca1155805c05b638f845778 (diff) |
Bluetooth: Add new mgmt setting for LE advertising
This patch adds a new mgmt setting for LE advertising and hooks up the
necessary places in the mgmt code to operate on the HCI_LE_PERIPHERAL
flag (which corresponds to this setting). This patch does not yet add
any new command for enabling the setting - that is left for a subsequent
patch.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
-rw-r--r-- | include/net/bluetooth/mgmt.h | 1 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 1 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 21 |
3 files changed, 22 insertions, 1 deletions
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 9944c3e68c5d..6cc72b69e014 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h | |||
@@ -93,6 +93,7 @@ struct mgmt_rp_read_index_list { | |||
93 | #define MGMT_SETTING_BREDR 0x00000080 | 93 | #define MGMT_SETTING_BREDR 0x00000080 |
94 | #define MGMT_SETTING_HS 0x00000100 | 94 | #define MGMT_SETTING_HS 0x00000100 |
95 | #define MGMT_SETTING_LE 0x00000200 | 95 | #define MGMT_SETTING_LE 0x00000200 |
96 | #define MGMT_SETTING_ADVERTISING 0x00000400 | ||
96 | 97 | ||
97 | #define MGMT_OP_READ_INFO 0x0004 | 98 | #define MGMT_OP_READ_INFO 0x0004 |
98 | #define MGMT_READ_INFO_SIZE 0 | 99 | #define MGMT_READ_INFO_SIZE 0 |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 48db81f8a337..917c7c833f69 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1000,6 +1000,7 @@ static void hci_cc_write_le_host_supported(struct hci_dev *hdev, | |||
1000 | } else { | 1000 | } else { |
1001 | hdev->features[1][0] &= ~LMP_HOST_LE; | 1001 | hdev->features[1][0] &= ~LMP_HOST_LE; |
1002 | clear_bit(HCI_LE_ENABLED, &hdev->dev_flags); | 1002 | clear_bit(HCI_LE_ENABLED, &hdev->dev_flags); |
1003 | clear_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags); | ||
1003 | } | 1004 | } |
1004 | 1005 | ||
1005 | if (sent->simul) | 1006 | if (sent->simul) |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 4c3984ee1114..9a2faa310b7c 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -384,8 +384,10 @@ static u32 get_supported_settings(struct hci_dev *hdev) | |||
384 | if (enable_hs) | 384 | if (enable_hs) |
385 | settings |= MGMT_SETTING_HS; | 385 | settings |= MGMT_SETTING_HS; |
386 | 386 | ||
387 | if (lmp_le_capable(hdev)) | 387 | if (lmp_le_capable(hdev)) { |
388 | settings |= MGMT_SETTING_LE; | 388 | settings |= MGMT_SETTING_LE; |
389 | settings |= MGMT_SETTING_ADVERTISING; | ||
390 | } | ||
389 | 391 | ||
390 | return settings; | 392 | return settings; |
391 | } | 393 | } |
@@ -424,6 +426,9 @@ static u32 get_current_settings(struct hci_dev *hdev) | |||
424 | if (test_bit(HCI_HS_ENABLED, &hdev->dev_flags)) | 426 | if (test_bit(HCI_HS_ENABLED, &hdev->dev_flags)) |
425 | settings |= MGMT_SETTING_HS; | 427 | settings |= MGMT_SETTING_HS; |
426 | 428 | ||
429 | if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags)) | ||
430 | settings |= MGMT_SETTING_ADVERTISING; | ||
431 | |||
427 | return settings; | 432 | return settings; |
428 | } | 433 | } |
429 | 434 | ||
@@ -1411,6 +1416,11 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
1411 | changed = true; | 1416 | changed = true; |
1412 | } | 1417 | } |
1413 | 1418 | ||
1419 | if (!val && test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags)) { | ||
1420 | clear_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags); | ||
1421 | changed = true; | ||
1422 | } | ||
1423 | |||
1414 | err = send_settings_rsp(sk, MGMT_OP_SET_LE, hdev); | 1424 | err = send_settings_rsp(sk, MGMT_OP_SET_LE, hdev); |
1415 | if (err < 0) | 1425 | if (err < 0) |
1416 | goto unlock; | 1426 | goto unlock; |
@@ -1442,6 +1452,9 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) | |||
1442 | 1452 | ||
1443 | hci_req_init(&req, hdev); | 1453 | hci_req_init(&req, hdev); |
1444 | 1454 | ||
1455 | if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags) && !val) | ||
1456 | hci_req_add(&req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(val), &val); | ||
1457 | |||
1445 | hci_req_add(&req, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(hci_cp), | 1458 | hci_req_add(&req, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(hci_cp), |
1446 | &hci_cp); | 1459 | &hci_cp); |
1447 | 1460 | ||
@@ -3517,6 +3530,12 @@ static int powered_update_hci(struct hci_dev *hdev) | |||
3517 | sizeof(cp), &cp); | 3530 | sizeof(cp), &cp); |
3518 | } | 3531 | } |
3519 | 3532 | ||
3533 | if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags)) { | ||
3534 | u8 adv = 0x01; | ||
3535 | |||
3536 | hci_req_add(&req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(adv), &adv); | ||
3537 | } | ||
3538 | |||
3520 | link_sec = test_bit(HCI_LINK_SECURITY, &hdev->dev_flags); | 3539 | link_sec = test_bit(HCI_LINK_SECURITY, &hdev->dev_flags); |
3521 | if (link_sec != test_bit(HCI_AUTH, &hdev->flags)) | 3540 | if (link_sec != test_bit(HCI_AUTH, &hdev->flags)) |
3522 | hci_req_add(&req, HCI_OP_WRITE_AUTH_ENABLE, | 3541 | hci_req_add(&req, HCI_OP_WRITE_AUTH_ENABLE, |