Diff between 23fed61b1f3385f6f2d5c98cea8e8536ef5d3be1 and 421efd407e93464d86e6c77ebf3e237001a30bfe

Changed Files

File Additions Deletions Status
doc/mgmt-api.txt +15 -0 modified
lib/mgmt.h +4 -0 modified
plugins/mgmtops.c +22 -2 modified

Full Patch

diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt
index 1334044..0d6523f 100644
--- a/doc/mgmt-api.txt
+++ b/doc/mgmt-api.txt
@@ -303,6 +303,21 @@ Remove Remote Out Of Band Data Command
 	Command Parameters:	Address (6 Octets)
 	Return Paramters:
 
+Start Discovery Command
+=======================
+
+	Command Code:		0x0001B
+	Controller Index:	<controller id>
+	Command Parameters:
+	Return Parameters:
+
+Stop Discovery Command
+======================
+
+	Command Code:		0x0001C
+	Controller Index:	<controller id>
+	Command Parameters:
+	Return Parameters:
 
 Read Tracing Buffer Size Command
 ================================
diff --git a/lib/mgmt.h b/lib/mgmt.h
index fdec6c2..ec3985c 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -201,6 +201,10 @@ struct mgmt_cp_remove_remote_oob_data {
 	bdaddr_t bdaddr;
 } __packed;
 
+#define MGMT_OP_START_DISCOVERY		0x001B
+
+#define MGMT_OP_STOP_DISCOVERY		0x001C
+
 #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 b41be77..f366c8b 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -1518,14 +1518,34 @@ static int mgmt_set_limited_discoverable(int index, gboolean limited)
 
 static int mgmt_start_inquiry(int index, uint8_t length, gboolean periodic)
 {
+	struct mgmt_hdr hdr;
+
 	DBG("index %d length %u periodic %d", index, length, periodic);
-	return -ENOSYS;
+
+	memset(&hdr, 0, sizeof(hdr));
+	hdr.opcode = htobs(MGMT_OP_START_DISCOVERY);
+	hdr.index = htobs(index);
+
+	if (write(mgmt_sock, &hdr, sizeof(hdr)) < 0)
+		return -errno;
+
+	return 0;
 }
 
 static int mgmt_stop_inquiry(int index)
 {
+	struct mgmt_hdr hdr;
+
 	DBG("index %d", index);
-	return -ENOSYS;
+
+	memset(&hdr, 0, sizeof(hdr));
+	hdr.opcode = htobs(MGMT_OP_STOP_DISCOVERY);
+	hdr.index = htobs(index);
+
+	if (write(mgmt_sock, &hdr, sizeof(hdr)) < 0)
+		return -errno;
+
+	return 0;
 }
 
 static int mgmt_start_scanning(int index)