linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Implement fast connectable mode for mgmt interface
@ 2011-06-16 11:55 Antti Julku
  2011-06-16 18:57 ` Johan Hedberg
  0 siblings, 1 reply; 5+ messages in thread
From: Antti Julku @ 2011-06-16 11:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Antti Julku

Management interface implementation for fast connectable mode.
---
 doc/mgmt-api.txt  |    8 ++++++++
 lib/mgmt.h        |    5 +++++
 plugins/mgmtops.c |   24 +++++++++++++++++++++---
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 353705e..b3863e6 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -319,6 +319,14 @@ Stop Discovery Command
 	Command Parameters:
 	Return Parameters:
 
+Set Fast Connectable Command
+============================
+
+        Command Code:           0x0001F
+        Controller Index:       <controller id>
+        Command Parameters:     Enable (1 Octet)
+        Return Parameters:      Status (1 octet)
+
 Read Tracing Buffer Size Command
 ================================
 
diff --git a/lib/mgmt.h b/lib/mgmt.h
index 57e7603..be2f567 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -205,6 +205,11 @@ struct mgmt_cp_remove_remote_oob_data {
 
 #define MGMT_OP_STOP_DISCOVERY		0x001C
 
+#define MGMT_OP_SET_FAST_CONNECTABLE	0x001F
+struct mgmt_cp_set_fast_connectable {
+	uint8_t enable;
+} __packed;
+
 #define MGMT_EV_CMD_COMPLETE		0x0001
 struct mgmt_ev_cmd_complete {
 	uint16_t opcode;
diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index 4302813..2893dfd 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -1201,6 +1201,9 @@ static void mgmt_cmd_complete(int sk, uint16_t index, void *buf, size_t len)
 	case MGMT_OP_REMOVE_REMOTE_OOB_DATA:
 		DBG("remove_remote_oob_data complete");
 		break;
+	case MGMT_OP_SET_FAST_CONNECTABLE:
+		DBG("set_fast_connectable complete");
+		break;
 	default:
 		error("Unknown command complete for opcode %u", opcode);
 		break;
@@ -1655,10 +1658,25 @@ static int mgmt_cancel_resolve_name(int index, bdaddr_t *bdaddr)
 	return -ENOSYS;
 }
 
-static int mgmt_fast_connectable(int index, gboolean enable)
+static int mgmt_set_fast_connectable(int index, gboolean enable)
 {
+	char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_set_fast_connectable)];
+	struct mgmt_hdr *hdr = (void *) buf;
+	struct mgmt_cp_set_fast_connectable *cp = (void *) &buf[sizeof(*hdr)];
+
 	DBG("index %d enable %d", index, enable);
-	return -ENOSYS;
+
+	memset(buf, 0, sizeof(buf));
+	hdr->opcode = htobs(MGMT_OP_SET_FAST_CONNECTABLE);
+	hdr->len = htobs(sizeof(*cp));
+	hdr->index = htobs(index);
+
+	cp->enable = enable;
+
+	if (write(mgmt_sock, buf, sizeof(buf)) < 0)
+		return -errno;
+
+	return 0;
 }
 
 static int mgmt_read_clock(int index, bdaddr_t *bdaddr, int which, int timeout,
@@ -2014,7 +2032,7 @@ static struct btd_adapter_ops mgmt_ops = {
 	.cancel_resolve_name = mgmt_cancel_resolve_name,
 	.set_name = mgmt_set_name,
 	.set_dev_class = mgmt_set_dev_class,
-	.set_fast_connectable = mgmt_fast_connectable,
+	.set_fast_connectable = mgmt_set_fast_connectable,
 	.read_clock = mgmt_read_clock,
 	.read_bdaddr = mgmt_read_bdaddr,
 	.block_device = mgmt_block_device,
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] Implement fast connectable mode for mgmt interface
  2011-06-16 11:55 Antti Julku
@ 2011-06-16 18:57 ` Johan Hedberg
  0 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2011-06-16 18:57 UTC (permalink / raw)
  To: Antti Julku; +Cc: linux-bluetooth

Hi Antti,

On Thu, Jun 16, 2011, Antti Julku wrote:
> Management interface implementation for fast connectable mode.
> ---
>  doc/mgmt-api.txt  |    8 ++++++++
>  lib/mgmt.h        |    5 +++++
>  plugins/mgmtops.c |   24 +++++++++++++++++++++---
>  3 files changed, 34 insertions(+), 3 deletions(-)

Now that your blacklist patch has been applied this one doesn't apply
cleanly anymore, so you'll have to rebase against the upstream tree.

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] Implement fast connectable mode for mgmt interface
@ 2011-06-17  9:44 Antti Julku
  2011-06-17  9:44 ` [PATCH 2/2] Rename fast_connectable function in hciops Antti Julku
  2011-09-27  9:32 ` [PATCH 1/2] Implement fast connectable mode for mgmt interface Johan Hedberg
  0 siblings, 2 replies; 5+ messages in thread
From: Antti Julku @ 2011-06-17  9:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Antti Julku

Management interface implementation for fast connectable mode.
---
 doc/mgmt-api.txt  |    8 ++++++++
 lib/mgmt.h        |    5 +++++
 plugins/mgmtops.c |   24 +++++++++++++++++++++---
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index d89467c..8bf5e52 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -335,6 +335,14 @@ Unblock Device Command
 	Command Parameters:	Address (6 Octets)
 	Return Parameters:	Status (1 octet)
 
+Set Fast Connectable Command
+============================
+
+        Command Code:           0x0001F
+        Controller Index:       <controller id>
+        Command Parameters:     Enable (1 Octet)
+        Return Parameters:      Status (1 octet)
+
 Read Tracing Buffer Size Command
 ================================
 
