All of lore.kernel.org
 help / color / mirror / Atom feed
From: "João Paulo Rechi Vita" <jprvita@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Cc: Claudio Takahasi <claudio.takahasi@openbossa.org>
Subject: [PATCH BlueZ v5 07/14] mgmt: Add LE scanning callback
Date: Tue,  4 Sep 2012 16:04:35 -0300	[thread overview]
Message-ID: <1346785482-13359-8-git-send-email-jprvita@openbossa.org> (raw)
In-Reply-To: <1346785482-13359-1-git-send-email-jprvita@openbossa.org>

From: Claudio Takahasi <claudio.takahasi@openbossa.org>

This patch adds a new callback to allow the adapter to control LE
scanning. The current approach uses the active scanning with default
windows and intervals defined by the core spec without any filtering.
---
 src/mgmt.c | 34 ++++++++++++++++++++++++++++++++++
 src/mgmt.h |  1 +
 2 files changed, 35 insertions(+)

diff --git a/src/mgmt.c b/src/mgmt.c
index 4643816..8e69778 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -2043,6 +2043,40 @@ int mgmt_start_discovery(int index)
 	return 0;
 }
 
+int mgmt_start_scanning(int index)
+{
+	char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_start_discovery)];
+	struct mgmt_hdr *hdr = (void *) buf;
+	struct mgmt_cp_start_discovery *cp = (void *) &buf[sizeof(*hdr)];
+	struct controller_info *info = &controllers[index];
+
+	DBG("index %d", index);
+
+	if (!mgmt_low_energy(info->current_settings)) {
+		error("scanning failed: Low Energy not enabled/supported");
+		return -ENOTSUP;
+	}
+
+	info->discov_type = 0;
+	hci_set_bit(BDADDR_LE_PUBLIC, &info->discov_type);
+	hci_set_bit(BDADDR_LE_RANDOM, &info->discov_type);
+
+	memset(buf, 0, sizeof(buf));
+	hdr->opcode = htobs(MGMT_OP_START_DISCOVERY);
+	hdr->len = htobs(sizeof(*cp));
+	hdr->index = htobs(index);
+
+	cp->type = info->discov_type;
+
+	if (write(mgmt_sock, buf, sizeof(buf)) < 0) {
+		int err = -errno;
+		error("failed to write to MGMT socket: %s", strerror(-err));
+		return err;
+	}
+
+	return 0;
+}
+
 int mgmt_stop_discovery(int index)
 {
 	char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_start_discovery)];
diff --git a/src/mgmt.h b/src/mgmt.h
index 95245d2..eb7434a 100644
--- a/src/mgmt.h
+++ b/src/mgmt.h
@@ -33,6 +33,7 @@ int mgmt_set_dev_class(int index, uint8_t major, uint8_t minor);
 int mgmt_set_fast_connectable(int index, gboolean enable);
 
 int mgmt_start_discovery(int index);
+int mgmt_start_scanning(int index);
 int mgmt_stop_discovery(int index);
 
 int mgmt_read_clock(int index, bdaddr_t *bdaddr, int which, int timeout,
-- 
1.7.11.4


  parent reply	other threads:[~2012-09-04 19:04 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-04 19:04 [PATCH BlueZ v5 00/14] LE General Connection Establishment procedure João Paulo Rechi Vita
2012-09-04 19:04 ` [PATCH BlueZ v5 01/14] core: Control connections based on adapter state João Paulo Rechi Vita
2012-09-07  9:59   ` Johan Hedberg
2012-09-11 13:34     ` Joao Paulo Rechi Vita
2012-09-04 19:04 ` [PATCH BlueZ v5 02/14] mgmt: Print error message when start_discovery fails João Paulo Rechi Vita
2012-09-04 19:04 ` [PATCH BlueZ v5 03/14] core: Add compare function for bdaddr in a struct btd_device João Paulo Rechi Vita
2012-09-04 19:04 ` [PATCH BlueZ v5 04/14] core: Add a list of LE devices to connect João Paulo Rechi Vita
2012-09-07 10:23   ` Johan Hedberg
2012-09-04 19:04 ` [PATCH BlueZ v5 05/14] core: Use adapter connect list for LE connections João Paulo Rechi Vita
2012-09-04 19:04 ` [PATCH BlueZ v5 06/14] core: Mutually exclude concurrent connections João Paulo Rechi Vita
2012-09-04 19:04 ` João Paulo Rechi Vita [this message]
2012-09-04 19:04 ` [PATCH BlueZ v5 08/14] core: Replace interleaved by LE scanning João Paulo Rechi Vita
2012-09-04 19:04 ` [PATCH BlueZ v5 09/14] core: Start LE scanning when a device requests João Paulo Rechi Vita
2012-09-04 19:04 ` [PATCH BlueZ v5 10/14] core: Queue discovery if scanning is active João Paulo Rechi Vita
2012-09-04 19:04 ` [PATCH BlueZ v5 11/14] core: Disable unnecessary auto connections João Paulo Rechi Vita
2012-09-04 19:04 ` [PATCH BlueZ v5 12/14] core: Re-connect for ECONNRESET or ECONNABORTED João Paulo Rechi Vita
2012-09-04 19:04 ` [PATCH BlueZ v5 13/14] mgmt: Add address type to bonding debug message João Paulo Rechi Vita
2012-09-04 19:04 ` [PATCH BlueZ v5 14/14] core: Suspend scanning before connect on pairing João Paulo Rechi Vita
2012-09-05  5:00 ` [PATCH BlueZ v5 00/14] LE General Connection Establishment procedure Chen Ganir
2012-09-05 17:15   ` Joao Paulo Rechi Vita

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=1346785482-13359-8-git-send-email-jprvita@openbossa.org \
    --to=jprvita@openbossa.org \
    --cc=claudio.takahasi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.