From: Andre Guedes <andre.guedes@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 1/6] Bluetooth: Discovery parameters per hci_dev
Date: Fri, 9 Aug 2013 20:12:29 -0300 [thread overview]
Message-ID: <1376089954-13639-2-git-send-email-andre.guedes@openbossa.org> (raw)
In-Reply-To: <1376089954-13639-1-git-send-email-andre.guedes@openbossa.org>
This patch adds discovery parameters to struct hci_dev. This way, we
will be able to configure the discovery parameters per hci device.
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
include/net/bluetooth/hci_core.h | 13 +++++++++++++
net/bluetooth/hci_core.c | 13 ++++++++++++-
net/bluetooth/mgmt.c | 15 +++++++++------
3 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index f77885e..0a02fdb 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -127,6 +127,17 @@ struct amp_assoc {
__u8 data[HCI_MAX_AMP_ASSOC_SIZE];
};
+struct discovery_param {
+ u8 scan_type;
+ u16 scan_interval;
+ u16 scan_window;
+ unsigned int interleaved_scan_duration;
+ unsigned int le_scan_duration;
+
+ u8 interleaved_inquiry_length;
+ u8 bredr_inquiry_length;
+};
+
#define HCI_MAX_PAGES 3
#define NUM_REASSEMBLY 4
@@ -280,6 +291,8 @@ struct hci_dev {
__u8 adv_data[HCI_MAX_AD_LENGTH];
__u8 adv_data_len;
+ struct discovery_param discovery_param;
+
int (*open)(struct hci_dev *hdev);
int (*close)(struct hci_dev *hdev);
int (*flush)(struct hci_dev *hdev);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index b821b19..8750663 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2013,6 +2013,7 @@ static void le_scan_disable_work_complete(struct hci_dev *hdev, u8 status)
{
/* General inquiry access code (GIAC) */
u8 lap[3] = { 0x33, 0x8b, 0x9e };
+ struct discovery_param *discov = &hdev->discovery_param;
struct hci_request req;
struct hci_cp_inquiry cp;
int err;
@@ -2034,7 +2035,7 @@ static void le_scan_disable_work_complete(struct hci_dev *hdev, u8 status)
memset(&cp, 0, sizeof(cp));
memcpy(&cp.lap, lap, sizeof(cp.lap));
- cp.length = DISCOV_INTERLEAVED_INQUIRY_LEN;
+ cp.length = discov->interleaved_inquiry_length;
hci_req_add(&req, HCI_OP_INQUIRY, sizeof(cp), &cp);
hci_dev_lock(hdev);
@@ -2077,6 +2078,7 @@ static void le_scan_disable_work(struct work_struct *work)
struct hci_dev *hci_alloc_dev(void)
{
struct hci_dev *hdev;
+ struct discovery_param *discov;
hdev = kzalloc(sizeof(struct hci_dev), GFP_KERNEL);
if (!hdev)
@@ -2123,6 +2125,15 @@ struct hci_dev *hci_alloc_dev(void)
hci_init_sysfs(hdev);
discovery_init(hdev);
+ discov = &hdev->discovery_param;
+ discov->scan_type = LE_SCAN_ACTIVE;
+ discov->scan_interval = DISCOV_LE_SCAN_INT;
+ discov->scan_window = DISCOV_LE_SCAN_WIN;
+ discov->le_scan_duration = DISCOV_LE_TIMEOUT;
+ discov->interleaved_scan_duration = DISCOV_INTERLEAVED_TIMEOUT;
+ discov->interleaved_inquiry_length = DISCOV_INTERLEAVED_INQUIRY_LEN;
+ discov->bredr_inquiry_length = DISCOV_BREDR_INQUIRY_LEN;
+
return hdev;
}
EXPORT_SYMBOL(hci_alloc_dev);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index fedc539..2b4a3ba 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2642,6 +2642,8 @@ static int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status)
static void start_discovery_complete(struct hci_dev *hdev, u8 status)
{
+ struct discovery_param *discov = &hdev->discovery_param;
+
BT_DBG("status %d", status);
if (status) {
@@ -2658,12 +2660,12 @@ static void start_discovery_complete(struct hci_dev *hdev, u8 status)
switch (hdev->discovery.type) {
case DISCOV_TYPE_LE:
queue_delayed_work(hdev->workqueue, &hdev->le_scan_disable,
- DISCOV_LE_TIMEOUT);
+ discov->le_scan_duration);
break;
case DISCOV_TYPE_INTERLEAVED:
queue_delayed_work(hdev->workqueue, &hdev->le_scan_disable,
- DISCOV_INTERLEAVED_TIMEOUT);
+ discov->interleaved_scan_duration);
break;
case DISCOV_TYPE_BREDR:
@@ -2678,6 +2680,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
void *data, u16 len)
{
struct mgmt_cp_start_discovery *cp = data;
+ struct discovery_param *discov = &hdev->discovery_param;
struct pending_cmd *cmd;
struct hci_cp_le_set_scan_param param_cp;
struct hci_cp_le_set_scan_enable enable_cp;
@@ -2739,7 +2742,7 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
memset(&inq_cp, 0, sizeof(inq_cp));
memcpy(&inq_cp.lap, lap, sizeof(inq_cp.lap));
- inq_cp.length = DISCOV_BREDR_INQUIRY_LEN;
+ inq_cp.length = discov->bredr_inquiry_length;
hci_req_add(&req, HCI_OP_INQUIRY, sizeof(inq_cp), &inq_cp);
break;
@@ -2775,9 +2778,9 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
}
memset(¶m_cp, 0, sizeof(param_cp));
- param_cp.type = LE_SCAN_ACTIVE;
- param_cp.interval = cpu_to_le16(DISCOV_LE_SCAN_INT);
- param_cp.window = cpu_to_le16(DISCOV_LE_SCAN_WIN);
+ param_cp.type = discov->scan_type;
+ param_cp.interval = cpu_to_le16(discov->scan_interval);
+ param_cp.window = cpu_to_le16(discov->scan_window);
hci_req_add(&req, HCI_OP_LE_SET_SCAN_PARAM, sizeof(param_cp),
¶m_cp);
--
1.8.3.4
next prev parent reply other threads:[~2013-08-09 23:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-09 23:12 [PATCH 0/6] LE parameters via debugfs Andre Guedes
2013-08-09 23:12 ` Andre Guedes [this message]
2013-08-09 23:12 ` [PATCH 2/6] Bluetooth: Export discovery parameters on debugfs Andre Guedes
2013-08-09 23:12 ` [PATCH 3/6] Bluetooth: Set discovery parameters Andre Guedes
2013-08-10 16:09 ` Marcel Holtmann
2013-08-21 20:41 ` Andre Guedes
2013-08-21 22:56 ` Marcel Holtmann
2013-08-22 20:01 ` Andre Guedes
2013-08-09 23:12 ` [PATCH 4/6] Bluetooth: Keep the LE connection parameters in its own structure Andre Guedes
2013-08-09 23:12 ` [PATCH 5/6] Bluetooth: Add LE connection parameters to debugfs Andre Guedes
2013-08-10 16:10 ` Marcel Holtmann
2013-08-21 20:41 ` Andre Guedes
2013-08-09 23:12 ` [PATCH 6/6] Bluetooth: Add support for setting LE connection parameters via debugfs Andre Guedes
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=1376089954-13639-2-git-send-email-andre.guedes@openbossa.org \
--to=andre.guedes@openbossa.org \
--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