From 421efd407e93464d86e6c77ebf3e237001a30bfe Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 31 Mar 2011 14:26:20 +0300 Subject: [PATCH] mgmt: Add support for start_discovery & stop_discovery --- doc/mgmt-api.txt | 15 +++++++++++++++ lib/mgmt.h | 4 ++++ plugins/mgmtops.c | 24 ++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/doc/mgmt-api.txt b/doc/mgmt-api.txt index 133404499..0d6523f69 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: + Command Parameters: + Return Parameters: + +Stop Discovery Command +====================== + + Command Code: 0x0001C + Controller Index: + Command Parameters: + Return Parameters: Read Tracing Buffer Size Command ================================ diff --git a/lib/mgmt.h b/lib/mgmt.h index fdec6c289..ec3985ccc 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 b41be7720..f366c8b94 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) -- 2.47.3