From: Albert Huang <ashuang@gmail.com>
To: BlueZ Mailing List <bluez-devel@lists.sourceforge.net>
Subject: [Bluez-devel] patch to add read/write inquiry scan type functionality
Date: Wed, 15 Jun 2005 15:58:52 -0400 [thread overview]
Message-ID: <ef9938ec0506151258214c60e1@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 167 bytes --]
The attached patches add reading and writing of inquiry scan type (for
interlaced inquiry scan)
One patch is for libs, the other is for utils
Regards,
Albert
[-- Attachment #2: libs-albert-istype.diff --]
[-- Type: text/plain, Size: 3223 bytes --]
Index: include/hci.h
===================================================================
RCS file: /cvsroot/bluez/libs/include/hci.h,v
retrieving revision 1.69
diff -u -r1.69 hci.h
--- include/hci.h 8 May 2005 12:24:54 -0000 1.69
+++ include/hci.h 15 Jun 2005 18:09:47 -0000
@@ -833,6 +833,23 @@
} __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;
Index: include/hci_lib.h
===================================================================
RCS file: /cvsroot/bluez/libs/include/hci_lib.h,v
retrieving revision 1.47
diff -u -r1.47 hci_lib.h
--- include/hci_lib.h 1 May 2005 14:52:53 -0000 1.47
+++ include/hci_lib.h 15 Jun 2005 18:09:47 -0000
@@ -97,6 +97,8 @@
int hci_exit_park_mode(int dd, uint16_t handle, 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_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_afh_mode(int dd, uint8_t *mode, int to);
int hci_write_afh_mode(int dd, uint8_t mode, int to);
int hci_read_transmit_power_level(int dd, uint16_t handle, uint8_t type, int8_t *level, int to);
Index: src/hci.c
===================================================================
RCS file: /cvsroot/bluez/libs/src/hci.c,v
retrieving revision 1.71
diff -u -r1.71 hci.c
--- src/hci.c 1 May 2005 14:52:53 -0000 1.71
+++ src/hci.c 15 Jun 2005 18:09:48 -0000
@@ -1885,6 +1885,57 @@
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_local_name(int dd, int len, char *name, int to)
{
return hci_read_local_name(dd, len, name, to);
[-- Attachment #3: utils-albert-istype.diff --]
[-- Type: text/plain, Size: 1759 bytes --]
Index: tools/hciconfig.c
===================================================================
RCS file: /cvsroot/bluez/utils/tools/hciconfig.c,v
retrieving revision 1.62
diff -u -r1.62 hciconfig.c
--- tools/hciconfig.c 1 May 2005 14:54:11 -0000 1.62
+++ tools/hciconfig.c 15 Jun 2005 18:26:49 -0000
@@ -881,6 +881,40 @@
}
}
+static void cmd_inq_scan_type(int ctl, int hdev, char *opt)
+{
+ int dd;
+
+ dd = hci_open_dev(hdev);
+ if (dd < 0) {
+ fprintf(stderr, "Can't open device hci%d: %s (%d)\n",
+ hdev, strerror(errno), errno);
+ exit(1);
+ }
+
+ if (opt) {
+ uint8_t type = atoi(opt);
+
+ if (hci_write_inquiry_scan_type(dd, type, 2000) < 0) {
+ fprintf(stderr, "Can't set inquiry scan type on hci%d: %s (%d)\n",
+ hdev, strerror(errno), errno);
+ exit(1);
+ }
+ } else {
+ uint8_t type;
+
+ if (hci_read_inquiry_scan_type(dd, &type, 1000) < 0) {
+ fprintf(stderr, "Can't read inquiry scan type on hci%d: %s (%d)\n",
+ hdev, strerror(errno), errno);
+ exit(1);
+ }
+
+ print_dev_hdr(&di);
+ printf("\tInquiry scan type: %s\n",
+ type == 1 ? "Interlaced Inquiry Scan" : "Standard Inquiry Scan");
+ }
+}
+
static void cmd_inq_parms(int ctl, int hdev, char *opt)
{
struct hci_request rq;
@@ -1325,6 +1359,7 @@
{ "voice", cmd_voice, "[voice]", "Get/Set voice setting" },
{ "iac", cmd_iac, "[iac]", "Get/Set inquiry access code" },
{ "inqmode", cmd_inq_mode, "[mode]", "Get/set inquiry mode" },
+ { "istype", cmd_inq_scan_type, "[type]", "Get/set inquiry scan type" },
{ "inqparms", cmd_inq_parms, "[win:int]", "Get/Set inquiry scan window and interval" },
{ "pageparms", cmd_page_parms, "[win:int]", "Get/Set page scan window and interval" },
{ "pageto", cmd_page_to, "[to]", "Get/Set page timeout" },
next reply other threads:[~2005-06-15 19:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-15 19:58 Albert Huang [this message]
2005-06-16 14:05 ` [Bluez-devel] patch to add read/write inquiry scan type functionality Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef9938ec0506151258214c60e1@mail.gmail.com \
--to=ashuang@gmail.com \
--cc=bluez-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox