* Re: [PATCH] Fix parsing of "Flags" AD type
From: Johan Hedberg @ 2011-02-15 14:25 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <1297705009-12848-1-git-send-email-anderson.lizardo@openbossa.org>
Hi Lizardo,
On Mon, Feb 14, 2011, Anderson Lizardo wrote:
> If an advertising report did not contain a "Flags" AD Type (e.g. a Scan
> response), the previous flags value was mistakenly set to 0x00. This fix
> makes sure dev->flags is only updated for valid values.
> ---
> src/adapter.c | 5 +++--
> src/adapter.h | 2 +-
> src/event.c | 4 +++-
> 3 files changed, 7 insertions(+), 4 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] src: fix typo
From: Johan Hedberg @ 2011-02-15 14:26 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
In-Reply-To: <1297719284-13410-1-git-send-email-padovan@profusion.mobi>
Hi Gustavo,
On Mon, Feb 14, 2011, Gustavo F. Padovan wrote:
> ---
> src/event.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/event.c b/src/event.c
> index 0659fd1..a415468 100644
> --- a/src/event.c
> +++ b/src/event.c
> @@ -731,7 +731,7 @@ void btd_event_le_set_scan_enable_complete(bdaddr_t *local, uint8_t status)
> }
>
> if (status) {
> - error("Can't enabled/disable LE scan");
> + error("Can't enable/disable LE scan");
> return;
> }
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* [PATCH 2/2] Add Write Request operation in gatttool
From: Bruna Moreira @ 2011-02-15 14:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
Add option and callbacks for Write Request operation in gatttool.
---
attrib/gatttool.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 60 insertions(+), 1 deletions(-)
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 8e8ed8e..b9f0087 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -63,6 +63,7 @@ static gboolean opt_listen = FALSE;
static gboolean opt_char_desc = FALSE;
static gboolean opt_le = FALSE;
static gboolean opt_char_write = FALSE;
+static gboolean opt_char_write_req = FALSE;
static GMainLoop *event_loop;
static gboolean got_error = FALSE;
@@ -436,6 +437,59 @@ error:
return FALSE;
}
+static void char_write_req_cb(guint8 status, const guint8 *pdu, guint16 plen,
+ gpointer user_data)
+{
+ if (status != 0) {
+ g_printerr("Characteristic Write Request failed: "
+ "%s\n", att_ecode2str(status));
+ goto done;
+ }
+
+ if (!dec_write_resp(pdu, plen)) {
+ g_printerr("Protocol error\n");
+ goto done;
+ }
+
+ g_print("Characteristic value was written sucessfully\n");
+
+done:
+ if (opt_listen == FALSE)
+ g_main_loop_quit(event_loop);
+}
+
+static gboolean characteristics_write_req(gpointer user_data)
+{
+ GAttrib *attrib = user_data;
+ uint8_t *value;
+ size_t len;
+
+ if (opt_handle <= 0) {
+ g_printerr("A valid handle is required\n");
+ goto error;
+ }
+
+ if (opt_value == NULL || opt_value[0] == '\0') {
+ g_printerr("A value is required\n");
+ goto error;
+ }
+
+ len = attr_data_from_string(opt_value, &value);
+ if (len == 0) {
+ g_printerr("Invalid value\n");
+ goto error;
+ }
+
+ gatt_write_char(attrib, opt_handle, value, len, char_write_req_cb,
+ NULL);
+
+ return FALSE;
+
+error:
+ g_main_loop_quit(event_loop);
+ return FALSE;
+}
+
static void char_desc_cb(guint8 status, const guint8 *pdu, guint16 plen,
gpointer user_data)
{
@@ -530,7 +584,10 @@ static GOptionEntry gatt_options[] = {
{ "char-read", 0, 0, G_OPTION_ARG_NONE, &opt_char_read,
"Characteristics Value/Descriptor Read", NULL },
{ "char-write", 0, 0, G_OPTION_ARG_NONE, &opt_char_write,
- "Characteristics Value Write", NULL },
+ "Characteristics Value Write Without Response (Write Command)",
+ NULL },
+ { "char-write-req", 0, 0, G_OPTION_ARG_NONE, &opt_char_write_req,
+ "Characteristics Value Write (Write Request)", NULL },
{ "char-desc", 0, 0, G_OPTION_ARG_NONE, &opt_char_desc,
"Characteristics Descriptor Discovery", NULL },
{ "listen", 0, 0, G_OPTION_ARG_NONE, &opt_listen,
@@ -602,6 +659,8 @@ int main(int argc, char *argv[])
callback = characteristics_read;
else if (opt_char_write)
callback = characteristics_write;
+ else if (opt_char_write_req)
+ callback = characteristics_write_req;
else if (opt_char_desc)
callback = characteristics_desc;
else {
--
1.7.0.4
^ permalink raw reply related
* Re: [PATCH 1/2] Add encode/decode for write response
From: Johan Hedberg @ 2011-02-15 14:48 UTC (permalink / raw)
To: Bruna Moreira; +Cc: linux-bluetooth
In-Reply-To: <1297779409-32597-1-git-send-email-bruna.moreira@openbossa.org>
Hi Bruna,
On Tue, Feb 15, 2011, Bruna Moreira wrote:
> The encode/decode functions for Write Response operations were created
> to keep consistency with the rest of GATT API.
> ---
> attrib/att.c | 21 +++++++++++++++++++++
> attrib/att.h | 2 ++
> src/attrib-server.c | 4 +---
> 3 files changed, 24 insertions(+), 3 deletions(-)
Both patches have been pushed upstream. Thanks.
Johan
^ permalink raw reply
* [RFC -v3] Bluetooth: add BT_CONNINFO socketopt
From: Gustavo F. Padovan @ 2011-02-15 15:05 UTC (permalink / raw)
To: linux-bluetooth
ATT needs to know to link key type before run some of it procedures.
Using the socket sec_level doesn't work because the socket may not reflect
the real sec_level of the link.
Reported-by: Anderson Lizardo <anderson.lizardo@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
include/net/bluetooth/bluetooth.h | 5 +++++
net/bluetooth/l2cap_sock.c | 16 ++++++++++++++++
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 4375043..be7a8ee 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -66,6 +66,11 @@ struct bt_security {
#define BT_FLUSHABLE 8
+#define BT_CONNINFO 9
+struct bt_conninfo {
+ __u8 sec_level;
+};
+
#define BT_FLUSHABLE_OFF 0
#define BT_FLUSHABLE_ON 1
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 484e717..f09fd97 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -467,7 +467,9 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us
static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen)
{
struct sock *sk = sock->sk;
+ struct hci_conn *hcon = l2cap_pi(sk)->conn->hcon;
struct bt_security sec;
+ struct bt_conninfo conninfo;
int len, err = 0;
BT_DBG("sk %p", sk);
@@ -516,6 +518,20 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
break;
+ case BT_CONNINFO:
+ if (sk->sk_state != BT_CONNECTED) {
+ err = -EINVAL;
+ break;
+ }
+
+ conninfo.sec_level = hcon->sec_level;
+
+ len = min_t(unsigned int, len, sizeof(conninfo));
+ if (copy_to_user(optval, (char *) &conninfo, len))
+ err = -EFAULT;
+
+ break;
+
default:
err = -ENOPROTOOPT;
break;
--
1.7.4
^ permalink raw reply related
* How can I write a virtual BT device?
From: Massimo Messore @ 2011-02-15 16:09 UTC (permalink / raw)
To: linux-bluetooth
Hi all.
Is it possible to write a local application that simulates a virtual BT
device (i.e. GPS, hands free, ecc.)?
I basically want to run such application on my PC and then run "hcitool
scan" on the same PC and discover also the virtual device exposed by the
application.
If this is feasible, can you please point me to the main component of BlueZ
I should look at?
Thanks in advance.
Massimo
^ permalink raw reply
* Re: bluetooth disabled with current 2.6.38-rc4
From: Justin Mattock @ 2011-02-15 16:20 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20110215135245.GA11561@jh-x301>
On Feb 15, 2011, at 5:52 AM, Johan Hedberg wrote:
> Hi Justin,
>
> On Sun, Feb 13, 2011, Justin Mattock wrote:
>> maybe I missed something, but my bluetooth is just not functioning
>> with
>> 2.6.38-rc4(works with 2.6.37-rc4)
>>
>> I've done a bisect on this, but was pointed to:
>> c0e45c1ca3162acb2e77b3d9e152ce6e7b6fa3f5
>> but doesn't look correct to me
>>
>> here is what I am seeing with the bluetooth-applet etc..:
>>
>> working correctly:
>> http://www.flickr.com/photos/44066293@N08/5443727238/
>>
>> not working:
>> http://www.flickr.com/photos/44066293@N08/5443124859/
>>
>> my /var/log/daemon.log shows:
>>
>> Feb 13 17:12:22 Linux-2 acpid: 1 client rule loaded
>> Feb 13 17:12:23 Linux-2 bluetoothd[1950]: HCI dev 0 registered
>> Feb 13 17:12:23 Linux-2 bluetoothd[1950]: Listening for HCI events
>> on hci0
>> Feb 13 17:12:23 Linux-2 bluetoothd[1950]: HCI dev 0 up
>> Feb 13 17:12:23 Linux-2 bluetoothd[1950]: Unable to find matching
>> adapter
>>
>> I can try at another bisect, but might take some time.. let me know
>> if there is something I can test
>> or do.
>
> Are you sure this is a kernel problem? There was a similar issue with
> BlueZ 4.86 or 4.87 which was already fixed. Could you try with 4.88?
>
> Johan
yeah Ill give the latest a try(currently using 4.82)
Justin P. Mattock
^ permalink raw reply
* Re: [PATCH 1/3] Fixed def of ATT_UUID per BT Assigned Numbers
From: Johan Hedberg @ 2011-02-15 17:08 UTC (permalink / raw)
To: Brian Gix; +Cc: linux-bluetooth, padovan
In-Reply-To: <1297891081-27976-2-git-send-email-bgix@codeaurora.org>
Hi Brian,
On Wed, Feb 16, 2011, Brian Gix wrote:
> ---
> lib/sdp.h | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
I've pushed this patch upstream but will wait for the other ones since
there were some comments regarding them.
Johan
^ permalink raw reply
* [PATCH v4] Add an initial interactive mode to gatttool
From: Sheldon Demario @ 2011-02-15 17:09 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <20110209212642.GA11368@jh-x301>
Mode required to allow better GATT procedures control. Some scenarios
require sequential commands without disconnection and delay between
operations. It is also desirable to change some connection parameters
of an active connection.
---
Makefile.am | 8 ++-
attrib/gatttool.c | 9 ++++
attrib/gatttool.h | 24 +++++++++
attrib/interactive.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++
configure.ac | 1 +
5 files changed, 168 insertions(+), 2 deletions(-)
create mode 100644 attrib/gatttool.h
create mode 100644 attrib/interactive.c
diff --git a/Makefile.am b/Makefile.am
index 275f511..7e5d0ee 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -175,12 +175,16 @@ builtin_sources += plugins/service.c
endif
if ATTRIBPLUGIN
+
+if READLINE
bin_PROGRAMS += attrib/gatttool
attrib_gatttool_SOURCES = attrib/gatttool.c attrib/att.c attrib/gatt.c \
attrib/gattrib.c btio/btio.c \
- src/glib-helper.h src/glib-helper.c
-attrib_gatttool_LDADD = lib/libbluetooth.la @GLIB_LIBS@
+ src/glib-helper.h src/glib-helper.c \
+ attrib/gatttool.h attrib/interactive.c
+attrib_gatttool_LDADD = lib/libbluetooth.la @GLIB_LIBS@ @READLINE_LIBS@
+endif
builtin_modules += attrib
builtin_sources += attrib/main.c \
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index b9f0087..c3d0472 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -42,6 +42,7 @@
#include "gattrib.h"
#include "glib-helper.h"
#include "gatt.h"
+#include "gatttool.h"
/* Minimum MTU for L2CAP connections over BR/EDR */
#define ATT_MIN_MTU_L2CAP 48
@@ -64,6 +65,7 @@ static gboolean opt_char_desc = FALSE;
static gboolean opt_le = FALSE;
static gboolean opt_char_write = FALSE;
static gboolean opt_char_write_req = FALSE;
+static gboolean opt_interactive = FALSE;
static GMainLoop *event_loop;
static gboolean got_error = FALSE;
@@ -594,6 +596,8 @@ static GOptionEntry gatt_options[] = {
"Listen for notifications and indications", NULL },
{ "le", 0, 0, G_OPTION_ARG_NONE, &opt_le,
"Use Bluetooth Low Energy transport", NULL },
+ { "interactive", 'I', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
+ &opt_interactive, "Use interactive mode", NULL },
{ NULL },
};
@@ -651,6 +655,11 @@ int main(int argc, char *argv[])
g_error_free(gerr);
}
+ if (opt_interactive) {
+ interactive();
+ goto done;
+ }
+
if (opt_primary)
callback = primary;
else if (opt_characteristics)
diff --git a/attrib/gatttool.h b/attrib/gatttool.h
new file mode 100644
index 0000000..ed5d9d6
--- /dev/null
+++ b/attrib/gatttool.h
@@ -0,0 +1,24 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2011 Nokia Corporation
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+int interactive(void);
diff --git a/attrib/interactive.c b/attrib/interactive.c
new file mode 100644
index 0000000..0653609
--- /dev/null
+++ b/attrib/interactive.c
@@ -0,0 +1,128 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2011 Nokia Corporation
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+#include <strings.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <glib.h>
+
+#include <readline/readline.h>
+#include <readline/history.h>
+
+#include "gatttool.h"
+
+static GMainLoop *event_loop;
+
+static void cmd_help(int argcp, char **argvp);
+
+static void cmd_exit(int argcp, char **argvp)
+{
+ rl_callback_handler_remove();
+ g_main_loop_quit(event_loop);
+}
+
+static struct {
+ const char *cmd;
+ void (*func)(int argcp, char **argvp);
+ const char *desc;
+} commands[] = {
+ { "help", cmd_help, "Show this help"},
+ { "exit", cmd_exit, "Exit interactive mode"},
+ { NULL, NULL, NULL}
+};
+
+static void cmd_help(int argcp, char **argvp)
+{
+ int i;
+
+ for (i = 0; commands[i].cmd; i++)
+ printf("%-12s\t%s\n", commands[i].cmd, commands[i].desc);
+}
+
+static void parse_line(char *line_read)
+{
+ gchar **argvp;
+ int argcp;
+ int i;
+
+ if (line_read == NULL) {
+ printf("\n");
+ cmd_exit(0, NULL);
+ return;
+ }
+
+ line_read = g_strstrip(line_read);
+
+ if (*line_read == '\0')
+ return;
+
+ add_history(line_read);
+
+ g_shell_parse_argv(line_read, &argcp, &argvp, NULL);
+
+ for (i = 0; commands[i].cmd; i++)
+ if (strcasecmp(commands[i].cmd, argvp[0]) == 0)
+ break;
+
+ if (commands[i].cmd)
+ commands[i].func(argcp, argvp);
+ else
+ printf("%s: command not found\n", argvp[0]);
+
+ g_strfreev(argvp);
+}
+
+static gboolean prompt_read(GIOChannel *chan, GIOCondition cond,
+ gpointer user_data)
+{
+ if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
+ g_io_channel_unref(chan);
+ return FALSE;
+ }
+
+ rl_callback_read_char();
+
+ return TRUE;
+}
+
+int interactive(void)
+{
+ GIOChannel *pchan;
+ gint events;
+
+ event_loop = g_main_loop_new(NULL, FALSE);
+
+ pchan = g_io_channel_unix_new(fileno(stdin));
+ g_io_channel_set_close_on_unref(pchan, TRUE);
+ events = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
+ g_io_add_watch(pchan, events, prompt_read, NULL);
+
+ rl_callback_handler_install("> ", parse_line);
+
+ g_main_loop_run(event_loop);
+
+ rl_callback_handler_remove();
+ g_io_channel_unref(pchan);
+ g_main_loop_unref(event_loop);
+
+ return 0;
+}
diff --git a/configure.ac b/configure.ac
index 88dd177..0002af2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,6 +42,7 @@ AC_PATH_GSTREAMER
AC_PATH_USB
AC_PATH_SNDFILE
AC_PATH_OUI
+AC_PATH_READLINE
AC_ARG_BLUEZ
--
1.7.1
^ permalink raw reply related
* Re: [PATCH v3 1/3] Include check to readline lib on acinlude.m4
From: Johan Hedberg @ 2011-02-15 17:20 UTC (permalink / raw)
To: Sheldon Demario; +Cc: linux-bluetooth
In-Reply-To: <1297696040-16453-1-git-send-email-sheldon.demario@openbossa.org>
Hi Sheldon,
On Mon, Feb 14, 2011, Sheldon Demario wrote:
> ---
> acinclude.m4 | 10 ++++++++++
> 1 files changed, 10 insertions(+), 0 deletions(-)
All three patches (v4 of 2/3) have been pushed upstream. Thanks.
Johan
^ permalink raw reply
* [PATCH] Move HealthManager Interface to "/" path
From: Gustavo F. Padovan @ 2011-02-15 19:31 UTC (permalink / raw)
To: linux-bluetooth
Yeah, this breaks the API, but health is still disabled by default and it
is not a good idea create a new path only for it. So moving it to "/"
---
doc/health-api.txt | 2 +-
health/hdp.c | 4 ++--
test/test-health | 2 +-
test/test-health-sink | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/doc/health-api.txt b/doc/health-api.txt
index 3d0a717..9d5a54d 100644
--- a/doc/health-api.txt
+++ b/doc/health-api.txt
@@ -10,7 +10,7 @@ Health Device Profile hierarchy
Service org.bluez
Interface org.bluez.HealthManager
-Object path /org/bluez/
+Object path /
Methods:
diff --git a/health/hdp.c b/health/hdp.c
index d4a2a30..e58bd55 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -2171,7 +2171,7 @@ int hdp_manager_start(DBusConnection *conn)
{
DBG("Starting Health manager");
- if (!g_dbus_register_interface(conn, MANAGER_PATH,
+ if (!g_dbus_register_interface(conn, "/",
HEALTH_MANAGER,
health_manager_methods, NULL, NULL,
NULL, manager_path_unregister)) {
@@ -2186,7 +2186,7 @@ int hdp_manager_start(DBusConnection *conn)
void hdp_manager_stop()
{
- g_dbus_unregister_interface(connection, MANAGER_PATH, HEALTH_MANAGER);
+ g_dbus_unregister_interface(connection, "/", HEALTH_MANAGER);
dbus_connection_unref(connection);
DBG("Stopped Health manager");
diff --git a/test/test-health b/test/test-health
index 28cc894..7820a24 100755
--- a/test/test-health
+++ b/test/test-health
@@ -47,7 +47,7 @@ def enter_mainloop():
finally:
print "Exiting, bye"
-hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
+hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.bluez.HealthManager")
role = None
diff --git a/test/test-health-sink b/test/test-health-sink
index cb9d434..50eb74c 100755
--- a/test/test-health-sink
+++ b/test/test-health-sink
@@ -12,7 +12,7 @@ loop = gobject.MainLoop()
bus = dbus.SystemBus()
-hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
+hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.bluez.HealthManager")
app_path = hdp_manager.CreateApplication({"DataType": dbus.types.UInt16(4103),
"Role": "sink"})
--
1.7.4
^ permalink raw reply related
* Re: [PATCH] Move HealthManager Interface to "/" path
From: Luiz Augusto von Dentz @ 2011-02-15 19:35 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
In-Reply-To: <1297798306-32591-1-git-send-email-padovan@profusion.mobi>
Hi,
On Tue, Feb 15, 2011 at 9:31 PM, Gustavo F. Padovan
<padovan@profusion.mobi> wrote:
> Yeah, this breaks the API, but health is still disabled by default and it
> is not a good idea create a new path only for it. So moving it to "/"
> ---
> doc/health-api.txt | 2 +-
> health/hdp.c | 4 ++--
> test/test-health | 2 +-
> test/test-health-sink | 2 +-
> 4 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/doc/health-api.txt b/doc/health-api.txt
> index 3d0a717..9d5a54d 100644
> --- a/doc/health-api.txt
> +++ b/doc/health-api.txt
> @@ -10,7 +10,7 @@ Health Device Profile hierarchy
>
> Service org.bluez
> Interface org.bluez.HealthManager
> -Object path /org/bluez/
> +Object path /
>
> Methods:
>
> diff --git a/health/hdp.c b/health/hdp.c
> index d4a2a30..e58bd55 100644
> --- a/health/hdp.c
> +++ b/health/hdp.c
> @@ -2171,7 +2171,7 @@ int hdp_manager_start(DBusConnection *conn)
> {
> DBG("Starting Health manager");
>
> - if (!g_dbus_register_interface(conn, MANAGER_PATH,
> + if (!g_dbus_register_interface(conn, "/",
> HEALTH_MANAGER,
> health_manager_methods, NULL, NULL,
> NULL, manager_path_unregister)) {
> @@ -2186,7 +2186,7 @@ int hdp_manager_start(DBusConnection *conn)
>
> void hdp_manager_stop()
> {
> - g_dbus_unregister_interface(connection, MANAGER_PATH, HEALTH_MANAGER);
> + g_dbus_unregister_interface(connection, "/", HEALTH_MANAGER);
>
> dbus_connection_unref(connection);
> DBG("Stopped Health manager");
> diff --git a/test/test-health b/test/test-health
> index 28cc894..7820a24 100755
> --- a/test/test-health
> +++ b/test/test-health
> @@ -47,7 +47,7 @@ def enter_mainloop():
> finally:
> print "Exiting, bye"
>
> -hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
> +hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/"),
> "org.bluez.HealthManager")
>
> role = None
> diff --git a/test/test-health-sink b/test/test-health-sink
> index cb9d434..50eb74c 100755
> --- a/test/test-health-sink
> +++ b/test/test-health-sink
> @@ -12,7 +12,7 @@ loop = gobject.MainLoop()
>
> bus = dbus.SystemBus()
>
> -hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
> +hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/"),
> "org.bluez.HealthManager")
> app_path = hdp_manager.CreateApplication({"DataType": dbus.types.UInt16(4103),
> "Role": "sink"})
> --
> 1.7.4
Any reasons why this is not per adapter? This is supposed to be very
similar to Media API which is used in a per adapter fashion.
--
Luiz Augusto von Dentz
Computer Engineer
^ permalink raw reply
* Re: [PATCH] Move HealthManager Interface to "/" path
From: Gustavo F. Padovan @ 2011-02-15 19:59 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <AANLkTimDQtwuYvdLYr3mTXygHLHYaQCCrFC6LYj6ajHT@mail.gmail.com>
Hi Luiz,
* Luiz Augusto von Dentz <luiz.dentz@gmail.com> [2011-02-15 21:35:20 +0200]:
> Hi,
>
> On Tue, Feb 15, 2011 at 9:31 PM, Gustavo F. Padovan
> <padovan@profusion.mobi> wrote:
> > Yeah, this breaks the API, but health is still disabled by default and it
> > is not a good idea create a new path only for it. So moving it to "/"
> > ---
> > doc/health-api.txt | 2 +-
> > health/hdp.c | 4 ++--
> > test/test-health | 2 +-
> > test/test-health-sink | 2 +-
> > 4 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/doc/health-api.txt b/doc/health-api.txt
> > index 3d0a717..9d5a54d 100644
> > --- a/doc/health-api.txt
> > +++ b/doc/health-api.txt
> > @@ -10,7 +10,7 @@ Health Device Profile hierarchy
> >
> > Service org.bluez
> > Interface org.bluez.HealthManager
> > -Object path /org/bluez/
> > +Object path /
> >
> > Methods:
> >
> > diff --git a/health/hdp.c b/health/hdp.c
> > index d4a2a30..e58bd55 100644
> > --- a/health/hdp.c
> > +++ b/health/hdp.c
> > @@ -2171,7 +2171,7 @@ int hdp_manager_start(DBusConnection *conn)
> > {
> > DBG("Starting Health manager");
> >
> > - if (!g_dbus_register_interface(conn, MANAGER_PATH,
> > + if (!g_dbus_register_interface(conn, "/",
> > HEALTH_MANAGER,
> > health_manager_methods, NULL, NULL,
> > NULL, manager_path_unregister)) {
> > @@ -2186,7 +2186,7 @@ int hdp_manager_start(DBusConnection *conn)
> >
> > void hdp_manager_stop()
> > {
> > - g_dbus_unregister_interface(connection, MANAGER_PATH, HEALTH_MANAGER);
> > + g_dbus_unregister_interface(connection, "/", HEALTH_MANAGER);
> >
> > dbus_connection_unref(connection);
> > DBG("Stopped Health manager");
> > diff --git a/test/test-health b/test/test-health
> > index 28cc894..7820a24 100755
> > --- a/test/test-health
> > +++ b/test/test-health
> > @@ -47,7 +47,7 @@ def enter_mainloop():
> > finally:
> > print "Exiting, bye"
> >
> > -hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
> > +hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/"),
> > "org.bluez.HealthManager")
> >
> > role = None
> > diff --git a/test/test-health-sink b/test/test-health-sink
> > index cb9d434..50eb74c 100755
> > --- a/test/test-health-sink
> > +++ b/test/test-health-sink
> > @@ -12,7 +12,7 @@ loop = gobject.MainLoop()
> >
> > bus = dbus.SystemBus()
> >
> > -hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
> > +hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/"),
> > "org.bluez.HealthManager")
> > app_path = hdp_manager.CreateApplication({"DataType": dbus.types.UInt16(4103),
> > "Role": "sink"})
> > --
> > 1.7.4
>
> Any reasons why this is not per adapter? This is supposed to be very
> similar to Media API which is used in a per adapter fashion.
IIRC In the first versions of the API Marcel tried to abstract the concept of
adapter and have the API works with Health Applications. But not sure if after
http://www.spinics.net/lists/linux-bluetooth/msg06788.html
this is still valid.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* Re: [PATCH] Move HealthManager Interface to "/" path
From: Gustavo F. Padovan @ 2011-02-15 20:11 UTC (permalink / raw)
To: Elvis Pfützenreuter; +Cc: linux-bluetooth
In-Reply-To: <9C50502C-696A-45DE-B306-8421FE18F897@signove.com>
* Elvis Pfützenreuter <epx@signove.com> [2011-02-15 17:45:05 -0200]:
> Hi Padovan,
>
> On Feb 15, 2011, at 5:31 PM, Gustavo F. Padovan wrote:
>
> > Yeah, this breaks the API, but health is still disabled by default and it
> > is not a good idea create a new path only for it. So moving it to "/"
> > ---
> > doc/health-api.txt | 2 +-
> > health/hdp.c | 4 ++--
> > test/test-health | 2 +-
> > test/test-health-sink | 2 +-
> > 4 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/doc/health-api.txt b/doc/health-api.txt
> > index 3d0a717..9d5a54d 100644
> > --- a/doc/health-api.txt
> > +++ b/doc/health-api.txt
> > @@ -10,7 +10,7 @@ Health Device Profile hierarchy
> >
> > Service org.bluez
> > Interface org.bluez.HealthManager
> > -Object path /org/bluez/
> > +Object path /
> >
> > Methods:
> >
> > diff --git a/health/hdp.c b/health/hdp.c
> > index d4a2a30..e58bd55 100644
> > --- a/health/hdp.c
> > +++ b/health/hdp.c
> > @@ -2171,7 +2171,7 @@ int hdp_manager_start(DBusConnection *conn)
> > {
> > DBG("Starting Health manager");
> >
> > - if (!g_dbus_register_interface(conn, MANAGER_PATH,
> > + if (!g_dbus_register_interface(conn, "/",
>
> I'd rather change macro value instead of removing it. Patch gets smaller.
> (Or remove the macro definition along with its references.)
Yeah, I forgot to remove the macro definition.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* [PATCH -v2] Move HealthManager Interface to "/" path
From: Gustavo F. Padovan @ 2011-02-15 20:12 UTC (permalink / raw)
To: linux-bluetooth
Yeah, this breaks the API, but health is still disabled by default and it
is not a good idea create a new path only for it. So moving it to "/"
---
doc/health-api.txt | 2 +-
health/hdp.c | 6 +++---
health/hdp_types.h | 2 --
test/test-health | 2 +-
test/test-health-sink | 2 +-
5 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/doc/health-api.txt b/doc/health-api.txt
index 3d0a717..9d5a54d 100644
--- a/doc/health-api.txt
+++ b/doc/health-api.txt
@@ -10,7 +10,7 @@ Health Device Profile hierarchy
Service org.bluez
Interface org.bluez.HealthManager
-Object path /org/bluez/
+Object path /
Methods:
diff --git a/health/hdp.c b/health/hdp.c
index d4a2a30..ae20a1f 100644
--- a/health/hdp.c
+++ b/health/hdp.c
@@ -290,7 +290,7 @@ static gboolean set_app_path(struct hdp_application *app)
app->id = get_app_id();
if (!app->id)
return FALSE;
- app->path = g_strdup_printf(MANAGER_PATH "/health_app_%d", app->id);
+ app->path = g_strdup_printf("/health_app_%d", app->id);
return TRUE;
};
@@ -2171,7 +2171,7 @@ int hdp_manager_start(DBusConnection *conn)
{
DBG("Starting Health manager");
- if (!g_dbus_register_interface(conn, MANAGER_PATH,
+ if (!g_dbus_register_interface(conn, "/",
HEALTH_MANAGER,
health_manager_methods, NULL, NULL,
NULL, manager_path_unregister)) {
@@ -2186,7 +2186,7 @@ int hdp_manager_start(DBusConnection *conn)
void hdp_manager_stop()
{
- g_dbus_unregister_interface(connection, MANAGER_PATH, HEALTH_MANAGER);
+ g_dbus_unregister_interface(connection, "/", HEALTH_MANAGER);
dbus_connection_unref(connection);
DBG("Stopped Health manager");
diff --git a/health/hdp_types.h b/health/hdp_types.h
index 7d23293..466f8c6 100644
--- a/health/hdp_types.h
+++ b/health/hdp_types.h
@@ -30,8 +30,6 @@
#define HDP_SOURCE_UUID "00001401-0000-1000-8000-00805F9B34FB"
#define HDP_SINK_UUID "00001402-0000-1000-8000-00805F9B34FB"
-#define MANAGER_PATH "/org/bluez"
-
#define HEALTH_MANAGER "org.bluez.HealthManager"
#define HEALTH_DEVICE "org.bluez.HealthDevice"
#define HEALTH_CHANNEL "org.bluez.HealthChannel"
diff --git a/test/test-health b/test/test-health
index 28cc894..7820a24 100755
--- a/test/test-health
+++ b/test/test-health
@@ -47,7 +47,7 @@ def enter_mainloop():
finally:
print "Exiting, bye"
-hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
+hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.bluez.HealthManager")
role = None
diff --git a/test/test-health-sink b/test/test-health-sink
index cb9d434..50eb74c 100755
--- a/test/test-health-sink
+++ b/test/test-health-sink
@@ -12,7 +12,7 @@ loop = gobject.MainLoop()
bus = dbus.SystemBus()
-hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"),
+hdp_manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.bluez.HealthManager")
app_path = hdp_manager.CreateApplication({"DataType": dbus.types.UInt16(4103),
"Role": "sink"})
--
1.7.4
^ permalink raw reply related
* Re: [RFC 1/3] Bluetooth: Add LE signaling commands handling
From: Gustavo F. Padovan @ 2011-02-15 21:14 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1297459736-24514-2-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
* Claudio Takahasi <claudio.takahasi@openbossa.org> [2011-02-11 19:28:54 -0200]:
> This patch splits the L2CAP command handling function in order to
> have a clear separation between the commands related to BR/EDR and
> LE. Commands and responses in the LE signaling channel are not being
> handled yet, command reject is sent to all received requests. Bluetooth
> Core Specification, Volume 3, Part A, section 4 defines the signaling
> packets formats and allowed commands/responses over the LE signaling
> channel.
>
> Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
> ---
> include/net/bluetooth/l2cap.h | 2 +
> net/bluetooth/l2cap_core.c | 150 +++++++++++++++++++++++++++--------------
> 2 files changed, 100 insertions(+), 52 deletions(-)
>
> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> index 420981c..6aa70e9 100644
> --- a/include/net/bluetooth/l2cap.h
> +++ b/include/net/bluetooth/l2cap.h
> @@ -89,6 +89,8 @@ struct l2cap_conninfo {
> #define L2CAP_ECHO_RSP 0x09
> #define L2CAP_INFO_REQ 0x0a
> #define L2CAP_INFO_RSP 0x0b
> +#define L2CAP_CONN_PARAM_UPDATE_REQ 0x12
> +#define L2CAP_CONN_PARAM_UPDATE_RSP 0x13
>
> /* L2CAP feature mask */
> #define L2CAP_FEAT_FLOWCTL 0x00000001
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 0ca54d8..122fc1c 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -1435,7 +1435,11 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
>
> lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE);
> lh->len = cpu_to_le16(L2CAP_CMD_HDR_SIZE + dlen);
> - lh->cid = cpu_to_le16(L2CAP_CID_SIGNALING);
> +
> + if (conn->hcon->type == LE_LINK)
> + lh->cid = cpu_to_le16(L2CAP_CID_LE_SIGNALING);
> + else
> + lh->cid = cpu_to_le16(L2CAP_CID_SIGNALING);
>
> cmd = (struct l2cap_cmd_hdr *) skb_put(skb, L2CAP_CMD_HDR_SIZE);
> cmd->code = code;
> @@ -2504,12 +2508,98 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
> return 0;
> }
>
> -static inline void l2cap_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)
> +static inline int bredr_sig_cmd(struct l2cap_conn *conn,
> + struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data)
> +{
> + int err = 0;
> +
> + switch (cmd->code) {
> + case L2CAP_COMMAND_REJ:
> + l2cap_command_rej(conn, cmd, data);
> + break;
> +
> + case L2CAP_CONN_REQ:
> + err = l2cap_connect_req(conn, cmd, data);
> + break;
> +
> + case L2CAP_CONN_RSP:
> + err = l2cap_connect_rsp(conn, cmd, data);
> + break;
> +
> + case L2CAP_CONF_REQ:
> + err = l2cap_config_req(conn, cmd, cmd_len, data);
> + break;
> +
> + case L2CAP_CONF_RSP:
> + err = l2cap_config_rsp(conn, cmd, data);
> + break;
> +
> + case L2CAP_DISCONN_REQ:
> + err = l2cap_disconnect_req(conn, cmd, data);
> + break;
> +
> + case L2CAP_DISCONN_RSP:
> + err = l2cap_disconnect_rsp(conn, cmd, data);
> + break;
> +
> + case L2CAP_ECHO_REQ:
> + l2cap_send_cmd(conn, cmd->ident, L2CAP_ECHO_RSP, cmd_len, data);
> + break;
> +
> + case L2CAP_ECHO_RSP:
> + break;
> +
> + case L2CAP_INFO_REQ:
> + err = l2cap_information_req(conn, cmd, data);
> + break;
> +
> + case L2CAP_INFO_RSP:
> + err = l2cap_information_rsp(conn, cmd, data);
> + break;
> +
> + default:
> + BT_ERR("Unknown BR/EDR signaling command 0x%2.2x", cmd->code);
> + err = -EINVAL;
> + break;
> + }
> +
> + return err;
> +}
> +
> +static inline int le_sig_cmd(struct l2cap_conn *conn,
> + struct l2cap_cmd_hdr *cmd, u8 *data)
> +{
> + int err;
This var can be removed, I went ahead and removed it for you. Patch is now
applied. I also added a l2cap_ prefix to the new functions you added.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* [PATCH] Pass config parameters to do_connect() on gatttool
From: Sheldon Demario @ 2011-02-15 21:14 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
It is desirable that do_connect() doesn't depend on global variables
in order to make it more independent and reusable. Unifying all these
connection parameters on a single struct makes the code simpler.
---
attrib/gatttool.c | 61 +++++++++++++++++++++++++------------------------
attrib/gatttool.h | 11 ++++++++-
attrib/interactive.c | 28 ++++++++++++++---------
3 files changed, 58 insertions(+), 42 deletions(-)
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 1e2a8db..d72a49e 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -47,28 +47,24 @@
/* Minimum MTU for L2CAP connections over BR/EDR */
#define ATT_MIN_MTU_L2CAP 48
-static gchar *opt_src = NULL;
-static gchar *opt_dst = NULL;
static gchar *opt_value = NULL;
-static gchar *opt_sec_level = "low";
static uuid_t *opt_uuid = NULL;
static int opt_start = 0x0001;
static int opt_end = 0xffff;
static int opt_handle = -1;
-static int opt_mtu = 0;
-static int opt_psm = 0x1f;
static gboolean opt_primary = FALSE;
static gboolean opt_characteristics = FALSE;
static gboolean opt_char_read = FALSE;
static gboolean opt_listen = FALSE;
static gboolean opt_char_desc = FALSE;
-static gboolean opt_le = FALSE;
static gboolean opt_char_write = FALSE;
static gboolean opt_char_write_req = FALSE;
static gboolean opt_interactive = FALSE;
static GMainLoop *event_loop;
static gboolean got_error = FALSE;
+struct connect_params config;
+
struct characteristic_data {
GAttrib *attrib;
uint16_t start;
@@ -84,7 +80,7 @@ static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
}
}
-GIOChannel *do_connect(gchar *dst, gboolean le, BtIOConnect connect_cb)
+GIOChannel *do_connect(struct connect_params *config, BtIOConnect connect_cb)
{
GIOChannel *chan;
bdaddr_t sba, dba;
@@ -93,49 +89,49 @@ GIOChannel *do_connect(gchar *dst, gboolean le, BtIOConnect connect_cb)
/* This check is required because currently setsockopt() returns no
* errors for MTU values smaller than the allowed minimum. */
- if (opt_mtu != 0 && opt_mtu < ATT_MIN_MTU_L2CAP) {
+ if (config->mtu != 0 && config->mtu < ATT_MIN_MTU_L2CAP) {
g_printerr("MTU cannot be smaller than %d\n",
ATT_MIN_MTU_L2CAP);
return NULL;
}
/* Remote device */
- if (dst == NULL) {
+ if (config->dst == NULL) {
g_printerr("Remote Bluetooth address required\n");
return NULL;
}
- str2ba(dst, &dba);
+ str2ba(config->dst, &dba);
/* Local adapter */
- if (opt_src != NULL) {
- if (!strncmp(opt_src, "hci", 3))
- hci_devba(atoi(opt_src + 3), &sba);
+ if (config->src != NULL) {
+ if (!strncmp(config->src, "hci", 3))
+ hci_devba(atoi(config->src + 3), &sba);
else
- str2ba(opt_src, &sba);
+ str2ba(config->src, &sba);
} else
bacpy(&sba, BDADDR_ANY);
- if (strcmp(opt_sec_level, "medium") == 0)
+ if (strcmp(config->sec_level, "medium") == 0)
sec_level = BT_IO_SEC_MEDIUM;
- else if (strcmp(opt_sec_level, "high") == 0)
+ else if (strcmp(config->sec_level, "high") == 0)
sec_level = BT_IO_SEC_HIGH;
else
sec_level = BT_IO_SEC_LOW;
- if (le)
+ if (config->le)
chan = bt_io_connect(BT_IO_L2CAP, connect_cb, NULL, NULL, &err,
BT_IO_OPT_SOURCE_BDADDR, &sba,
BT_IO_OPT_DEST_BDADDR, &dba,
BT_IO_OPT_CID, GATT_CID,
- BT_IO_OPT_OMTU, opt_mtu,
+ BT_IO_OPT_OMTU, config->mtu,
BT_IO_OPT_SEC_LEVEL, sec_level,
BT_IO_OPT_INVALID);
else
chan = bt_io_connect(BT_IO_L2CAP, connect_cb, NULL, NULL, &err,
BT_IO_OPT_SOURCE_BDADDR, &sba,
BT_IO_OPT_DEST_BDADDR, &dba,
- BT_IO_OPT_PSM, opt_psm,
- BT_IO_OPT_OMTU, opt_mtu,
+ BT_IO_OPT_PSM, config->psm,
+ BT_IO_OPT_OMTU, config->mtu,
BT_IO_OPT_SEC_LEVEL, sec_level,
BT_IO_OPT_INVALID);
@@ -594,7 +590,7 @@ static GOptionEntry gatt_options[] = {
"Characteristics Descriptor Discovery", NULL },
{ "listen", 0, 0, G_OPTION_ARG_NONE, &opt_listen,
"Listen for notifications and indications", NULL },
- { "le", 0, 0, G_OPTION_ARG_NONE, &opt_le,
+ { "le", 0, 0, G_OPTION_ARG_NONE, &config.le,
"Use Bluetooth Low Energy transport", NULL },
{ "interactive", 'I', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
&opt_interactive, "Use interactive mode", NULL },
@@ -602,15 +598,15 @@ static GOptionEntry gatt_options[] = {
};
static GOptionEntry options[] = {
- { "adapter", 'i', 0, G_OPTION_ARG_STRING, &opt_src,
+ { "adapter", 'i', 0, G_OPTION_ARG_STRING, &config.src,
"Specify local adapter interface", "hciX" },
- { "device", 'b', 0, G_OPTION_ARG_STRING, &opt_dst,
+ { "device", 'b', 0, G_OPTION_ARG_STRING, &config.dst,
"Specify remote Bluetooth address", "MAC" },
- { "mtu", 'm', 0, G_OPTION_ARG_INT, &opt_mtu,
+ { "mtu", 'm', 0, G_OPTION_ARG_INT, &config.mtu,
"Specify the MTU size", "MTU" },
- { "psm", 'p', 0, G_OPTION_ARG_INT, &opt_psm,
+ { "psm", 'p', 0, G_OPTION_ARG_INT, &config.psm,
"Specify the PSM for GATT/ATT over BR/EDR", "PSM" },
- { "sec-level", 'l', 0, G_OPTION_ARG_STRING, &opt_sec_level,
+ { "sec-level", 'l', 0, G_OPTION_ARG_STRING, &config.sec_level,
"Set security level. Default: low", "[low | medium | high]"},
{ NULL },
};
@@ -624,6 +620,10 @@ int main(int argc, char *argv[])
GIOChannel *chan;
GSourceFunc callback;
+ memset(&config, 0, sizeof(config));
+ config.sec_level = strdup("low");
+ config.psm = 0x1f;
+
context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, options, NULL);
@@ -656,7 +656,7 @@ int main(int argc, char *argv[])
}
if (opt_interactive) {
- interactive(opt_dst, opt_le);
+ interactive(config.dst, config.le);
goto done;
}
@@ -680,7 +680,7 @@ int main(int argc, char *argv[])
goto done;
}
- chan = do_connect(opt_dst, opt_le, connect_cb);
+ chan = do_connect(&config, connect_cb);
if (chan == NULL) {
got_error = TRUE;
goto done;
@@ -706,9 +706,10 @@ int main(int argc, char *argv[])
done:
g_option_context_free(context);
- g_free(opt_src);
- g_free(opt_dst);
+ g_free(config.src);
+ g_free(config.dst);
g_free(opt_uuid);
+ g_free(config.sec_level);
if (got_error)
exit(EXIT_FAILURE);
diff --git a/attrib/gatttool.h b/attrib/gatttool.h
index 2237330..ec6fa35 100644
--- a/attrib/gatttool.h
+++ b/attrib/gatttool.h
@@ -21,5 +21,14 @@
*
*/
+struct connect_params {
+ gchar *src;
+ gchar *dst;
+ gchar *sec_level;
+ int psm;
+ int mtu;
+ gboolean le;
+};
+
int interactive(gchar *dst, gboolean le);
-GIOChannel *do_connect(gchar *dst, gboolean le, BtIOConnect connect_cb);
+GIOChannel *do_connect(struct connect_params *config, BtIOConnect connect_cb);
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 83a0778..284699b 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -37,8 +37,7 @@ static GAttrib *attrib = NULL;
static GMainLoop *event_loop;
static GString *prompt;
-static gchar *opt_dst = NULL;
-static gboolean opt_le = FALSE;
+struct connect_params config;
static void cmd_help(int argcp, char **argvp);
@@ -60,12 +59,12 @@ static char *get_prompt(void)
else
g_string_assign(prompt, "[ ]");
- if (opt_dst)
- g_string_append_printf(prompt, "[%17s]", opt_dst);
+ if (config.dst)
+ g_string_append_printf(prompt, "[%17s]", config.dst);
else
g_string_append_printf(prompt, "[%17s]", "");
- if (opt_le)
+ if (config.le)
g_string_append(prompt, "[LE]");
else
g_string_append(prompt, "[BR]");
@@ -107,17 +106,17 @@ static void cmd_connect(int argcp, char **argvp)
return;
if (argcp > 1) {
- g_free(opt_dst);
- opt_dst = strdup(argvp[1]);
+ g_free(config.dst);
+ config.dst = strdup(argvp[1]);
}
- if (opt_dst == NULL) {
+ if (config.dst == NULL) {
printf("Remote Bluetooth address required\n");
return;
}
set_state(STATE_CONNECTING);
- iochannel = do_connect(opt_dst, opt_le, connect_cb);
+ iochannel = do_connect(&config, connect_cb);
if (iochannel == NULL)
set_state(STATE_DISCONNECTED);
@@ -212,8 +211,12 @@ int interactive(gchar *dst, gboolean le)
GIOChannel *pchan;
gint events;
- opt_dst = dst;
- opt_le = le;
+ memset(&config, 0, sizeof(config));
+ config.sec_level = strdup("low");
+ config.psm = 0x1f;
+
+ config.dst = strdup(dst);
+ config.le = le;
prompt = g_string_new(NULL);
@@ -234,5 +237,8 @@ int interactive(gchar *dst, gboolean le)
g_main_loop_unref(event_loop);
g_string_free(prompt, TRUE);
+ g_free(config.dst);
+ g_free(config.sec_level);
+
return 0;
}
--
1.7.1
^ permalink raw reply related
* Re: [RFC 2/3] Bluetooth: Add connection parameter update response
From: Gustavo F. Padovan @ 2011-02-15 21:15 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1297459736-24514-3-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
* Claudio Takahasi <claudio.takahasi@openbossa.org> [2011-02-11 19:28:55 -0200]:
> Implements L2CAP Connection Parameter Update Response defined in
> the Bluetooth Core Specification, Volume 3, Part A, section 4.21.
> Address the LE Connection Parameter Procedure initiated by the slave.
>
> Connection Interval Minimum and Maximum have the same range: 6 to
> 3200. Time = N * 1.25ms. Minimum shall be less or equal to Maximum.
> The Slave Latency field shall have a value in the range of 0 to
> ((connSupervisionTimeout / connIntervalMax) - 1). Latency field shall
> be less than 500. connSupervisionTimeout = Timeout Multiplier * 10 ms.
> Multiplier field shall have a value in the range of 10 to 3200.
>
> Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
> ---
> include/net/bluetooth/l2cap.h | 15 ++++++++++
> net/bluetooth/l2cap_core.c | 60 ++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 74 insertions(+), 1 deletions(-)
Applied, after fix the conflict caused by the changes I did in the previous
patch. Thanks.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* Re: [RFC 2/3] Bluetooth: Add connection parameter update response
From: Gustavo F. Padovan @ 2011-02-15 21:17 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1297459736-24514-3-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
* Claudio Takahasi <claudio.takahasi@openbossa.org> [2011-02-11 19:28:55 -0200]:
> Implements L2CAP Connection Parameter Update Response defined in
> the Bluetooth Core Specification, Volume 3, Part A, section 4.21.
> Address the LE Connection Parameter Procedure initiated by the slave.
>
> Connection Interval Minimum and Maximum have the same range: 6 to
> 3200. Time = N * 1.25ms. Minimum shall be less or equal to Maximum.
> The Slave Latency field shall have a value in the range of 0 to
> ((connSupervisionTimeout / connIntervalMax) - 1). Latency field shall
> be less than 500. connSupervisionTimeout = Timeout Multiplier * 10 ms.
> Multiplier field shall have a value in the range of 10 to 3200.
>
> Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
> ---
> include/net/bluetooth/l2cap.h | 15 ++++++++++
> net/bluetooth/l2cap_core.c | 60 ++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 74 insertions(+), 1 deletions(-)
This one doesn't apply to my tree. Please rebase.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* Re: [RFC 3/3] Bluetooth: Send LE Connection Update Command
From: Gustavo F. Padovan @ 2011-02-15 21:20 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1297459736-24514-4-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
* Claudio Takahasi <claudio.takahasi@openbossa.org> [2011-02-11 19:28:56 -0200]:
> If the new connection update parameter are accepted, the LE master
> host sends the LE Connection Update Command to its controller informing
> the new requested parameters.
>
> Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
> ---
> include/net/bluetooth/hci.h | 11 +++++++++++
> include/net/bluetooth/hci_core.h | 2 ++
> net/bluetooth/hci_conn.c | 20 ++++++++++++++++++++
> net/bluetooth/l2cap_core.c | 7 ++++++-
> 4 files changed, 39 insertions(+), 1 deletions(-)
Actually it is this one that doesn't apply, not 2 of 3.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* Re: bluetooth disabled with current 2.6.38-rc4
From: Justin Mattock @ 2011-02-16 3:26 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20110215135245.GA11561@jh-x301>
On Feb 15, 2011, at 5:52 AM, Johan Hedberg wrote:
> Hi Justin,
>
> On Sun, Feb 13, 2011, Justin Mattock wrote:
>> maybe I missed something, but my bluetooth is just not functioning
>> with
>> 2.6.38-rc4(works with 2.6.37-rc4)
>>
>> I've done a bisect on this, but was pointed to:
>> c0e45c1ca3162acb2e77b3d9e152ce6e7b6fa3f5
>> but doesn't look correct to me
>>
>> here is what I am seeing with the bluetooth-applet etc..:
>>
>> working correctly:
>> http://www.flickr.com/photos/44066293@N08/5443727238/
>>
>> not working:
>> http://www.flickr.com/photos/44066293@N08/5443124859/
>>
>> my /var/log/daemon.log shows:
>>
>> Feb 13 17:12:22 Linux-2 acpid: 1 client rule loaded
>> Feb 13 17:12:23 Linux-2 bluetoothd[1950]: HCI dev 0 registered
>> Feb 13 17:12:23 Linux-2 bluetoothd[1950]: Listening for HCI events
>> on hci0
>> Feb 13 17:12:23 Linux-2 bluetoothd[1950]: HCI dev 0 up
>> Feb 13 17:12:23 Linux-2 bluetoothd[1950]: Unable to find matching
>> adapter
>>
>> I can try at another bisect, but might take some time.. let me know
>> if there is something I can test
>> or do.
>
> Are you sure this is a kernel problem? There was a similar issue with
> BlueZ 4.86 or 4.87 which was already fixed. Could you try with 4.88?
>
> Johan
o.k. I built 4.88 and still had the issue show up, except this time no
icon(instead of the icon, that is not lit up)..
anyways I did do another bisect and had better results(hopefully)this
time..:
23bb57633df97ede067ea26f3cdc8a7ba2cd8109 is the first bad commit
commit 23bb57633df97ede067ea26f3cdc8a7ba2cd8109
Author: Johan Hedberg <johan.hedberg@nokia.com>
Date: Tue Dec 21 23:01:27 2010 +0200
Bluetooth: Fix __hci_request synchronization for hci_open_dev
The initialization function used by hci_open_dev (hci_init_req)
sends
many different HCI commands. The __hci_request function should only
return when all of these commands have completed (or a timeout
occurs).
Several of these commands cause hci_req_complete to be called which
causes __hci_request to return prematurely.
This patch fixes the issue by adding a new hdev->req_last_cmd
variable
which is set during the initialization procedure. The
hci_req_complete
function will no longer mark the request as complete until the
command
matching hdev->req_last_cmd completes.
Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
:040000 040000 e8d8ae5fab74b2ba73d0c52e7e09b30e5df8484e
8d1409e8dc2206492cb86e8848c8c23aff182e2a M include
:040000 040000 07fdb5f6ceadcfde12c46a3b5c82937b7dac892c
8f3b08fbbc9fcd078d0f5224b8bc818eeb072dc4 M net
git bisect log
git bisect start
# bad: [c56eb8fb6dccb83d9fe62fd4dc00c834de9bc470] Linux 2.6.38-rc1
git bisect bad c56eb8fb6dccb83d9fe62fd4dc00c834de9bc470
# good: [d9a1abe4844e7591cd82e167a1a09e6546f6c45e] arch/mn10300/kernel/
irq.c: fix build
git bisect good d9a1abe4844e7591cd82e167a1a09e6546f6c45e
# bad: [76d9cc454a8d0bb7484616a4b8136280068c8a8b] spi: tegra: don't
treat NULL clk as an error
git bisect bad 76d9cc454a8d0bb7484616a4b8136280068c8a8b
# bad: [f70f5b9dc74ca7d0a64c4ead3fb28da09dc1b234] Merge git://
git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next-2.6
git bisect bad f70f5b9dc74ca7d0a64c4ead3fb28da09dc1b234
# good: [1d212aa96e1b63459486f729af9a3fa38768b801] Merge branch
'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/
wireless-next-2.6 into for-davem
git bisect good 1d212aa96e1b63459486f729af9a3fa38768b801
# bad: [4e3dbdb1392a83bd21a6ff8f6bc785495058d37c] cassini: Use local-
mac-address prom property for Cassini MAC address
git bisect bad 4e3dbdb1392a83bd21a6ff8f6bc785495058d37c
# good: [65a6538a56d4c7ae8465f2a8420ddc65877b6779] mac80211: check for
CONFIG_MAC80211_LEDS in the tpt_led_trigger declaration
git bisect good 65a6538a56d4c7ae8465f2a8420ddc65877b6779
# good: [dbbe68bb12b34f3e450da7a73c20e6fa1f85d63a] Merge branch
'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
git bisect good dbbe68bb12b34f3e450da7a73c20e6fa1f85d63a
# bad: [c9e57f0fdccf74ef7884fed61d212e524b9c4bcd] carl9170: add
missing return-value check
git bisect bad c9e57f0fdccf74ef7884fed61d212e524b9c4bcd
# good: [a3463a1fdc9aa0881760e54efbd62742275601a5] rndis_wlan: remove
unused variable from priv structure
git bisect good a3463a1fdc9aa0881760e54efbd62742275601a5
# bad: [17f9cc3124c97f50a19a7597e5f29f915b5b835c] Bluetooth: Improve
handling of HCI control channel in bind
git bisect bad 17f9cc3124c97f50a19a7597e5f29f915b5b835c
# good: [e41d8b4e131a41f2a3b74aaa783b16aa46376d8e] Bluetooth: Add
error handling for managment command handlers
git bisect good e41d8b4e131a41f2a3b74aaa783b16aa46376d8e
# good: [f7b64e69c7c75c8e9f2d5e23edec8de1ce883bcc] Bluetooth: Add
read_info management command
git bisect good f7b64e69c7c75c8e9f2d5e23edec8de1ce883bcc
# bad: [23bb57633df97ede067ea26f3cdc8a7ba2cd8109] Bluetooth: Fix
__hci_request synchronization for hci_open_dev
git bisect bad 23bb57633df97ede067ea26f3cdc8a7ba2cd8109
# good: [c71e97bfaadfa727669fcfcf12301744fd169091] Bluetooth: Add
management events for controller addition & removal
git bisect good c71e97bfaadfa727669fcfcf12301744fd169091
reverting that commit gets the icon to show up, as well as the mouse
to connect..
(hardware is a MacBookPro2,2 and the mouse is a mightmouse) let me
know if there is anything I can supply
Justin P. Mattock
^ permalink raw reply
* [PATCH v2 1/1] HID: Documentation for hidraw
From: Alan Ott @ 2011-02-16 3:53 UTC (permalink / raw)
To: Randy Dunlap, Alan Ott, linux-doc, linux-kernel, jkosina, ospite,
linux-input, linux-bluetooth
Cc: Alan Ott
Documenation for the hidraw driver, with example program.
Signed-off-by: Alan Ott <alan@signal11.us>
---
Now that my feature report patches have made it into -next. It seems
the time is right for the documentation to go in as well.
Documentation/hid/Makefile | 8 ++
Documentation/hid/hid-example.c | 167 +++++++++++++++++++++++++++++++++++++++
Documentation/hid/hidraw.txt | 119 ++++++++++++++++++++++++++++
3 files changed, 294 insertions(+), 0 deletions(-)
create mode 100644 Documentation/hid/Makefile
create mode 100644 Documentation/hid/hid-example.c
create mode 100644 Documentation/hid/hidraw.txt
diff --git a/Documentation/hid/Makefile b/Documentation/hid/Makefile
new file mode 100644
index 0000000..7811cb0
--- /dev/null
+++ b/Documentation/hid/Makefile
@@ -0,0 +1,8 @@
+# kbuild trick to avoid linker error. Can be omitted if a module is built.
+obj- := dummy.o
+
+# List of programs to build
+hostprogs-y := hid-example
+
+# Tell kbuild to always build the programs
+always := $(hostprogs-y)
diff --git a/Documentation/hid/hid-example.c b/Documentation/hid/hid-example.c
new file mode 100644
index 0000000..40e3d62
--- /dev/null
+++ b/Documentation/hid/hid-example.c
@@ -0,0 +1,167 @@
+/*
+ * Hidraw Userspace Example
+ *
+ * Copyright (c) 2010 Alan Ott <alan@signal11.us>
+ * Copyright (c) 2010 Signal 11 Software
+ *
+ * The code may be used by anyone for any purpose,
+ * and can serve as a starting point for developing
+ * applications using hidraw.
+ */
+
+/* Linux */
+#include <linux/types.h>
+#include <linux/input.h>
+#include <linux/hidraw.h>
+
+/* Unix */
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+/* C */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+const char *bus_str(int bus);
+
+int main(int argc, char **argv)
+{
+ int fd;
+ int i, res, desc_size = 0;
+ char buf[256];
+ struct hidraw_report_descriptor rpt_desc;
+ struct hidraw_devinfo info;
+
+ /* Open the Device with non-blocking reads. In real life,
+ don't use a hard coded path; use libudev instead. */
+ fd = open("/dev/hidraw0", O_RDWR|O_NONBLOCK);
+
+ if (fd < 0) {
+ perror("Unable to open device");
+ return 1;
+ }
+
+ memset(&rpt_desc, 0x0, sizeof(rpt_desc));
+ memset(&info, 0x0, sizeof(info));
+ memset(buf, 0x0, sizeof(buf));
+
+ /* Get Report Descriptor Size */
+ res = ioctl(fd, HIDIOCGRDESCSIZE, &desc_size);
+ if (res < 0)
+ perror("HIDIOCGRDESCSIZE");
+ else
+ printf("Report Descriptor Size: %d\n", desc_size);
+
+ /* Get Report Descriptor */
+ rpt_desc.size = desc_size;
+ res = ioctl(fd, HIDIOCGRDESC, &rpt_desc);
+ if (res < 0) {
+ perror("HIDIOCGRDESC");
+ } else {
+ printf("Report Descriptor:\n");
+ for (i = 0; i < rpt_desc.size; i++)
+ printf("%hhx ", rpt_desc.value[i]);
+ puts("\n");
+ }
+
+ /* Get Raw Name */
+ res = ioctl(fd, HIDIOCGRAWNAME(256), buf);
+ if (res < 0)
+ perror("HIDIOCGRAWNAME");
+ else
+ printf("Raw Name: %s\n", buf);
+
+ /* Get Physical Location */
+ res = ioctl(fd, HIDIOCGRAWPHYS(256), buf);
+ if (res < 0)
+ perror("HIDIOCGRAWPHYS");
+ else
+ printf("Raw Phys: %s\n", buf);
+
+ /* Get Raw Info */
+ res = ioctl(fd, HIDIOCGRAWINFO, &info);
+ if (res < 0) {
+ perror("HIDIOCGRAWINFO");
+ } else {
+ printf("Raw Info:\n");
+ printf("\tbustype: %d (%s)\n",
+ info.bustype, bus_str(info.bustype));
+ printf("\tvendor: 0x%04hx\n", info.vendor);
+ printf("\tproduct: 0x%04hx\n", info.product);
+ }
+
+ /* Set Feature */
+ buf[0] = 0x9; /* Report Number */
+ buf[1] = 0xff;
+ buf[2] = 0xff;
+ buf[3] = 0xff;
+ res = ioctl(fd, HIDIOCSFEATURE(4), buf);
+ if (res < 0)
+ perror("HIDIOCSFEATURE");
+ else
+ printf("ioctl HIDIOCGFEATURE returned: %d\n", res);
+
+ /* Get Feature */
+ buf[0] = 0x9; /* Report Number */
+ res = ioctl(fd, HIDIOCGFEATURE(256), buf);
+ if (res < 0) {
+ perror("HIDIOCGFEATURE");
+ } else {
+ printf("ioctl HIDIOCGFEATURE returned: %d\n", res);
+ printf("Report data (not containing the report number):\n\t");
+ for (i = 0; i < res; i++)
+ printf("%hhx ", buf[i]);
+ puts("\n");
+ }
+
+ /* Send a Report to the Device */
+ buf[0] = 0x1; /* Report Number */
+ buf[1] = 0x77;
+ res = write(fd, buf, 2);
+ if (res < 0) {
+ printf("Error: %d\n", errno);
+ perror("write");
+ } else {
+ printf("write() wrote %d bytes\n", res);
+ }
+
+ /* Get a report from the device */
+ res = read(fd, buf, 16);
+ if (res < 0) {
+ perror("read");
+ } else {
+ printf("read() read %d bytes:\n\t", res);
+ for (i = 0; i < res; i++)
+ printf("%hhx ", buf[i]);
+ puts("\n");
+ }
+ close(fd);
+ return 0;
+}
+
+const char *
+bus_str(int bus)
+{
+ switch (bus) {
+ case BUS_USB:
+ return "USB";
+ break;
+ case BUS_HIL:
+ return "HIL";
+ break;
+ case BUS_BLUETOOTH:
+ return "Bluetooth";
+ break;
+ case BUS_VIRTUAL:
+ return "Virtual";
+ break;
+ default:
+ return "Other";
+ break;
+ }
+}
diff --git a/Documentation/hid/hidraw.txt b/Documentation/hid/hidraw.txt
new file mode 100644
index 0000000..2e0d39a
--- /dev/null
+++ b/Documentation/hid/hidraw.txt
@@ -0,0 +1,119 @@
+ HIDRAW - Raw Access to USB and Bluetooth Human Interface Devices
+ ==================================================================
+
+The hidraw driver provides a raw interface to USB and Bluetooth Human
+Interface Devices (HIDs). It differs from hiddev in that reports sent and
+received are not parsed by the HID parser, but are sent to and received from
+the device unmodified.
+
+Hidraw should be used if the userspace application knows exactly how to
+communicate with the hardware device, and is able to construct the HID
+reports manually. This is often the case when making userspace drivers for
+custom HID devices.
+
+Hidraw is also useful for communicating with non-conformant HID devices
+which send and receive data in a way that is inconsistent with their report
+descriptors. Because hiddev parses reports which are sent and received
+through it, checking them against the device's report descriptor, such
+communication with these non-conformant devices is impossible using hiddev.
+Hidraw is the only alternative, short of writing a custom kernel driver, for
+these non-conformant devices.
+
+A benefit of hidraw is that its use by userspace applications is independent
+of the underlying hardware type. Currently, Hidraw is implemented for USB
+and Bluetooth. In the future, as new hardware bus types are developed which
+use the HID specification, hidraw will be expanded to add support for these
+new bus types.
+
+Hidraw uses a dynamic major number, meaning that udev should be relied on to
+create hidraw device nodes. Udev will typically create the device nodes
+directly under /dev (eg: /dev/hidraw0). As this location is distribution-
+and udev rule-dependent, applications should use libudev to locate hidraw
+devices attached to the system. There is a tutorial on libudev with a
+working example at:
+ http://www.signal11.us/oss/udev/
+
+The HIDRAW API
+---------------
+
+read()
+-------
+read() will read a queued report received from the HID device. On USB
+devices, the reports read using read() are the reports sent from the device
+on the INTERRUPT IN endpoint. By default, read() will block until there is
+a report available to be read. read() can be made non-blocking, by passing
+the O_NONBLOCK flag to open(), or by setting the O_NONBLOCK flag using
+fcntl().
+
+On a device which uses numbered reports, the first byte of the returned data
+will be the report number; the report data follows, beginning in the second
+byte. For devices which do not use numbered reports, the report data
+will begin at the first byte.
+
+write()
+--------
+The write() function will write a report to the device. For USB devices, if
+the device has an INTERRUPT OUT endpoint, the report will be sent on that
+endpoint. If it does not, the report will be sent over the control endpoint,
+using a SET_REPORT transfer.
+
+The first byte of the buffer passed to write() should be set to the report
+number. If the device does not use numbered reports, the first byte should
+be set to 0. The report data itself should begin at the second byte.
+
+ioctl()
+--------
+Hidraw supports the following ioctls:
+
+HIDIOCGRDESCSIZE: Get Report Descriptor Size
+This ioctl will get the size of the device's report descriptor.
+
+HIDIOCGRDESC: Get Report Descriptor
+This ioctl returns the device's report descriptor using a
+hidraw_report_descriptor struct. Make sure to set the size field of the
+hidraw_report_descriptor struct to the size returned from HIDIOCGRDESCSIZE.
+
+HIDIOCGRAWINFO: Get Raw Info
+This ioctl will return a hidraw_devinfo struct containing the bus type, the
+vendor ID (VID), and product ID (PID) of the device. The bus type can be one
+of:
+ BUS_USB
+ BUS_HIL
+ BUS_BLUETOOTH
+ BUS_VIRTUAL
+which are defined in linux/input.h.
+
+HIDIOCGRAWNAME(len): Get Raw Name
+This ioctl returns a string containing the vendor and product strings of
+the device. The returned string is Unicode, UTF-8 encoded.
+
+HIDIOCGRAWPHYS(len): Get Physical Address
+This ioctl returns a string representing the physical address of the device.
+For USB devices, the string contains the physical path to the device (the
+USB controller, hubs, ports, etc). For Bluetooth devices, the string
+contains the hardware (MAC) address of the device.
+
+HIDIOCSFEATURE(len): Send a Feature Report
+This ioctl will send a feature report to the device. Per the HID
+specification, feature reports are always sent using the control endpoint.
+Set the first byte of the supplied buffer to the report number. For devices
+which do not use numbered reports, set the first byte to 0. The report data
+begins in the second byte. Make sure to set len accordingly, to one more
+than the length of the report (to account for the report number).
+
+HIDIOCGFEATURE(len): Get a Feature Report
+This ioctl will request a feature report from the device using the control
+endpoint. The first byte of the supplied buffer should be set to the report
+number of the requested report. For devices which do not use numbered
+reports, set the first byte to 0. The report will be returned starting at
+the first byte of the buffer (ie: the report number is not returned).
+
+Example
+---------
+In this directory, find hid-example.c, which shows examples of read(),
+write(), and all the ioctls for hidraw. The code may be used by anyone for
+any purpose, and can serve as a starting point for developing applications
+using hidraw.
+
+Document by:
+ Alan Ott <alan@signal11.us>, Signal 11 Software
--
1.7.0.4
^ permalink raw reply related
* [PATCH v4 0/2] HID: hidraw Documentation
From: Alan Ott @ 2011-02-16 4:06 UTC (permalink / raw)
To: Randy Dunlap, Alan Ott, linux-doc, linux-kernel, jkosina, ospite,
linux-input, linux-bluetooth, bgood
Cc: Alan Ott
So I messed up a minute ago and sent just one of these out. Please disregard
the one I just sent that says v2. It should have been v3, and it should have
had 2 patches in the set instead of just 1. Sorry for the noise....
These patches add the hidraw.txt file to a new Documentation/hid/ directory.
The example program has been moved out of the document and fixed up for style
(it's now checkpatch.pl clean), and a Makefile has been created for it.
I integrated the comments provided.
hiddev.txt has been moved from Documentation/usb/ to Documentation/hid/
This is rebased against .37+
Alan Ott (2):
HID: Documentation for hidraw
HID: Move hiddev.txt to the new Documentation/HID directory
Documentation/hid/Makefile | 8 ++
Documentation/hid/hid-example.c | 167 +++++++++++++++++++++++++++++++++
Documentation/{usb => hid}/hiddev.txt | 0
Documentation/hid/hidraw.txt | 119 +++++++++++++++++++++++
4 files changed, 294 insertions(+), 0 deletions(-)
create mode 100644 Documentation/hid/Makefile
create mode 100644 Documentation/hid/hid-example.c
rename Documentation/{usb => hid}/hiddev.txt (100%)
create mode 100644 Documentation/hid/hidraw.txt
^ permalink raw reply
* [PATCH v4 1/2] HID: Documentation for hidraw
From: Alan Ott @ 2011-02-16 4:06 UTC (permalink / raw)
To: Randy Dunlap, Alan Ott, linux-doc, linux-kernel, jkosina, ospite,
linux-input, linux-bluetooth, bgood
Cc: Alan Ott
In-Reply-To: <1297829209-10511-1-git-send-email-alan@signal11.us>
Documenation for the hidraw driver, with example program.
Signed-off-by: Alan Ott <alan@signal11.us>
---
Documentation/hid/Makefile | 8 ++
Documentation/hid/hid-example.c | 167 +++++++++++++++++++++++++++++++++++++++
Documentation/hid/hidraw.txt | 119 ++++++++++++++++++++++++++++
3 files changed, 294 insertions(+), 0 deletions(-)
create mode 100644 Documentation/hid/Makefile
create mode 100644 Documentation/hid/hid-example.c
create mode 100644 Documentation/hid/hidraw.txt
diff --git a/Documentation/hid/Makefile b/Documentation/hid/Makefile
new file mode 100644
index 0000000..7811cb0
--- /dev/null
+++ b/Documentation/hid/Makefile
@@ -0,0 +1,8 @@
+# kbuild trick to avoid linker error. Can be omitted if a module is built.
+obj- := dummy.o
+
+# List of programs to build
+hostprogs-y := hid-example
+
+# Tell kbuild to always build the programs
+always := $(hostprogs-y)
diff --git a/Documentation/hid/hid-example.c b/Documentation/hid/hid-example.c
new file mode 100644
index 0000000..40e3d62
--- /dev/null
+++ b/Documentation/hid/hid-example.c
@@ -0,0 +1,167 @@
+/*
+ * Hidraw Userspace Example
+ *
+ * Copyright (c) 2010 Alan Ott <alan@signal11.us>
+ * Copyright (c) 2010 Signal 11 Software
+ *
+ * The code may be used by anyone for any purpose,
+ * and can serve as a starting point for developing
+ * applications using hidraw.
+ */
+
+/* Linux */
+#include <linux/types.h>
+#include <linux/input.h>
+#include <linux/hidraw.h>
+
+/* Unix */
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+/* C */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+const char *bus_str(int bus);
+
+int main(int argc, char **argv)
+{
+ int fd;
+ int i, res, desc_size = 0;
+ char buf[256];
+ struct hidraw_report_descriptor rpt_desc;
+ struct hidraw_devinfo info;
+
+ /* Open the Device with non-blocking reads. In real life,
+ don't use a hard coded path; use libudev instead. */
+ fd = open("/dev/hidraw0", O_RDWR|O_NONBLOCK);
+
+ if (fd < 0) {
+ perror("Unable to open device");
+ return 1;
+ }
+
+ memset(&rpt_desc, 0x0, sizeof(rpt_desc));
+ memset(&info, 0x0, sizeof(info));
+ memset(buf, 0x0, sizeof(buf));
+
+ /* Get Report Descriptor Size */
+ res = ioctl(fd, HIDIOCGRDESCSIZE, &desc_size);
+ if (res < 0)
+ perror("HIDIOCGRDESCSIZE");
+ else
+ printf("Report Descriptor Size: %d\n", desc_size);
+
+ /* Get Report Descriptor */
+ rpt_desc.size = desc_size;
+ res = ioctl(fd, HIDIOCGRDESC, &rpt_desc);
+ if (res < 0) {
+ perror("HIDIOCGRDESC");
+ } else {
+ printf("Report Descriptor:\n");
+ for (i = 0; i < rpt_desc.size; i++)
+ printf("%hhx ", rpt_desc.value[i]);
+ puts("\n");
+ }
+
+ /* Get Raw Name */
+ res = ioctl(fd, HIDIOCGRAWNAME(256), buf);
+ if (res < 0)
+ perror("HIDIOCGRAWNAME");
+ else
+ printf("Raw Name: %s\n", buf);
+
+ /* Get Physical Location */
+ res = ioctl(fd, HIDIOCGRAWPHYS(256), buf);
+ if (res < 0)
+ perror("HIDIOCGRAWPHYS");
+ else
+ printf("Raw Phys: %s\n", buf);
+
+ /* Get Raw Info */
+ res = ioctl(fd, HIDIOCGRAWINFO, &info);
+ if (res < 0) {
+ perror("HIDIOCGRAWINFO");
+ } else {
+ printf("Raw Info:\n");
+ printf("\tbustype: %d (%s)\n",
+ info.bustype, bus_str(info.bustype));
+ printf("\tvendor: 0x%04hx\n", info.vendor);
+ printf("\tproduct: 0x%04hx\n", info.product);
+ }
+
+ /* Set Feature */
+ buf[0] = 0x9; /* Report Number */
+ buf[1] = 0xff;
+ buf[2] = 0xff;
+ buf[3] = 0xff;
+ res = ioctl(fd, HIDIOCSFEATURE(4), buf);
+ if (res < 0)
+ perror("HIDIOCSFEATURE");
+ else
+ printf("ioctl HIDIOCGFEATURE returned: %d\n", res);
+
+ /* Get Feature */
+ buf[0] = 0x9; /* Report Number */
+ res = ioctl(fd, HIDIOCGFEATURE(256), buf);
+ if (res < 0) {
+ perror("HIDIOCGFEATURE");
+ } else {
+ printf("ioctl HIDIOCGFEATURE returned: %d\n", res);
+ printf("Report data (not containing the report number):\n\t");
+ for (i = 0; i < res; i++)
+ printf("%hhx ", buf[i]);
+ puts("\n");
+ }
+
+ /* Send a Report to the Device */
+ buf[0] = 0x1; /* Report Number */
+ buf[1] = 0x77;
+ res = write(fd, buf, 2);
+ if (res < 0) {
+ printf("Error: %d\n", errno);
+ perror("write");
+ } else {
+ printf("write() wrote %d bytes\n", res);
+ }
+
+ /* Get a report from the device */
+ res = read(fd, buf, 16);
+ if (res < 0) {
+ perror("read");
+ } else {
+ printf("read() read %d bytes:\n\t", res);
+ for (i = 0; i < res; i++)
+ printf("%hhx ", buf[i]);
+ puts("\n");
+ }
+ close(fd);
+ return 0;
+}
+
+const char *
+bus_str(int bus)
+{
+ switch (bus) {
+ case BUS_USB:
+ return "USB";
+ break;
+ case BUS_HIL:
+ return "HIL";
+ break;
+ case BUS_BLUETOOTH:
+ return "Bluetooth";
+ break;
+ case BUS_VIRTUAL:
+ return "Virtual";
+ break;
+ default:
+ return "Other";
+ break;
+ }
+}
diff --git a/Documentation/hid/hidraw.txt b/Documentation/hid/hidraw.txt
new file mode 100644
index 0000000..2e0d39a
--- /dev/null
+++ b/Documentation/hid/hidraw.txt
@@ -0,0 +1,119 @@
+ HIDRAW - Raw Access to USB and Bluetooth Human Interface Devices
+ ==================================================================
+
+The hidraw driver provides a raw interface to USB and Bluetooth Human
+Interface Devices (HIDs). It differs from hiddev in that reports sent and
+received are not parsed by the HID parser, but are sent to and received from
+the device unmodified.
+
+Hidraw should be used if the userspace application knows exactly how to
+communicate with the hardware device, and is able to construct the HID
+reports manually. This is often the case when making userspace drivers for
+custom HID devices.
+
+Hidraw is also useful for communicating with non-conformant HID devices
+which send and receive data in a way that is inconsistent with their report
+descriptors. Because hiddev parses reports which are sent and received
+through it, checking them against the device's report descriptor, such
+communication with these non-conformant devices is impossible using hiddev.
+Hidraw is the only alternative, short of writing a custom kernel driver, for
+these non-conformant devices.
+
+A benefit of hidraw is that its use by userspace applications is independent
+of the underlying hardware type. Currently, Hidraw is implemented for USB
+and Bluetooth. In the future, as new hardware bus types are developed which
+use the HID specification, hidraw will be expanded to add support for these
+new bus types.
+
+Hidraw uses a dynamic major number, meaning that udev should be relied on to
+create hidraw device nodes. Udev will typically create the device nodes
+directly under /dev (eg: /dev/hidraw0). As this location is distribution-
+and udev rule-dependent, applications should use libudev to locate hidraw
+devices attached to the system. There is a tutorial on libudev with a
+working example at:
+ http://www.signal11.us/oss/udev/
+
+The HIDRAW API
+---------------
+
+read()
+-------
+read() will read a queued report received from the HID device. On USB
+devices, the reports read using read() are the reports sent from the device
+on the INTERRUPT IN endpoint. By default, read() will block until there is
+a report available to be read. read() can be made non-blocking, by passing
+the O_NONBLOCK flag to open(), or by setting the O_NONBLOCK flag using
+fcntl().
+
+On a device which uses numbered reports, the first byte of the returned data
+will be the report number; the report data follows, beginning in the second
+byte. For devices which do not use numbered reports, the report data
+will begin at the first byte.
+
+write()
+--------
+The write() function will write a report to the device. For USB devices, if
+the device has an INTERRUPT OUT endpoint, the report will be sent on that
+endpoint. If it does not, the report will be sent over the control endpoint,
+using a SET_REPORT transfer.
+
+The first byte of the buffer passed to write() should be set to the report
+number. If the device does not use numbered reports, the first byte should
+be set to 0. The report data itself should begin at the second byte.
+
+ioctl()
+--------
+Hidraw supports the following ioctls:
+
+HIDIOCGRDESCSIZE: Get Report Descriptor Size
+This ioctl will get the size of the device's report descriptor.
+
+HIDIOCGRDESC: Get Report Descriptor
+This ioctl returns the device's report descriptor using a
+hidraw_report_descriptor struct. Make sure to set the size field of the
+hidraw_report_descriptor struct to the size returned from HIDIOCGRDESCSIZE.
+
+HIDIOCGRAWINFO: Get Raw Info
+This ioctl will return a hidraw_devinfo struct containing the bus type, the
+vendor ID (VID), and product ID (PID) of the device. The bus type can be one
+of:
+ BUS_USB
+ BUS_HIL
+ BUS_BLUETOOTH
+ BUS_VIRTUAL
+which are defined in linux/input.h.
+
+HIDIOCGRAWNAME(len): Get Raw Name
+This ioctl returns a string containing the vendor and product strings of
+the device. The returned string is Unicode, UTF-8 encoded.
+
+HIDIOCGRAWPHYS(len): Get Physical Address
+This ioctl returns a string representing the physical address of the device.
+For USB devices, the string contains the physical path to the device (the
+USB controller, hubs, ports, etc). For Bluetooth devices, the string
+contains the hardware (MAC) address of the device.
+
+HIDIOCSFEATURE(len): Send a Feature Report
+This ioctl will send a feature report to the device. Per the HID
+specification, feature reports are always sent using the control endpoint.
+Set the first byte of the supplied buffer to the report number. For devices
+which do not use numbered reports, set the first byte to 0. The report data
+begins in the second byte. Make sure to set len accordingly, to one more
+than the length of the report (to account for the report number).
+
+HIDIOCGFEATURE(len): Get a Feature Report
+This ioctl will request a feature report from the device using the control
+endpoint. The first byte of the supplied buffer should be set to the report
+number of the requested report. For devices which do not use numbered
+reports, set the first byte to 0. The report will be returned starting at
+the first byte of the buffer (ie: the report number is not returned).
+
+Example
+---------
+In this directory, find hid-example.c, which shows examples of read(),
+write(), and all the ioctls for hidraw. The code may be used by anyone for
+any purpose, and can serve as a starting point for developing applications
+using hidraw.
+
+Document by:
+ Alan Ott <alan@signal11.us>, Signal 11 Software
--
1.7.0.4
^ permalink raw reply related
* [PATCH v4 2/2] HID: Move hiddev.txt to the new Documentation/HID directory
From: Alan Ott @ 2011-02-16 4:06 UTC (permalink / raw)
To: Randy Dunlap, Alan Ott, linux-doc, linux-kernel, jkosina, ospite,
linux-input, linux-bluetooth, bgood
Cc: Alan Ott
In-Reply-To: <1297829209-10511-1-git-send-email-alan@signal11.us>
With the new Documentation/hid directory, it makes sense to have
hiddev.txt here as well.
Signed-off-by: Alan Ott <alan@signal11.us>
---
Documentation/{usb => hid}/hiddev.txt | 0
1 files changed, 0 insertions(+), 0 deletions(-)
rename Documentation/{usb => hid}/hiddev.txt (100%)
diff --git a/Documentation/usb/hiddev.txt b/Documentation/hid/hiddev.txt
similarity index 100%
rename from Documentation/usb/hiddev.txt
rename to Documentation/hid/hiddev.txt
--
1.7.0.4
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox