From f38a7523b3e2ec2109cd5c5f65803da5a354da03 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 16 Jun 2005 13:53:08 +0000 Subject: Add support for reading and writing the inquiry scan type --- include/hci.h | 17 +++++++++++++++++ include/hci_lib.h | 2 ++ src/hci.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) diff --git a/include/hci.h b/include/hci.h index 86ffe8c9..b6275196 100644 --- a/include/hci.h +++ b/include/hci.h @@ -833,6 +833,23 @@ typedef struct { } __attribute__ ((packed)) set_afh_classification_rp; #define SET_AFH_CLASSIFICATION_RP_SIZE 1 +#define OCF_READ_INQUIRY_SCAN_TYPE 0x0042 +typedef struct { + uint8_t status; + uint8_t type; +} __attribute__ ((packed)) read_inquiry_scan_type_rp; +#define READ_INQUIRY_SCAN_TYPE_RP_SIZE 2 + +#define OCF_WRITE_INQUIRY_SCAN_TYPE 0x0043 +typedef struct { + uint8_t type; +} __attribute__ ((packed)) write_inquiry_scan_type_cp; +#define WRITE_INQUIRY_SCAN_TYPE_CP_SIZE 1 +typedef struct { + uint8_t status; +} __attribute__ ((packed)) write_inquiry_scan_type_rp; +#define WRITE_INQUIRY_SCAN_TYPE_RP_SIZE 1 + #define OCF_READ_INQUIRY_MODE 0x0044 typedef struct { uint8_t status; diff --git a/include/hci_lib.h b/include/hci_lib.h index 7761bb99..eac144e7 100644 --- a/include/hci_lib.h +++ b/include/hci_lib.h @@ -95,6 +95,8 @@ int hci_change_link_key(int dd, uint16_t handle, int to); int hci_switch_role(int dd, bdaddr_t *bdaddr, uint8_t role, int to); int hci_park_mode(int dd, uint16_t handle, uint16_t max_interval, uint16_t min_interval, int to); int hci_exit_park_mode(int dd, uint16_t handle, int to); +int hci_read_inquiry_scan_type(int dd, uint8_t *type, int to); +int hci_write_inquiry_scan_type(int dd, uint8_t type, int to); int hci_read_inquiry_mode(int dd, uint8_t *mode, int to); int hci_write_inquiry_mode(int dd, uint8_t mode, int to); int hci_read_afh_mode(int dd, uint8_t *mode, int to); diff --git a/src/hci.c b/src/hci.c index 60898e9b..b52b53fa 100644 --- a/src/hci.c +++ b/src/hci.c @@ -1564,6 +1564,57 @@ int hci_exit_park_mode(int dd, uint16_t handle, int to) return 0; } +int hci_read_inquiry_scan_type(int dd, uint8_t *type, int to) +{ + read_inquiry_scan_type_rp rp; + struct hci_request rq; + + memset(&rq, 0, sizeof(rq)); + rq.ogf = OGF_HOST_CTL; + rq.ocf = OCF_READ_INQUIRY_SCAN_TYPE; + rq.rparam = &rp; + rq.rlen = READ_INQUIRY_SCAN_TYPE_RP_SIZE; + + if (hci_send_req(dd, &rq, to) < 0) + return -1; + + if (rp.status) { + errno = EIO; + return -1; + } + + *type = rp.type; + return 0; +} + +int hci_write_inquiry_scan_type(int dd, uint8_t type, int to) +{ + write_inquiry_scan_type_cp cp; + write_inquiry_scan_type_rp rp; + struct hci_request rq; + + memset(&cp, 0, sizeof(cp)); + cp.type = type; + + memset(&rq, 0, sizeof(rq)); + rq.ogf = OGF_HOST_CTL; + rq.ocf = OCF_WRITE_INQUIRY_SCAN_TYPE; + rq.cparam = &cp; + rq.clen = WRITE_INQUIRY_SCAN_TYPE_CP_SIZE; + rq.rparam = &rp; + rq.rlen = WRITE_INQUIRY_SCAN_TYPE_RP_SIZE; + + if (hci_send_req(dd, &rq, to) < 0) + return -1; + + if (rp.status) { + errno = EIO; + return -1; + } + + return 0; +} + int hci_read_inquiry_mode(int dd, uint8_t *mode, int to) { read_inquiry_mode_rp rp; -- cgit