diff --git a/lib/mgmt.h b/lib/mgmt.h
index f22434e..95003a2 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -215,6 +215,11 @@ struct mgmt_cp_unblock_device {
 	bdaddr_t bdaddr;
 } __packed;
 
+#define MGMT_OP_SET_FAST_CONNECTABLE	0x001F
+struct mgmt_cp_set_fast_connectable {
+	uint8_t enable;
+} __packed;
+
 #define MGMT_EV_CMD_COMPLETE		0x0001
 struct mgmt_ev_cmd_complete {
 	uint16_t opcode;
diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index d6226c4..b98c995 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -1207,6 +1207,9 @@ static void mgmt_cmd_complete(int sk, uint16_t index, void *buf, size_t len)
 	case MGMT_OP_UNBLOCK_DEVICE:
 		DBG("unblock_device complete");
 		break;
+	case MGMT_OP_SET_FAST_CONNECTABLE:
+		DBG("set_fast_connectable complete");
+		break;
 	default:
 		error("Unknown command complete for opcode %u", opcode);
 		break;
@@ -1661,10 +1664,25 @@ static int mgmt_cancel_resolve_name(int index, bdaddr_t *bdaddr)
 	return -ENOSYS;
 }
 
-static int mgmt_fast_connectable(int index, gboolean enable)
+static int mgmt_set_fast_connectable(int index, gboolean enable)
 {
+	char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_set_fast_connectable)];
+	struct mgmt_hdr *hdr = (void *) buf;
+	struct mgmt_cp_set_fast_connectable *cp = (void *) &buf[sizeof(*hdr)];
+
 	DBG("index %d enable %d", index, enable);
-	return -ENOSYS;
+
+	memset(buf, 0, sizeof(buf));
+	hdr->opcode = htobs(MGMT_OP_SET_FAST_CONNECTABLE);
+	hdr->len = htobs(sizeof(*cp));
+	hdr->index = htobs(index);
+
+	cp->enable = enable;
+
+	if (write(mgmt_sock, buf, sizeof(buf)) < 0)
+		return -errno;
+
+	return 0;
 }
 
 static int mgmt_read_clock(int index, bdaddr_t *bdaddr, int which, int timeout,
@@ -2056,7 +2074,7 @@ static struct btd_adapter_ops mgmt_ops = {
 	.cancel_resolve_name = mgmt_cancel_resolve_name,
 	.set_name = mgmt_set_name,
 	.set_dev_class = mgmt_set_dev_class,
-	.set_fast_connectable = mgmt_fast_connectable,
+	.set_fast_connectable = mgmt_set_fast_connectable,
 	.read_clock = mgmt_read_clock,
 	.read_bdaddr = mgmt_read_bdaddr,
 	.block_device = mgmt_block_device,
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] Rename fast_connectable function in hciops
  2011-06-17  9:44 [PATCH 1/2] Implement fast connectable mode for mgmt interface Antti Julku
@ 2011-06-17  9:44 ` Antti Julku
  2011-09-27  9:32 ` [PATCH 1/2] Implement fast connectable mode for mgmt interface Johan Hedberg
  1 sibling, 0 replies; 5+ messages in thread
From: Antti Julku @ 2011-06-17  9:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Antti Julku

Rename fast_connectable function in hciops to set_fast_connectable
to make it consistent with rest of the file and with mgmt interface
counterpart.
---
 plugins/hciops.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/plugins/hciops.c b/plugins/hciops.c
index 6ce0e27..db4b9a4 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -3107,7 +3107,7 @@ static int hciops_stop_discovery(int index)
 	}
 }
 
-static int hciops_fast_connectable(int index, gboolean enable)
+static int hciops_set_fast_connectable(int index, gboolean enable)
 {
 	struct dev_info *dev = &devs[index];
 	write_page_activity_cp cp;
@@ -3662,7 +3662,7 @@ static struct btd_adapter_ops hci_ops = {
 	.cancel_resolve_name = hciops_cancel_resolve_name,
 	.set_name = hciops_set_name,
 	.set_dev_class = hciops_set_dev_class,
-	.set_fast_connectable = hciops_fast_connectable,
+	.set_fast_connectable = hciops_set_fast_connectable,
 	.read_clock = hciops_read_clock,
 	.read_bdaddr = hciops_read_bdaddr,
 	.block_device = hciops_block_device,
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] Implement fast connectable mode for mgmt interface
  2011-06-17  9:44 [PATCH 1/2] Implement fast connectable mode for mgmt interface Antti Julku
  2011-06-17  9:44 ` [PATCH 2/2] Rename fast_connectable function in hciops Antti Julku
@ 2011-09-27  9:32 ` Johan Hedberg
  1 sibling, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2011-09-27  9:32 UTC (permalink / raw)
  To: Antti Julku; +Cc: linux-bluetooth

Hi Antti,

On Fri, Jun 17, 2011, Antti Julku wrote:
> Management interface implementation for fast connectable mode.
> ---
>  doc/mgmt-api.txt  |    8 ++++++++
>  lib/mgmt.h        |    5 +++++
>  plugins/mgmtops.c |   24 +++++++++++++++++++++---
>  3 files changed, 34 insertions(+), 3 deletions(-)

Both patches applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-09-27  9:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-17  9:44 [PATCH 1/2] Implement fast connectable mode for mgmt interface Antti Julku
2011-06-17  9:44 ` [PATCH 2/2] Rename fast_connectable function in hciops Antti Julku
2011-09-27  9:32 ` [PATCH 1/2] Implement fast connectable mode for mgmt interface Johan Hedberg
  -- strict thread matches above, loose matches on Subject: below --
2011-06-16 11:55 Antti Julku
2011-06-16 18:57 ` Johan Hedberg

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).