Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/btconfig add "imode" parameter to allow setting the...
details: https://anonhg.NetBSD.org/src/rev/a198d1a5b6f3
branches: trunk
changeset: 746961:a198d1a5b6f3
user: plunky <plunky%NetBSD.org@localhost>
date: Mon Aug 24 20:43:35 2009 +0000
description:
add "imode" parameter to allow setting the Inquiry Mode. This supercedes
the "rssi" parameter (which remains for compatibility)
imode takes an argument: "std", "rssi" or "ext"
diffstat:
usr.sbin/btconfig/btconfig.8 | 22 ++++++++++++--
usr.sbin/btconfig/btconfig.c | 64 +++++++++++++++++++++++++++++++++++--------
2 files changed, 70 insertions(+), 16 deletions(-)
diffs (193 lines):
diff -r 4606d3fb1480 -r a198d1a5b6f3 usr.sbin/btconfig/btconfig.8
--- a/usr.sbin/btconfig/btconfig.8 Mon Aug 24 20:37:36 2009 +0000
+++ b/usr.sbin/btconfig/btconfig.8 Mon Aug 24 20:43:35 2009 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: btconfig.8,v 1.11 2009/08/20 21:40:59 plunky Exp $
+.\" $NetBSD: btconfig.8,v 1.12 2009/08/24 20:43:35 plunky Exp $
.\"
.\" Copyright (c) 2006 Itronix Inc.
.\" All rights reserved.
@@ -138,12 +138,26 @@
Set variable pin type.
.It Cm inquiry
Perform device Discovery from the specified device and print details.
-.It Cm rssi
+.It Cm imode Ar type
+Set inquiry mode type to control which event formats are generated during
+a device inquiry.
+The
+.Ar type
+can be:
+.Bl -tag -width xxxxxx
+.It std
+Standard Inquiry Result Event format.
+.It rssi
Enable Remote Signal Strength Indicator (RSSI) in inquiry results.
This will only work if the device features indicate
.Aq RSSI with inquiry result .
-.It Cm -rssi
-Disable Remote Signal Strength Indicator (RSSI) in inquiry results.
+.It ext
+Inquiry Result with RSSI format or Extended Inquiry Result fomat.
+This will only work where the device features indicate
+.Aq extended inquiry ,
+and the Extended Inquiry Result will only occur when the remote device
+provides the extended information.
+.El
.It Cm reset
Perform a hard reset on the device and re-initialise system state.
.It Cm voice
diff -r 4606d3fb1480 -r a198d1a5b6f3 usr.sbin/btconfig/btconfig.c
--- a/usr.sbin/btconfig/btconfig.c Mon Aug 24 20:37:36 2009 +0000
+++ b/usr.sbin/btconfig/btconfig.c Mon Aug 24 20:43:35 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: btconfig.c,v 1.14 2009/08/20 21:40:59 plunky Exp $ */
+/* $NetBSD: btconfig.c,v 1.15 2009/08/24 20:43:35 plunky Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2006 Itronix, Inc. All rights reserved.");
-__RCSID("$NetBSD: btconfig.c,v 1.14 2009/08/20 21:40:59 plunky Exp $");
+__RCSID("$NetBSD: btconfig.c,v 1.15 2009/08/24 20:43:35 plunky Exp $");
#include <sys/ioctl.h>
#include <sys/param.h>
@@ -60,9 +60,11 @@
int main(int, char *[]);
void badarg(const char *);
void badparam(const char *);
+void badval(const char *, const char *);
void usage(void);
int set_unit(unsigned long);
void config_unit(void);
+void print_val(const char *, const char **, int);
void print_info(int);
void print_stats(void);
void print_class(const char *);
@@ -144,10 +146,12 @@
int opt_pin = 0;
/* Inquiry */
-int opt_rssi = 0; /* inquiry_with_rssi (flag) */
+int opt_rssi = 0; /* inquiry_with_rssi (obsolete flag) */
+int opt_imode = 0; /* inquiry mode */
int opt_inquiry = 0;
#define INQUIRY_LENGTH 10 /* about 12 seconds */
#define INQUIRY_MAX_RESPONSES 10
+const char *imodes[] = { "std", "rssi", "ext", NULL };
/* Voice Settings */
int opt_voice = 0;
@@ -163,7 +167,7 @@
struct parameter {
const char *name;
- enum { P_SET, P_CLR, P_STR, P_HEX, P_NUM } type;
+ enum { P_SET, P_CLR, P_STR, P_HEX, P_NUM, P_VAL } type;
int *opt;
void *val;
} parameters[] = {
@@ -196,6 +200,7 @@
{ "variable", P_CLR, &opt_pin, NULL },
{ "inq", P_SET, &opt_inquiry, NULL },
{ "inquiry", P_SET, &opt_inquiry, NULL },
+ { "imode", P_VAL, &opt_imode, imodes },
{ "rssi", P_SET, &opt_rssi, NULL },
{ "-rssi", P_CLR, &opt_rssi, NULL },
{ "reset", P_SET, &opt_reset, NULL },
@@ -299,6 +304,17 @@
*(uint32_t *)(p->val) = strtoul(*++av, NULL, 10);
*(p->opt) = 1;
break;
+
+ case P_VAL:
+ if (--ac < 1) badarg(p->name);
+ ++av;
+ ch = 0;
+ do {
+ if (((char **)(p->val))[ch] == NULL)
+ badval(p->name, *av);
+ } while (strcmp(((char **)(p->val))[ch++], *av));
+ *(p->opt) = ch;
+ break;
}
av++, ac--;
@@ -331,6 +347,14 @@
}
void
+badval(const char *param, const char *value)
+{
+
+ fprintf(stderr, "bad value '%s' for parameter '%s'\n", value, param);
+ exit(EXIT_FAILURE);
+}
+
+void
usage(void)
{
@@ -615,14 +639,31 @@
}
}
- if (opt_rssi) {
+ if (opt_imode | opt_rssi) {
uint8_t val = (opt_rssi > 0 ? 1 : 0);
+ if (opt_imode)
+ val = opt_imode - 1;
+
save_value(HCI_CMD_WRITE_INQUIRY_MODE, &val, sizeof(val));
}
}
/*
+ * print value from NULL terminated array given index
+ */
+void
+print_val(const char *hdr, const char **argv, int idx)
+{
+ int i = 0;
+
+ while (i < idx && *argv != NULL)
+ i++, argv++;
+
+ printf("\t%s: %s\n", hdr, *argv == NULL ? "unknown" : *argv);
+}
+
+/*
* Print info for Bluetooth Device with varying verbosity levels
*/
void
@@ -682,6 +723,12 @@
load_value(HCI_CMD_READ_PIN_TYPE, &val, sizeof(val));
printf("\tpin: %s\n", val ? "fixed" : "variable");
+ val = 0;
+ if (version >= HCI_SPEC_V12)
+ load_value(HCI_CMD_READ_INQUIRY_MODE, &val, sizeof(val));
+
+ print_val("inquiry mode", imodes, val);
+
width = printf("\toptions:");
load_value(HCI_CMD_READ_SCAN_ENABLE, &val, sizeof(val));
@@ -709,13 +756,6 @@
if (val & HCI_LINK_POLICY_ENABLE_PARK_MODE) tag("park");
else if (level > 0) tag("-park");
- val = 0;
- if (version >= HCI_SPEC_V12)
- load_value(HCI_CMD_READ_INQUIRY_MODE, &val, sizeof(val));
-
- if (val) tag("rssi");
- else if (level > 0) tag("-rssi");
-
tag(NULL);
if (level-- < 1)
Home |
Main Index |
Thread Index |
Old Index