linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 3/6] mgmtops: Add timeout to set_discoverable callback
Date: Tue, 28 Feb 2012 13:23:23 +0200	[thread overview]
Message-ID: <1330428206-8185-3-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1330428206-8185-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This set the timeout in the command and let the kernel handle it properly
---
 plugins/mgmtops.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index 95fbe8b..9e8398d 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -215,7 +215,8 @@ static int mgmt_set_connectable(int index, gboolean connectable)
 	return mgmt_set_mode(index, MGMT_OP_SET_CONNECTABLE, connectable);
 }
 
-static int mgmt_set_discoverable(int index, gboolean discoverable)
+static int mgmt_set_discoverable(int index, gboolean discoverable,
+							uint16_t timeout)
 {
 	char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_set_discoverable)];
 	struct mgmt_hdr *hdr = (void *) buf;
@@ -229,6 +230,7 @@ static int mgmt_set_discoverable(int index, gboolean discoverable)
 	hdr->len = htobs(sizeof(*cp));
 
 	cp->val = discoverable;
+	cp->timeout = timeout;
 
 	if (write(mgmt_sock, buf, sizeof(buf)) < 0)
 		return -errno;
@@ -305,16 +307,17 @@ static void update_settings(struct btd_adapter *adapter, uint32_t settings)
 	struct controller_info *info;
 	gboolean pairable;
 	uint8_t on_mode;
-	uint16_t index;
+	uint16_t index, discoverable_timeout;
 
-	btd_adapter_get_mode(adapter, NULL, &on_mode, &pairable);
+	btd_adapter_get_mode(adapter, NULL, &on_mode, &discoverable_timeout,
+								&pairable);
 
 	index = adapter_get_dev_id(adapter);
 
 	info = &controllers[index];
 
 	if (on_mode == MODE_DISCOVERABLE && !mgmt_discoverable(settings))
-		mgmt_set_discoverable(index, TRUE);
+		mgmt_set_discoverable(index, TRUE, discoverable_timeout);
 	else if (on_mode == MODE_CONNECTABLE && !mgmt_connectable(settings))
 		mgmt_set_connectable(index, TRUE);
 	else if (mgmt_powered(settings))
@@ -1021,7 +1024,7 @@ static void read_info_complete(int sk, uint16_t index, void *buf, size_t len)
 
 	adapter_name_changed(adapter, (char *) rp->name);
 
-	btd_adapter_get_mode(adapter, &mode, NULL, NULL);
+	btd_adapter_get_mode(adapter, &mode, NULL, NULL, NULL);
 	if (mode == MODE_OFF && mgmt_powered(info->current_settings)) {
 		mgmt_set_powered(index, FALSE);
 		return;
-- 
1.7.7.6


  parent reply	other threads:[~2012-02-28 11:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-28 11:23 [PATCH BlueZ 1/6] core: Make adapter_ops->set_discoverable to take discoverable timeout Luiz Augusto von Dentz
2012-02-28 11:23 ` [PATCH BlueZ 2/6] hciops: Add discoverable timeout logic Luiz Augusto von Dentz
2012-02-28 11:23 ` Luiz Augusto von Dentz [this message]
2012-02-28 11:23 ` [PATCH BlueZ 4/6] core: remove set_limited_discoverable from adapter_ops driver Luiz Augusto von Dentz
2012-03-01  1:46   ` Johan Hedberg
2012-02-28 11:23 ` [PATCH BlueZ 5/6] hciops: Remove set_limited_discoverable callback Luiz Augusto von Dentz
2012-02-28 11:23 ` [PATCH BlueZ 6/6] mgmtops: " Luiz Augusto von Dentz
2012-03-01  1:43 ` [PATCH BlueZ 1/6] core: Make adapter_ops->set_discoverable to take discoverable timeout 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=1330428206-8185-3-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@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;
as well as URLs for NNTP newsgroup(s).