summaryrefslogtreecommitdiff
path: root/usr.sbin/btdevctl
diff options
context:
space:
mode:
authorplunky <plunky@NetBSD.org>2006-09-10 15:45:55 +0000
committerplunky <plunky@NetBSD.org>2006-09-10 15:45:55 +0000
commit4f1cbddc12c28f2041be5e25437215eeb7d31179 (patch)
tree41685ed68d501d0d63266ab6356a30d7c8802134 /usr.sbin/btdevctl
parent96c9f80c3d64038c2503c8341652f4908d9c24ae (diff)
update to bluetooth device attachment:
remove pseudo-device btdev(4) and inherent limitations add bthub(4) which autoconfigures at bluetooth controllers as they are enabled. bluetooth devices now attach here. btdevctl(8) and its cache is updated to handle new semantics etc/rc.d/btdevctl is updated to configure devices from a list in /etc/bluetooth/btdevctl.conf
Diffstat (limited to 'usr.sbin/btdevctl')
-rw-r--r--usr.sbin/btdevctl/Makefile4
-rw-r--r--usr.sbin/btdevctl/btdevctl.8114
-rw-r--r--usr.sbin/btdevctl/btdevctl.c237
-rw-r--r--usr.sbin/btdevctl/btdevctl.h19
-rw-r--r--usr.sbin/btdevctl/db.c224
-rw-r--r--usr.sbin/btdevctl/dev.c137
-rw-r--r--usr.sbin/btdevctl/print.c (renamed from usr.sbin/btdevctl/hid.c)125
-rw-r--r--usr.sbin/btdevctl/sdp.c (renamed from usr.sbin/btdevctl/cfg.c)209
8 files changed, 578 insertions, 491 deletions
diff --git a/usr.sbin/btdevctl/Makefile b/usr.sbin/btdevctl/Makefile
index b81b46cd1c1..a7d54ff4122 100644
--- a/usr.sbin/btdevctl/Makefile
+++ b/usr.sbin/btdevctl/Makefile
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.1 2006/08/13 09:03:23 plunky Exp $
+# $NetBSD: Makefile,v 1.2 2006/09/10 15:45:56 plunky Exp $
PROG= btdevctl
MAN= btdevctl.8
-SRCS= btdevctl.c cfg.c dev.c hid.c
+SRCS= btdevctl.c db.c print.c sdp.c
DPADD+= ${LIBBLUETOOTH} ${LIBPROP} ${LIBSDP} ${LIBUSBHID}
LDADD+= -lbluetooth -lprop -lsdp -lusbhid
diff --git a/usr.sbin/btdevctl/btdevctl.8 b/usr.sbin/btdevctl/btdevctl.8
index 96ebf556c93..2af72f769fd 100644
--- a/usr.sbin/btdevctl/btdevctl.8
+++ b/usr.sbin/btdevctl/btdevctl.8
@@ -1,4 +1,4 @@
-.\" $NetBSD: btdevctl.8,v 1.2 2006/08/27 11:41:58 plunky Exp $
+.\" $NetBSD: btdevctl.8,v 1.3 2006/09/10 15:45:56 plunky Exp $
.\"
.\" Copyright (c) 2006 Itronix Inc.
.\" All rights reserved.
@@ -51,10 +51,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: btdevctl.8,v 1.2 2006/08/27 11:41:58 plunky Exp $
+.\" $Id: btdevctl.8,v 1.3 2006/09/10 15:45:56 plunky Exp $
.\" $FreeBSD: src/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.8,v 1.3 2005/01/18 20:02:30 ru Exp $
.\"
-.Dd August 27, 2006
+.Dd September 9, 2006
.Dt BTDEVCTL 8
.Os
.Sh NAME
@@ -62,84 +62,84 @@
.Nd Bluetooth remote device control utility
.Sh SYNOPSIS
.Nm
-.Ar btdev
-.Ar command
-.Op Ar parameters
+.Op Fl A | Fl D
+.Op Fl qv
+.Fl a Ar address
+.Fl d Ar device
+.Fl s Ar service
.Sh DESCRIPTION
The
.Nm
-utility is used to configure
-.Xr btdev 4
-devices in the system, and manage the configuration entries stored in the
-.Pa /var/db/btdev.xml
-file.
-.Pp
-The
+utility is used to configure bluetooth devices in the system.
+Normally,
+.Nm
+will perform an SDP query to the remote device as needed, and
+cache the results in the
+.Pa /var/db/btdevctl.plist
+file for later use.
+If neither Attach nor Detach is specified,
.Nm
-utility will print results to the standard output and error messages to the
-standard error.
+will display the configuration.
.Pp
-The commands are as follows:
-.Bl -tag -width indent
-.It Cm Attach Op Fl q
-Attach device to
-.Ar btdev .
-If the
-.Fl q
-flag is given, be quiet about unconfigured devices.
-.It Cm Detach Op Fl q
-Detach device from
-.Ar btdev .
-.It Cm Parse
-Parse HID descriptor in configuration entry for
-.Ar btdev
-and print in legible format.
-.It Cm Print
-Print configuration entry for
-.Ar btdev
-.It Cm Query Oo Fl d Ar device Oc Fl a Ar address Fl s Ar service
-Perform an SDP query to the remote Bluetooth
-.Ar address
-for the given
-.Ar service
-and create a configuration entry for
-.Ar btdev .
+The options are:
+.Bl -tag
+.It Fl A
+Attach device
+.It Fl a Ar address
+Remote device address.
+The
.Ar address
may be given as BDADDR or a name.
If a name was specified,
.Nm
attempts to resolve the name via
.Xr bt_gethostbyname 3 .
-Communications can be limited to a specific controller by use of the
-.Fl d
-option.
+.It Fl D
+Detach device
+.It Fl d Ar device
+Local device address.
+May be given as BDADDR or device name.
+.It Fl q
+Ignore any cached data and perform a SDP query for the given
+.Ar service .
+.It Fl s Ar service
+Service to configure.
Known services are:
.Pp
-.Bl -tag -compact
+.Bl -tag -width HSETXX -compact
.It Dv HID
-Human Interface Device
-.It Dv HFP
-Hands Free Profile
+Human Interface Device.
+.It Dv HF
+Handsfree.
.It Dv HSET
-Headset
+Headset.
.El
-.Pp
-.It Cm Remove
-Remove config entry for
-.Ar btdev
-from configuration file.
+.It Fl v
+Be verbose.
.El
+.Pp
+For device configurations to persist across boots, add entries to the
+.Pa /etc/bluetooth/btdevctl.conf
+file and
+set the
+.Xr rc.conf 5
+variable
+.Sy btdevctl
+to YES.
+.Pp
.Sh EXIT STATUS
.Ex -std
.Sh FILES
.Bl -tag -compact
-.It Pa /dev/btdevN
-.It Pa /var/db/btdev.xml
+.It Pa /etc/bluetooth/btdevctl.conf
+.It Pa /dev/bthub
+.It Pa /var/db/btdevctl.plist
.El
.Sh SEE ALSO
-.Xr btdev 4 ,
.Xr bthidev 4 ,
-.Xr btsco 4
+.Xr bthub 4 ,
+.Xr btsco 4 ,
+.Xr rc.conf 5
.Sh HISTORY
Parts of the
.Nm
diff --git a/usr.sbin/btdevctl/btdevctl.c b/usr.sbin/btdevctl/btdevctl.c
index 731a04c92c5..a6c72590c88 100644
--- a/usr.sbin/btdevctl/btdevctl.c
+++ b/usr.sbin/btdevctl/btdevctl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: btdevctl.c,v 1.1 2006/08/13 09:03:23 plunky Exp $ */
+/* $NetBSD: btdevctl.c,v 1.2 2006/09/10 15:45:56 plunky Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -34,134 +34,191 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2006 Itronix, Inc.\n"
"All rights reserved.\n");
-__RCSID("$NetBSD: btdevctl.c,v 1.1 2006/08/13 09:03:23 plunky Exp $");
+__RCSID("$NetBSD: btdevctl.c,v 1.2 2006/09/10 15:45:56 plunky Exp $");
#include <prop/proplib.h>
+#include <sys/ioctl.h>
+#include <bluetooth.h>
+#include <ctype.h>
#include <err.h>
#include <fcntl.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include "btdevctl.h"
+#include <dev/bluetooth/btdev.h>
-const char *config_file = "/var/db/btdev.xml";
-const char *control_file = NULL;
-
-struct command {
- const char *command;
- int (*handler)(int, char **);
- const char *description;
-} commands[] = {
- { "Attach", dev_attach, "attach device" },
- { "Detach", dev_detach, "detach device" },
- { "Parse", hid_parse, "parse HID descriptor" },
- { "Print", cfg_print, "print config entry" },
- { "Query", cfg_query, "make config entry" },
- { "Remove", cfg_remove, "remove config entry" },
- { NULL }
-};
-
-static void
-usage(void)
-{
- struct command *cmd;
+#include "btdevctl.h"
- fprintf(stderr, "Usage: %s <btdev> <command> [parameters]\n"
- "Commands:\n",
- getprogname());
+#define BTHUB_PATH "/dev/bthub"
- for (cmd = commands ; cmd->command != NULL ; cmd++)
- fprintf(stderr, "\t%-13s%s\n", cmd->command, cmd->description);
-
- exit(EXIT_FAILURE);
-}
+int main(int, char *[]);
+void usage(void);
+char *uppercase(const char *);
+int bthub_pioctl(unsigned long, prop_dictionary_t);
int
main(int argc, char *argv[])
{
- struct command *cmd;
+ prop_dictionary_t dev;
+ prop_object_t obj;
+ bdaddr_t laddr, raddr;
+ const char *service;
+ int ch, query, verbose, attach, detach;
+
+ bdaddr_copy(&laddr, BDADDR_ANY);
+ bdaddr_copy(&raddr, BDADDR_ANY);
+ service = NULL;
+ query = FALSE;
+ verbose = FALSE;
+ attach = FALSE;
+ detach = FALSE;
+
+ while ((ch = getopt(argc, argv, "Aa:Dd:hqs:v")) != -1) {
+ switch (ch) {
+ case 'A': /* Attach device */
+ attach = TRUE;
+ break;
+
+ case 'a': /* remote address */
+ if (!bt_aton(optarg, &raddr)) {
+ struct hostent *he = NULL;
+
+ if ((he = bt_gethostbyname(optarg)) == NULL)
+ errx(EXIT_FAILURE, "%s: %s",
+ optarg, hstrerror(h_errno));
+
+ bdaddr_copy(&raddr, (bdaddr_t *)he->h_addr);
+ }
+ break;
+
+ case 'D': /* Detach device */
+ detach = TRUE;
+ break;
+
+ case 'd': /* local device address */
+ if (!bt_devaddr(optarg, &laddr))
+ err(EXIT_FAILURE, "%s", optarg);
+
+ break;
+
+ case 'q':
+ query = TRUE;
+ break;
+
+ case 's': /* service */
+ service = uppercase(optarg);
+ break;
+
+ case 'v': /* verbose */
+ verbose = TRUE;
+ break;
+
+ case 'h':
+ default:
+ usage();
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
- if (argc < 3)
+ if (argc > 0
+ || (attach == TRUE && detach == TRUE)
+ || bdaddr_any(&laddr)
+ || bdaddr_any(&raddr)
+ || service == NULL)
usage();
- control_file = argv[1];
+ if (attach == FALSE && detach == FALSE)
+ verbose = TRUE;
- for (cmd = commands ; cmd->command != NULL ; cmd++) {
- if (strcasecmp(argv[2], cmd->command) == 0)
- return (cmd->handler)(argc - 2, argv + 2);
+ dev = db_get(&laddr, &raddr, service);
+ if (dev == NULL || query == TRUE) {
+ if (verbose == TRUE)
+ printf("Performing SDP query for service '%s'..\n", service);
+
+ dev = cfg_query(&laddr, &raddr, service);
+ if (dev == NULL)
+ errx(EXIT_FAILURE, "%s/%s not found", bt_ntoa(&raddr, NULL), service);
+
+ if (!db_set(dev, &laddr, &raddr, service))
+ errx(EXIT_FAILURE, "service store failed");
}
- errx(EXIT_FAILURE, "%s: unknown command", argv[2]);
+ /* add binary local-bdaddr */
+ obj = prop_data_create_data(&laddr, sizeof(laddr));
+ if (obj == NULL || !prop_dictionary_set(dev, BTDEVladdr, obj))
+ errx(EXIT_FAILURE, "proplib failure (%s)", BTDEVladdr);
+
+ prop_object_release(obj);
+
+ /* add binary remote-bdaddr */
+ obj = prop_data_create_data(&raddr, sizeof(raddr));
+ if (obj == NULL || !prop_dictionary_set(dev, BTDEVraddr, obj))
+ errx(EXIT_FAILURE, "proplib failure (%s)", BTDEVraddr);
+
+ prop_object_release(obj);
+
+ if (verbose == TRUE)
+ cfg_print(dev);
+
+ if (attach == TRUE)
+ bthub_pioctl(BTDEV_ATTACH, dev);
+
+ if (detach == TRUE)
+ bthub_pioctl(BTDEV_DETACH, dev);
+
+ exit(EXIT_SUCCESS);
}
-prop_dictionary_t
-read_config(void)
+void
+usage(void)
{
- prop_dictionary_t dict;
- char *xml;
- off_t len;
- int fd;
-
- fd = open(config_file, O_RDONLY, 0);
- if (fd < 0)
- return NULL;
- len = lseek(fd, 0, SEEK_END);
- if (len == 0) {
- close(fd);
- return NULL;
- }
+ fprintf(stderr,
+ "usage: %s [-A | -D] [-qv] -a address -d device -s service\n"
+ "Where:\n"
+ "\t-A attach device\n"
+ "\t-a address remote device address\n"
+ "\t-D detach device\n"
+ "\t-d device local device address\n"
+ "\t-q force SDP query\n"
+ "\t-s service remote service\n"
+ "\t-v verbose\n"
+ "", getprogname());
- xml = malloc(len);
- if (xml == NULL) {
- close(fd);
- return NULL;
- }
+ exit(EXIT_FAILURE);
+}
- (void)lseek(fd, 0, SEEK_SET);
- if (read(fd, xml, len) != len) {
- close(fd);
- free(xml);
- return NULL;
- }
+char *
+uppercase(const char *arg)
+{
+ char *str, *ptr;
- dict = prop_dictionary_internalize(xml);
+ str = strdup(arg);
+ if (str == NULL)
+ err(EXIT_FAILURE, "strdup");
- free(xml);
- close(fd);
+ for (ptr = str ; *ptr ; ptr++)
+ *ptr = (char)toupper((int)*ptr);
- return dict;
+ return str;
}
int
-write_config(prop_dictionary_t dict)
+bthub_pioctl(unsigned long cmd, prop_dictionary_t dict)
{
- char *xml;
- size_t len;
int fd;
- fd = open(config_file, O_WRONLY | O_CREAT | O_TRUNC, 0640);
+ fd = open(BTHUB_PATH, O_WRONLY, 0);
if (fd < 0)
- return 0;
+ err(EXIT_FAILURE, "%s", BTHUB_PATH);
- xml = prop_dictionary_externalize(dict);
- if (xml == NULL) {
- close(fd);
- return 0;
- }
-
- len = strlen(xml);
- if (write(fd, xml, len) != len) {
- free(xml);
- close(fd);
- return 0;
- }
+ if (prop_dictionary_send_ioctl(dict, fd, cmd))
+ err(EXIT_FAILURE, "%s", BTHUB_PATH);
- free(xml);
close(fd);
-
- return 1;
+ return EXIT_SUCCESS;
}
diff --git a/usr.sbin/btdevctl/btdevctl.h b/usr.sbin/btdevctl/btdevctl.h
index 902510b3efd..e5f207f03e6 100644
--- a/usr.sbin/btdevctl/btdevctl.h
+++ b/usr.sbin/btdevctl/btdevctl.h
@@ -1,4 +1,4 @@
-/* $NetBSD: btdevctl.h,v 1.1 2006/08/13 09:03:23 plunky Exp $ */
+/* $NetBSD: btdevctl.h,v 1.2 2006/09/10 15:45:56 plunky Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -34,17 +34,14 @@
#ifndef __BTDEVCTL_H__
#define __BTDEVCTL_H__
-extern const char *control_file;
-extern const char *config_file;
+/* db.c */
+prop_dictionary_t db_get(bdaddr_t *, bdaddr_t *, const char *);
+int db_set(prop_dictionary_t, bdaddr_t *, bdaddr_t *, const char *);
-int cfg_print(int, char **);
-int cfg_query(int, char **);
-int cfg_remove(int, char **);
-int dev_attach(int, char **);
-int dev_detach(int, char **);
-int hid_parse(int, char **);
+/* print.c */
+void cfg_print(prop_dictionary_t);
-prop_dictionary_t read_config(void);
-int write_config(prop_dictionary_t);
+/* sdp.c */
+prop_dictionary_t cfg_query(bdaddr_t *, bdaddr_t *, const char *);
#endif /* __BTDEVCTL_H__ */
diff --git a/usr.sbin/btdevctl/db.c b/usr.sbin/btdevctl/db.c
new file mode 100644
index 00000000000..8badd6f57d0
--- /dev/null
+++ b/usr.sbin/btdevctl/db.c
@@ -0,0 +1,224 @@
+/* $NetBSD: db.c,v 1.1 2006/09/10 15:45:56 plunky Exp $ */
+
+/*-
+ * Copyright (c) 2006 Itronix Inc.
+ * All rights reserved.
+ *
+ * Written by Iain Hibbert for Itronix Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of Itronix Inc. may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: db.c,v 1.1 2006/09/10 15:45:56 plunky Exp $");
+
+#include <bluetooth.h>
+#include <err.h>
+#include <stdlib.h>
+
+#include <prop/proplib.h>
+
+#include <dev/bluetooth/btdev.h>
+#include <dev/bluetooth/btsco.h>
+
+#include "btdevctl.h"
+
+#define BTDEVCTL_PLIST "/var/db/btdevctl.plist"
+#define BTDEVCTL_VERSION 1
+
+static prop_dictionary_t db = NULL;
+static int db_flush = TRUE; /* write db on set */
+
+static void db_update0(void);
+
+/*
+ * lookup laddr/raddr/service in database and return dictionary
+ */
+prop_dictionary_t
+db_get(bdaddr_t *laddr, bdaddr_t *raddr, const char *service)
+{
+ prop_dictionary_t ldev, rdev, dev;
+ prop_object_t obj;
+
+ if (db == NULL) {
+ db = prop_dictionary_internalize_from_file(BTDEVCTL_PLIST);
+ if (db == NULL) {
+ db = prop_dictionary_create();
+ if (db == NULL)
+ err(EXIT_FAILURE, "prop_dictionary_create");
+
+ return NULL;
+ } else {
+ obj = prop_dictionary_get(db, "btdevctl-version");
+ switch(prop_number_integer_value(obj)) {
+ case 0:
+ db_update0();
+ break;
+
+ case BTDEVCTL_VERSION:
+ break;
+
+ default:
+ errx(EXIT_FAILURE, "unknown btdevctl-version");
+ }
+ }
+ }
+
+ ldev = prop_dictionary_get(db, bt_ntoa(laddr, NULL));
+ if (prop_object_type(ldev) != PROP_TYPE_DICTIONARY)
+ return NULL;
+
+ rdev = prop_dictionary_get(ldev, bt_ntoa(raddr, NULL));
+ if (prop_object_type(rdev) != PROP_TYPE_DICTIONARY)
+ return NULL;
+
+ dev = prop_dictionary_get(rdev, service);
+ if (prop_object_type(dev) != PROP_TYPE_DICTIONARY)
+ return NULL;
+
+ return dev;
+}
+
+/*
+ * store dictionary in database at laddr/raddr/service
+ */
+int
+db_set(prop_dictionary_t dev, bdaddr_t *laddr, bdaddr_t *raddr, const char *service)
+{
+ prop_dictionary_t ldev, rdev;
+ prop_number_t version;
+
+ ldev = prop_dictionary_get(db, bt_ntoa(laddr, NULL));
+ if (ldev == NULL) {
+ ldev = prop_dictionary_create();
+ if (ldev == NULL)
+ return 0;
+
+ if (!prop_dictionary_set(db, bt_ntoa(laddr, NULL), ldev))
+ return 0;
+
+ prop_object_release(ldev);
+ }
+
+ rdev = prop_dictionary_get(ldev, bt_ntoa(raddr, NULL));
+ if (rdev == NULL) {
+ rdev = prop_dictionary_create();
+ if (rdev == NULL)
+ return 0;
+
+ if (!prop_dictionary_set(ldev, bt_ntoa(raddr, NULL), rdev))
+ return 0;
+
+ prop_object_release(rdev);
+ }
+
+ if (!prop_dictionary_set(rdev, service, dev))
+ return 0;
+
+ if (db_flush == TRUE) {
+ version = prop_number_create_integer(BTDEVCTL_VERSION);
+ if (version == NULL)
+ err(EXIT_FAILURE, "prop_number_create_integer");
+
+ if (!prop_dictionary_set(db, "btdevctl-version", version))
+ err(EXIT_FAILURE, "prop_dictionary_set");
+
+ prop_object_release(version);
+
+ if (!prop_dictionary_externalize_to_file(db, BTDEVCTL_PLIST))
+ warn("%s", BTDEVCTL_PLIST);
+ }
+
+ return 1;
+}
+
+/*
+ * update database from version 0. This was a flat file using
+ * btdevN as an index, and local-bdaddr and remote-bdaddr stored
+ * as data objects. Step through and add them to the new dictionary.
+ * We have to generate the service, but only HID, HF and HSET
+ * were supported, so thats not too difficult.
+ */
+static void
+db_update0(void)
+{
+ prop_dictionary_t old, dev;
+ prop_dictionary_keysym_t key;
+ prop_object_iterator_t iter;
+ prop_object_t obj;
+ bdaddr_t laddr, raddr;
+ char *service;
+
+ db_flush = FALSE; /* no write on set */
+ old = db;
+
+ db = prop_dictionary_create();
+ if (db == NULL)
+ err(EXIT_FAILURE, "prop_dictionary_create");
+
+ iter = prop_dictionary_iterator(old);
+ if (iter == NULL)
+ err(EXIT_FAILURE, "prop_dictionary_iterator");
+
+ while ((key = prop_object_iterator_next(iter)) != NULL) {
+ dev = prop_dictionary_get_keysym(old, key);
+ if (prop_object_type(dev) != PROP_TYPE_DICTIONARY)
+ errx(EXIT_FAILURE, "invalid device dictionary");
+
+ obj = prop_dictionary_get(dev, BTDEVladdr);
+ if (prop_data_size(obj) != sizeof(laddr))
+ errx(EXIT_FAILURE, "invalid %s", BTDEVladdr);
+
+ bdaddr_copy(&laddr, prop_data_data_nocopy(obj));
+ prop_dictionary_remove(dev, BTDEVladdr);
+
+ obj = prop_dictionary_get(dev, BTDEVraddr);
+ if (prop_data_size(obj) != sizeof(raddr))
+ errx(EXIT_FAILURE, "invalid %s", BTDEVraddr);
+
+ bdaddr_copy(&raddr, prop_data_data_nocopy(obj));
+ prop_dictionary_remove(dev, BTDEVraddr);
+
+ obj = prop_dictionary_get(dev, BTDEVtype);
+ if (prop_string_equals_cstring(obj, "bthidev"))
+ service = "HID";
+ else if (prop_string_equals_cstring(obj, "btsco")) {
+ obj = prop_dictionary_get(dev, BTSCOlisten);
+ if (prop_bool_true(obj))
+ service = "HF";
+ else
+ service = "HSET";
+ } else
+ errx(EXIT_FAILURE, "invalid %s", BTDEVtype);
+
+ if (!db_set(dev, &laddr, &raddr, service))
+ err(EXIT_FAILURE, "service store failed");
+ }
+
+ prop_object_iterator_release(iter);
+ prop_object_release(old);
+
+ db_flush = TRUE; /* write on set */
+}
diff --git a/usr.sbin/btdevctl/dev.c b/usr.sbin/btdevctl/dev.c
deleted file mode 100644
index c897c185862..00000000000
--- a/usr.sbin/btdevctl/dev.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/* $NetBSD: dev.c,v 1.2 2006/08/17 20:18:23 plunky Exp $ */
-
-/*-
- * Copyright (c) 2006 Itronix Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of Itronix Inc. may not be used to endorse
- * or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__RCSID("$NetBSD: dev.c,v 1.2 2006/08/17 20:18:23 plunky Exp $");
-
-#include <sys/ioctl.h>
-#include <sys/param.h>
-#include <prop/proplib.h>
-#include <dev/bluetooth/btdev.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "btdevctl.h"
-
-int
-dev_attach(int ac, char **av)
-{
- prop_dictionary_t cfg, dev;
- char path[MAXPATHLEN];
- int fd, ch, quiet;
-
- quiet = 0;
-
- while ((ch = getopt(ac, av, "q")) != -1) {
- switch(ch) {
- case 'q':
- quiet = 1;
- break;
-
- default:
- errx(EXIT_FAILURE, "unkown option -%c", ch);
- }
- }
-
- cfg = read_config();
- if (cfg == NULL)
- err(EXIT_FAILURE, "%s", config_file);
-
- dev = prop_dictionary_get(cfg, control_file);
- if (dev == NULL || prop_object_type(dev) != PROP_TYPE_DICTIONARY) {
- if (quiet)
- exit(EXIT_FAILURE);
-
- errx(EXIT_FAILURE, "%s: no config entry", control_file);
- }
-
- snprintf(path, sizeof(path), "/dev/%s", control_file);
- fd = open(path, O_WRONLY, 0);
- if (fd < 0)
- err(EXIT_FAILURE, "%s", path);
-
- if (prop_dictionary_send_ioctl(dev, fd, BTDEV_ATTACH)) {
- if (quiet && errno == ENXIO)
- exit(EXIT_FAILURE);
-
- err(EXIT_FAILURE, "%s", path);
- }
-
- close(fd);
- prop_object_release(cfg);
- return EXIT_SUCCESS;
-}
-
-int
-dev_detach(int ac, char **av)
-{
- prop_dictionary_t dev;
- char path[MAXPATHLEN];
- int fd, ch, quiet;
-
- quiet = 0;
-
- while ((ch = getopt(ac, av, "q")) != -1) {
- switch(ch) {
- case 'q':
- quiet = 1;
- break;
-
- default:
- errx(EXIT_FAILURE, "unkown option -%c", ch);
- }
- }
-
- dev = prop_dictionary_create();
- if (dev == NULL)
- err(EXIT_FAILURE, "prop_dictionary_create");
-
- snprintf(path, sizeof(path), "/dev/%s", control_file);
- fd = open(path, O_WRONLY, 0);
- if (fd < 0)
- err(EXIT_FAILURE, "%s", path);
-
- if (prop_dictionary_send_ioctl(dev, fd, BTDEV_DETACH)) {
- if (quiet && errno == ENXIO)
- exit(EXIT_FAILURE);
-
- err(EXIT_FAILURE, "%s", path);
- }
-
- close(fd);
- prop_object_release(dev);
- return EXIT_SUCCESS;
-}
diff --git a/usr.sbin/btdevctl/hid.c b/usr.sbin/btdevctl/print.c
index 43edbaa2046..4160dfdb2fa 100644
--- a/usr.sbin/btdevctl/hid.c
+++ b/usr.sbin/btdevctl/print.c
@@ -1,9 +1,11 @@
-/* $NetBSD: hid.c,v 1.1 2006/08/13 09:03:23 plunky Exp $ */
+/* $NetBSD: print.c,v 1.1 2006/09/10 15:45:56 plunky Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
* All rights reserved.
*
+ * Written by Iain Hibbert for Itronix Inc.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -29,8 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
- * hid.c
- *
* Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
* All rights reserved.
*
@@ -55,55 +55,118 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: hid.c,v 1.1 2006/08/13 09:03:23 plunky Exp $
- * $FreeBSD: src/usr.sbin/bluetooth/bthidcontrol/hid.c,v 1.1 2004/04/10 00:18:00 emax Exp $
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: hid.c,v 1.1 2006/08/13 09:03:23 plunky Exp $");
+__RCSID("$NetBSD: print.c,v 1.1 2006/09/10 15:45:56 plunky Exp $");
+
+#include <sys/types.h>
+#include <dev/bluetooth/btdev.h>
+#include <dev/bluetooth/bthidev.h>
+#include <dev/bluetooth/btsco.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
+
#include <prop/proplib.h>
+#include <bluetooth.h>
#include <err.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <usbhid.h>
#include "btdevctl.h"
-static void hid_dump_item (char const *, struct hid_item *);
+static void cfg_bthidev(prop_dictionary_t dict);
+static void cfg_btsco(prop_dictionary_t dict);
+
+static void hid_dump_item(char const *, struct hid_item *);
+static void hid_parse(prop_data_t);
-int
-hid_parse(int ac, char **av)
+void
+cfg_print(prop_dictionary_t dict)
{
- prop_dictionary_t cfg, dev;
- prop_object_t desc;
- report_desc_t r;
- hid_data_t d;
- struct hid_item h;
+ prop_object_t obj;
- hid_init(NULL);
+ obj = prop_dictionary_get(dict, BTDEVladdr);
+ if (prop_object_type(obj) != PROP_TYPE_DATA) {
+ return;
+ }
+ printf("local bdaddr: %s\n", bt_ntoa(prop_data_data_nocopy(obj), NULL));
+
+ obj = prop_dictionary_get(dict, BTDEVraddr);
+ if (prop_object_type(obj) != PROP_TYPE_DATA) {
+ return;
+ }
+ printf("remote bdaddr: %s\n", bt_ntoa(prop_data_data_nocopy(obj), NULL));
+
+ obj = prop_dictionary_get(dict, BTDEVtype);
+ if (prop_object_type(obj) != PROP_TYPE_STRING) {
+ printf("No device type!\n");
+ return;
+ }
+ printf("device type: %s\n", prop_string_cstring(obj));
+
+ if (prop_string_equals_cstring(obj, "bthidev")) {
+ cfg_bthidev(dict);
+ return;
+ }
+
+ if (prop_string_equals_cstring(obj, "btsco")) {
+ cfg_btsco(dict);
+ return;
+ }
+
+ printf("Unknown device type!\n");
+}
+
+static void
+cfg_bthidev(prop_dictionary_t dict)
+{
+ prop_object_t obj;
+
+ obj = prop_dictionary_get(dict, BTHIDEVcontrolpsm);
+ if (prop_object_type(obj) == PROP_TYPE_NUMBER)
+ printf("control psm: 0x%4.4llx\n", prop_number_integer_value(obj));
- cfg = read_config();
- if (cfg == NULL)
- err(EXIT_FAILURE, "%s", config_file);
+ obj = prop_dictionary_get(dict, BTHIDEVinterruptpsm);
+ if (prop_object_type(obj) == PROP_TYPE_NUMBER)
+ printf("interrupt psm: 0x%4.4llx\n", prop_number_integer_value(obj));
- dev = prop_dictionary_get(cfg, control_file);
- if (dev == NULL)
- errx(EXIT_FAILURE, "%s: no config entry", control_file);
+ obj = prop_dictionary_get(dict, BTHIDEVreconnect);
+ if (prop_bool_true(obj))
+ printf("reconnect mode: TRUE\n");
+
+ obj = prop_dictionary_get(dict, BTHIDEVdescriptor);
+ if (prop_object_type(obj) == PROP_TYPE_DATA)
+ hid_parse(obj);
+}
+
+static void
+cfg_btsco(prop_dictionary_t dict)
+{
+ prop_object_t obj;
- if (prop_object_type(dev) != PROP_TYPE_DICTIONARY)
- errx(EXIT_FAILURE, "%s: not a dictionary", control_file);
+ obj = prop_dictionary_get(dict, BTSCOlisten);
+ printf("mode: %s\n", prop_bool_true(obj) ? "listen" : "connect");
- desc = prop_dictionary_get(dev, "descriptor");
- if (desc == NULL || prop_object_type(desc) != PROP_TYPE_DATA)
- errx(EXIT_FAILURE, "%s: no HID descriptor", control_file);
+ obj = prop_dictionary_get(dict, BTSCOchannel);
+ if (prop_object_type(obj) == PROP_TYPE_NUMBER)
+ printf("channel: %lld\n", prop_number_integer_value(obj));
+}
+
+static void
+hid_parse(prop_data_t desc)
+{
+ report_desc_t r;
+ hid_data_t d;
+ struct hid_item h;
+
+ hid_init(NULL);
- r = hid_use_report_desc((unsigned char *)prop_data_data_nocopy(desc), prop_data_size(desc));
+ r = hid_use_report_desc((unsigned char *)prop_data_data_nocopy(desc),
+ prop_data_size(desc));
if (r == NULL)
- errx(EXIT_FAILURE, "%s: Can't use HID descriptor", control_file);
+ return;
d = hid_start_parse(r, ~0, -1);
while (hid_get_item(d, &h)) {
@@ -134,8 +197,6 @@ hid_parse(int ac, char **av)
hid_end_parse(d);
hid_dispose_report_desc(r);
- prop_object_release(cfg);
- return EXIT_SUCCESS;
}
static void
diff --git a/usr.sbin/btdevctl/cfg.c b/usr.sbin/btdevctl/sdp.c
index 4040c5ede4b..7dbf08087e6 100644
--- a/usr.sbin/btdevctl/cfg.c
+++ b/usr.sbin/btdevctl/sdp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cfg.c,v 1.3 2006/08/27 11:41:58 plunky Exp $ */
+/* $NetBSD: sdp.c,v 1.1 2006/09/10 15:45:56 plunky Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -52,27 +52,26 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $Id: cfg.c,v 1.3 2006/08/27 11:41:58 plunky Exp $
- * $FreeBSD: src/usr.sbin/bluetooth/bthidcontrol/sdp.c,v 1.2 2006/02/10 19:54:17 markus Exp $
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: cfg.c,v 1.3 2006/08/27 11:41:58 plunky Exp $");
+__RCSID("$NetBSD: sdp.c,v 1.1 2006/09/10 15:45:56 plunky Exp $");
+
+#include <sys/types.h>
#include <dev/bluetooth/btdev.h>
+#include <dev/bluetooth/bthidev.h>
+#include <dev/bluetooth/btsco.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
+
#include <prop/proplib.h>
#include <bluetooth.h>
#include <err.h>
#include <errno.h>
#include <sdp.h>
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
#include <usbhid.h>
#include "btdevctl.h"
@@ -84,7 +83,7 @@ static int32_t parse_boolean(sdp_attr_t *);
static int config_hid(prop_dictionary_t);
static int config_hset(prop_dictionary_t);
-static int config_hfp(prop_dictionary_t);
+static int config_hf(prop_dictionary_t);
uint16_t hid_services[] = {
SDP_SERVICE_CLASS_HUMAN_INTERFACE_DEVICE
@@ -112,11 +111,11 @@ uint32_t hset_attrs[] = {
SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST),
};
-uint16_t hfp_services[] = {
+uint16_t hf_services[] = {
SDP_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY
};
-uint32_t hfp_attrs[] = {
+uint32_t hf_attrs[] = {
SDP_ATTR_RANGE( SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST,
SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST),
};
@@ -124,13 +123,13 @@ uint32_t hfp_attrs[] = {
#define NUM(v) (sizeof(v) / sizeof(v[0]))
static struct {
- const char *name;
- int (*handler)(prop_dictionary_t);
- const char *description;
- uint16_t *services;
- int nservices;
- uint32_t *attrs;
- int nattrs;
+ const char *name;
+ int (*handler)(prop_dictionary_t);
+ const char *description;
+ uint16_t *services;
+ int nservices;
+ uint32_t *attrs;
+ int nattrs;
} cfgtype[] = {
{
"HID", config_hid, "Human Interface Device",
@@ -143,103 +142,25 @@ static struct {
hset_attrs, NUM(hset_attrs),
},
{
- "HFP", config_hfp, "Hands Free Profile",
- hfp_services, NUM(hfp_services),
- hfp_attrs, NUM(hfp_attrs),
+ "HF", config_hf, "Handsfree",
+ hf_services, NUM(hf_services),
+ hf_attrs, NUM(hf_attrs),
},
};
static sdp_attr_t values[8];
static uint8_t buffer[NUM(values)][512];
-int
-cfg_print(int ac, char **av)
-{
- prop_dictionary_t cfg, dev;
- char *xml;
-
- cfg = read_config();
- if (cfg == NULL)
- return EXIT_FAILURE;
-
- dev = prop_dictionary_get(cfg, control_file);
- if (dev == NULL)
- errx(EXIT_FAILURE, "%s not found", control_file);
-
- if (prop_object_type(dev) != PROP_TYPE_DICTIONARY)
- errx(EXIT_FAILURE, "%s invalid config", control_file);
-
- xml = prop_dictionary_externalize(dev);
- if (xml == NULL)
- err(EXIT_FAILURE, "prop_dictionary_externalize");
-
- printf("%s", xml);
-
- free(xml);
- prop_object_release(cfg);
- return EXIT_SUCCESS;
-}
-
-int
-cfg_query(int ac, char **av)
+prop_dictionary_t
+cfg_query(bdaddr_t *laddr, bdaddr_t *raddr, const char *service)
{
- bdaddr_t laddr, raddr;
- prop_dictionary_t cfg, dev;
- prop_object_t obj;
- void *ss;
- char *service;
- int rv, i, ch;
-
- bdaddr_copy(&laddr, BDADDR_ANY);
- bdaddr_copy(&raddr, BDADDR_ANY);
- service = NULL;
-
- while ((ch = getopt(ac, av, "a:d:s:")) != -1) {
- switch (ch) {
- case 'a': /* remote address */
- if (!bt_aton(optarg, &raddr)) {
- struct hostent *he = NULL;
-
- if ((he = bt_gethostbyname(optarg)) == NULL)
- errx(EXIT_FAILURE, "%s: %s",
- optarg, hstrerror(h_errno));
-
- bdaddr_copy(&raddr, (bdaddr_t *)he->h_addr);
- }
- break;
-
- case 'd': /* local device address */
- if (!bt_devaddr(optarg, &laddr))
- err(EXIT_FAILURE, "%s", optarg);
+ prop_dictionary_t dict;
+ void *ss;
+ int rv, i;
- break;
-
- case 's': /* service */
- service = optarg;
- break;
-
- default:
- err(EXIT_FAILURE, "unknown option -%c", ch);
- }
- }
-
- if (bdaddr_any(&raddr))
- errx(EXIT_FAILURE, "must specify remote device address");
-
- if (service == NULL)
- errx(EXIT_FAILURE, "must specify service to configure");
-
- dev = prop_dictionary_create();
- if (dev == NULL)
- err(EXIT_FAILURE, "prop_dictinary_create");
-
- obj = prop_data_create_data_nocopy(&laddr, sizeof(laddr));
- if (obj == NULL || !prop_dictionary_set(dev, "local-bdaddr", obj))
- err(EXIT_FAILURE, "proplib");;
-
- obj = prop_data_create_data_nocopy(&raddr, sizeof(raddr));
- if (obj == NULL || !prop_dictionary_set(dev, "remote-bdaddr", obj))
- err(EXIT_FAILURE, "proplib");;
+ dict = prop_dictionary_create();
+ if (dict == NULL)
+ return NULL;
for (i = 0 ; i < NUM(values) ; i++) {
values[i].flags = SDP_ATTR_INVALID;
@@ -250,10 +171,10 @@ cfg_query(int ac, char **av)
for (i = 0 ; i < NUM(cfgtype) ; i++) {
if (strcasecmp(service, cfgtype[i].name) == 0) {
- ss = sdp_open(&laddr, &raddr);
+ ss = sdp_open(laddr, raddr);
if (ss == NULL || (errno = sdp_error(ss)) != 0)
- err(EXIT_FAILURE, "sdp_open");
+ return NULL;
rv = sdp_search(ss,
cfgtype[i].nservices, cfgtype[i].services,
@@ -262,29 +183,15 @@ cfg_query(int ac, char **av)
if (rv != 0) {
errno = sdp_error(ss);
- err(EXIT_FAILURE, "sdp_search");
+ return NULL;
}
sdp_close(ss);
- rv = (*cfgtype[i].handler)(dev);
+ rv = (*cfgtype[i].handler)(dict);
if (rv != 0)
- errx(EXIT_FAILURE, "%s: %s", cfgtype[i].name, strerror(rv));
-
- cfg = read_config();
- if (cfg == NULL && errno == ENOENT)
- cfg = prop_dictionary_create();
-
- if (cfg == NULL)
- err(EXIT_FAILURE, "%s", config_file);
-
- if (!prop_dictionary_set(cfg, control_file, dev))
- err(EXIT_FAILURE, "prop_dictionary_set");
+ return NULL;
- if (!write_config(cfg))
- err(EXIT_FAILURE, "%s", config_file);
-
- prop_object_release(cfg);
- return EXIT_SUCCESS;
+ return dict;
}
}
@@ -292,29 +199,7 @@ cfg_query(int ac, char **av)
for (i = 0 ; i < NUM(cfgtype) ; i++)
printf("\t%s\t%s\n", cfgtype[i].name, cfgtype[i].description);
- return EXIT_FAILURE;
-}
-
-int
-cfg_remove(int ac, char **av)
-{
- prop_dictionary_t cfg, dev;
-
- cfg = read_config();
- if (cfg == NULL)
- return EXIT_FAILURE;
-
- dev = prop_dictionary_get(cfg, control_file);
- if (dev == NULL)
- errx(EXIT_FAILURE, "%s not found", control_file);
-
- prop_dictionary_remove(cfg, control_file);
-
- if (!write_config(cfg))
- err(EXIT_FAILURE, "%s", config_file);
-
- prop_object_release(cfg);
- return EXIT_SUCCESS;
+ exit(EXIT_FAILURE);
}
/*
@@ -380,24 +265,24 @@ config_hid(prop_dictionary_t dict)
return ENOATTR;
obj = prop_string_create_cstring_nocopy("bthidev");
- if (obj == NULL || !prop_dictionary_set(dict, "device-type", obj))
+ if (obj == NULL || !prop_dictionary_set(dict, BTDEVtype, obj))
return errno;
obj = prop_number_create_integer(control_psm);
- if (obj == NULL || !prop_dictionary_set(dict, "control-psm", obj))
+ if (obj == NULL || !prop_dictionary_set(dict, BTHIDEVcontrolpsm, obj))
return errno;
obj = prop_number_create_integer(interrupt_psm);
- if (obj == NULL || !prop_dictionary_set(dict, "interrupt-psm", obj))
+ if (obj == NULL || !prop_dictionary_set(dict, BTHIDEVinterruptpsm, obj))
return errno;
obj = prop_data_create_data(hid_descriptor, hid_length);
- if (obj == NULL || !prop_dictionary_set(dict, "descriptor", obj))
+ if (obj == NULL || !prop_dictionary_set(dict, BTHIDEVdescriptor, obj))
return errno;
if (!reconnect_initiate) {
obj = prop_bool_create(TRUE);
- if (obj == NULL || !prop_dictionary_set(dict, "reconnect", obj))
+ if (obj == NULL || !prop_dictionary_set(dict, BTHIDEVreconnect, obj))
return errno;
}
@@ -431,21 +316,21 @@ config_hset(prop_dictionary_t dict)
return ENOATTR;
obj = prop_string_create_cstring_nocopy("btsco");
- if (obj == NULL || !prop_dictionary_set(dict, "device-type", obj))
+ if (obj == NULL || !prop_dictionary_set(dict, BTDEVtype, obj))
return errno;
obj = prop_number_create_integer(channel);
- if (obj == NULL || !prop_dictionary_set(dict, "rfcomm-channel", obj))
+ if (obj == NULL || !prop_dictionary_set(dict, BTSCOchannel, obj))
return errno;
return 0;
}
/*
- * Configure HFP results
+ * Configure HF results
*/
static int
-config_hfp(prop_dictionary_t dict)
+config_hf(prop_dictionary_t dict)
{
prop_object_t obj;
uint32_t channel;
@@ -468,15 +353,15 @@ config_hfp(prop_dictionary_t dict)
return ENOATTR;
obj = prop_string_create_cstring_nocopy("btsco");
- if (obj == NULL || !prop_dictionary_set(dict, "device-type", obj))
+ if (obj == NULL || !prop_dictionary_set(dict, BTDEVtype, obj))
return errno;
obj = prop_bool_create(TRUE);
- if (obj == NULL || !prop_dictionary_set(dict, "listen", obj))
+ if (obj == NULL || !prop_dictionary_set(dict, BTSCOlisten, obj))
return errno;
obj = prop_number_create_integer(channel);
- if (obj == NULL || !prop_dictionary_set(dict, "rfcomm-channel", obj))
+ if (obj == NULL || !prop_dictionary_set(dict, BTSCOchannel, obj))
return errno;
return 0;