Diff between fa63522766966692d0a93b589010c0a23a03ce53 and 1dcd74358cc829c95197e29f756e83a8b8d818cb

Changed Files

File Additions Deletions Status
doc/mgmt-api.txt +8 -0 modified
lib/mgmt.h +5 -0 modified
plugins/mgmtops.c +21 -3 modified

Full Patch

diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 4ccbabf..ef0d1f2 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 260f8c0..a3a90e9 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 0f68aa3..7df00ee 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;
@@ -1715,10 +1718,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,
@@ -2090,7 +2108,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,