From: johan.hedberg@gmail.com
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 7/8] Bluetooth: Add new mgmt setting for LE advertising
Date: Tue, 24 Sep 2013 17:02:42 +0300 [thread overview]
Message-ID: <1380031363-1266-8-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1380031363-1266-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
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>
---
include/net/bluetooth/mgmt.h | 1 +
net/bluetooth/mgmt.c | 24 +++++++++++++++++++++++-
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 9944c3e..6cc72b6 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -93,6 +93,7 @@ struct mgmt_rp_read_index_list {
#define MGMT_SETTING_BREDR 0x00000080
#define MGMT_SETTING_HS 0x00000100
#define MGMT_SETTING_LE 0x00000200
+#define MGMT_SETTING_ADVERTISING 0x00000400
#define MGMT_OP_READ_INFO 0x0004
#define MGMT_READ_INFO_SIZE 0
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index e595b59..d11899d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -384,8 +384,10 @@ static u32 get_supported_settings(struct hci_dev *hdev)
if (enable_hs)
settings |= MGMT_SETTING_HS;
- if (lmp_le_capable(hdev))
+ if (lmp_le_capable(hdev)) {
settings |= MGMT_SETTING_LE;
+ settings |= MGMT_SETTING_ADVERTISING;
+ }
return settings;
}
@@ -424,6 +426,9 @@ static u32 get_current_settings(struct hci_dev *hdev)
if (test_bit(HCI_HS_ENABLED, &hdev->dev_flags))
settings |= MGMT_SETTING_HS;
+ if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags))
+ settings |= MGMT_SETTING_ADVERTISING;
+
return settings;
}
@@ -1368,6 +1373,9 @@ static void le_enable_complete(struct hci_dev *hdev, u8 status)
change_bit(HCI_LE_ENABLED, &hdev->dev_flags);
+ if (!test_bit(HCI_LE_ENABLED, &hdev->dev_flags))
+ clear_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags);
+
mgmt_pending_foreach(MGMT_OP_SET_LE, hdev, settings_rsp, &match);
new_settings(hdev, match.sk);
@@ -1413,6 +1421,11 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
changed = true;
}
+ if (!val && test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags)) {
+ clear_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags);
+ changed = true;
+ }
+
err = send_settings_rsp(sk, MGMT_OP_SET_LE, hdev);
if (err < 0)
goto unlock;
@@ -1444,6 +1457,9 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
hci_req_init(&req, hdev);
+ if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags) && !val)
+ hci_req_add(&req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(val), &val);
+
hci_req_add(&req, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(hci_cp),
&hci_cp);
@@ -3519,6 +3535,12 @@ static int powered_update_hci(struct hci_dev *hdev)
sizeof(cp), &cp);
}
+ if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags)) {
+ u8 adv = 0x01;
+
+ hci_req_add(&req, HCI_OP_LE_SET_ADV_ENABLE, sizeof(adv), &adv);
+ }
+
link_sec = test_bit(HCI_LINK_SECURITY, &hdev->dev_flags);
if (link_sec != test_bit(HCI_AUTH, &hdev->flags))
hci_req_add(&req, HCI_OP_WRITE_AUTH_ENABLE,
--
1.8.4.rc3
next prev parent reply other threads:[~2013-09-24 14:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-24 14:02 [PATCH 0/8] Bluetooth: Cleanups and LE advertising support johan.hedberg
2013-09-24 14:02 ` [PATCH 1/8] Bluetooth: Add clarifying comment to bt_sock_wait_state() johan.hedberg
2013-09-24 18:11 ` Marcel Holtmann
2013-09-24 14:02 ` [PATCH 2/8] Bluetooth: Clean up socket locking in l2cap_sock_recvmsg johan.hedberg
2013-09-24 18:16 ` Marcel Holtmann
2013-09-24 14:02 ` [PATCH 3/8] Bluetooth: Test for HCI_SETUP and HCI_USER_CHANNEL in mgmt_valid_hdev() johan.hedberg
2013-09-24 18:19 ` Marcel Holtmann
2013-09-25 10:03 ` Johan Hedberg
2013-09-27 2:12 ` Marcel Holtmann
2013-09-27 11:45 ` Johan Hedberg
2013-09-28 8:06 ` Marcel Holtmann
2013-09-28 15:34 ` Johan Hedberg
2013-09-24 14:02 ` [PATCH 4/8] Bluetooth: Fix busy return for mgmt_set_powered in some cases johan.hedberg
2013-09-24 18:17 ` Marcel Holtmann
2013-09-24 14:02 ` [PATCH 5/8] Bluetooth: Move mgmt response convenience functions to a better location johan.hedberg
2013-09-24 18:11 ` Marcel Holtmann
2013-09-24 14:02 ` [PATCH 6/8] Bluetooth: Use async request for LE enable/disable johan.hedberg
2013-09-24 18:20 ` Marcel Holtmann
2013-09-24 14:02 ` johan.hedberg [this message]
2013-09-24 15:45 ` [PATCH 7/8] Bluetooth: Add new mgmt setting for LE advertising Anderson Lizardo
2013-09-24 17:21 ` Johan Hedberg
2013-09-25 10:28 ` Johan Hedberg
2013-09-24 18:29 ` Marcel Holtmann
2013-09-24 14:02 ` [PATCH 8/8] Bluetooth: Add new mgmt_set_advertising command johan.hedberg
2013-09-24 15:42 ` Johan Hedberg
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=1380031363-1266-8-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