* Re: How to config bluetooth headset ?
From: Daniel O'Connor @ 2011-02-22 10:02 UTC (permalink / raw)
To: Daniel O'Connor; +Cc: Bob Liu, linux-bluetooth
In-Reply-To: <6FA7AA79-9141-4C2A-BF2F-7B9C0F575F03@gsoft.com.au>
On 22/02/2011, at 20:27, Daniel O'Connor wrote:
>> Is there any doc about it in detail ?
>
> I haven't seen any :(
>
> There's the source of course, but.. :-/
Actually there is the D-Bus API documentation.
http://git.kernel.org/?p=bluetooth/bluez.git;a=tree;f=doc;h=c933b3d917a930387a2422589f1caccd7db3bc9a;hb=HEAD
--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
-- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
^ permalink raw reply
* Re: [PATCH 2/2] bt hidp: send Output reports using SET_REPORT on the Control channel
From: Jiri Kosina @ 2011-02-22 10:09 UTC (permalink / raw)
To: Gustavo F. Padovan
Cc: Alan Ott, Antonio Ospite, linux-input, linux-bluetooth,
Marcel Holtmann, Bastien Nocera, Jim Paris, pascal@pabr.org
In-Reply-To: <20110221210906.GI2965@joana>
On Mon, 21 Feb 2011, Gustavo F. Padovan wrote:
> > > > The current implementation of hidp_output_raw_report() relies only on
> > > > the Control channel even for Output reports, and the BT HID
> > > > specification [1] does not mention using the DATA message for Output
> > > > reports on the Control channel (see section 7.9.1 and also Figure 11:
> > > > SET_ Flow Chart), so let us just use SET_REPORT.
> > > >
> > > > This also fixes sending Output reports to some devices (like Sony
> > > > Sixaxis) which are not able to handle DATA messages on the Control
> > > > channel.
> > > >
> > > > Ideally hidp_output_raw_report() could be improved to use this scheme:
> > > > Feature Report -- SET_REPORT on the Control channel
> > > > Output Report -- DATA on the Interrupt channel
> > > > for more efficiency, but as said above, right now only the Control
> > > > channel is used.
> > > >
> > > > [1] http://www.bluetooth.com/Specification%20Documents/HID_SPEC_V10.pdf
> > > >
> > > > case HID_OUTPUT_REPORT:
> > > > - report_type = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT;
> > > > + report_type = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_OUPUT;
> > > >
> > >
> > > I think this is right. Section 7.4[.0] says that SET_ and GET_ requests return
> > > with HANDSHAKE. Section 7.4.9 says that DATA does _not_ return a HANDSHAKE. My
> > > patch to hidp_output_raw_report() relies on getting a HANDSHAKE back, so it
> > > wouldn't have worked with BT devices that take output reports. Since I don't
> > > have any that do, I couldn't test it. (And it was like that when I got here :)
> > > )
> > >
> > > For the whole set:
> > > Acked-by: Alan Ott <alan@signal11.us>
> >
> > Agreed.
> >
> > As an author of the original code, I agree with the change. But as it is
> > in net/bluetooth, I'd at least have Acked-by from some of the Bluetooth
> > folks before I take it through my tree.
> >
> > Marcel? Gustavo?
>
> Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Perfect, applied, thanks.
--
Jiri Kosina
SUSE Labs, Novell Inc.
^ permalink raw reply
* Re: [PATCH -next] bluetooth: fix build break
From: Gustavo F. Padovan @ 2011-02-22 12:14 UTC (permalink / raw)
To: Anand Gadiyar; +Cc: linux-bluetooth, linux-next
In-Reply-To: <1298358789-13202-1-git-send-email-gadiyar@ti.com>
Hi Anand,
* Anand Gadiyar <gadiyar@ti.com> [2011-02-22 12:43:09 +0530]:
> Linux-next as of 20110217 complains when building for OMAP1.
>
> LD vmlinux
> `hci_sock_cleanup' referenced in section `.init.text' of net/built-in.o: defined in discarded section `.exit.text' of net/built-in.o
> `hci_sock_cleanup' referenced in section `.init.text' of net/built-in.o: defined in discarded section `.exit.text' of net/built-in.o
> make: *** [vmlinux] Error 1
>
> A recent patch by Gustavo (Bluetooth: Merge L2CAP and SCO modules
> into bluetooth.ko) introduced this by calling the hci_sock_cleanup
> function in the error path of bt_init.
>
> Fix this by dropping the __exit marking for hci_sock_cleanup.
>
> Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
> Cc: Gustavo F. Padovan <padovan@profusion.mobi>
> ---
> net/bluetooth/hci_sock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
I didn't catch on my system, applied. Thanks for fixing this.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* Re: [PATCH] bluetooth: remove unnecessary call to hci_sock_cleanup
From: Gustavo F. Padovan @ 2011-02-22 12:26 UTC (permalink / raw)
To: Anand Gadiyar; +Cc: linux-bluetooth
In-Reply-To: <1298358806-13257-1-git-send-email-gadiyar@ti.com>
Hi Anand,
* Anand Gadiyar <gadiyar@ti.com> [2011-02-22 12:43:26 +0530]:
> hci_sock_cleanup is already called after the sock_err label.
> It appears that we can drop this call.
>
> Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
> Cc: Gustavo F. Padovan <padovan@profusion.mobi>
> ---
> net/bluetooth/af_bluetooth.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
Also applied, thanks.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* Help hcitool cmd (hci to connect)
From: Thibaut L @ 2011-02-22 12:43 UTC (permalink / raw)
To: linux-bluetooth
Dear all,
Please, could anyone tell me how to connect to a bluetooth device
through hcitool (BlueZ) hci command. Like this: "hcitool cmd 0x01
0x0005 [parameters]". How can I input this cmd? Is the [parameters] a
bt device MAC adress like XX:XX:XX:XX:XX:XX?
I've tryed to use "hcitool cc <MAC>", but it doesn't work for me cause
it disconnects the device a second later.
I just wanna measure RSSI.
Thanks in advance.
Best
Thibaut
^ permalink raw reply
* Re: [PATCH 5/5] Fix --enable-usb build
From: Vinicius Costa Gomes @ 2011-02-22 14:05 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1298367822-27766-5-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On 11:43 Tue 22 Feb, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
>
> ---
> configure.ac | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 602c948..fc63b8c 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -156,7 +156,7 @@ AC_ARG_ENABLE(usb, AC_HELP_STRING([--enable-usb],
> enable_usb=${enableval}
> ])
> AM_CONDITIONAL(USB, test "${enable_usb}" = "yes" &&
> - test "${enable_server}" != "no")
> + test "${enable_usb}" != "no")
I failed to notice how the new line that you added is different from the
first line of the AM_CONDITIONAL(). Perhaps just removing the "enable_server"
test is enough. Or am I missing something?
>
> AC_ARG_ENABLE(pcsuite, AC_HELP_STRING([--enable-pcsuite],
> [enable Nokia PcSuite plugin]), [
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Cheers,
--
Vinicius
^ permalink raw reply
* Re: [PATCH 5/5] Fix --enable-usb build
From: Luiz Augusto von Dentz @ 2011-02-22 14:13 UTC (permalink / raw)
To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <20110222140512.GA12838@piper>
Hi,
On Tue, Feb 22, 2011 at 4:05 PM, Vinicius Costa Gomes
<vinicius.gomes@openbossa.org> wrote:
> Hi Luiz,
>
> On 11:43 Tue 22 Feb, Luiz Augusto von Dentz wrote:
>> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
>>
>> ---
>> configure.ac | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 602c948..fc63b8c 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -156,7 +156,7 @@ AC_ARG_ENABLE(usb, AC_HELP_STRING([--enable-usb],
>> enable_usb=${enableval}
>> ])
>> AM_CONDITIONAL(USB, test "${enable_usb}" = "yes" &&
>> - test "${enable_server}" != "no")
>> + test "${enable_usb}" != "no")
>
> I failed to notice how the new line that you added is different from the
> first line of the AM_CONDITIONAL(). Perhaps just removing the "enable_server"
> test is enough. Or am I missing something?
>
>>
>> AC_ARG_ENABLE(pcsuite, AC_HELP_STRING([--enable-pcsuite],
>> [enable Nokia PcSuite plugin]), [
>> --
Actually this is wrong, I though it was a type but it is not, but you
are right we should not need to check for server there as we do
already in Makefile.am.
--
Luiz Augusto von Dentz
Computer Engineer
^ permalink raw reply
* [PATCH 4/5 v2] Move pcsuite drivers to its own plugin
From: Luiz Augusto von Dentz @ 2011-02-22 14:53 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
This make it easier to enable/disable this funcionality as a whole.
---
Makefile.am | 6 +-
configure.ac | 9 +-
plugins/ftp.c | 165 ++------------------------
plugins/nokia-backup.c | 309 ------------------------------------------------
4 files changed, 16 insertions(+), 473 deletions(-)
delete mode 100644 plugins/nokia-backup.c
diff --git a/Makefile.am b/Makefile.am
index fc996ec..d32d613 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,9 +43,9 @@ endif
builtin_modules += filesystem
builtin_sources += plugins/filesystem.c plugins/filesystem.h
-if NOKIA_BACKUP
-builtin_modules += backup
-builtin_sources += plugins/nokia-backup.c
+if NOKIA_PCSUITE
+builtin_modules += pcsuite
+builtin_sources += plugins/pcsuite.c
endif
builtin_modules += opp
diff --git a/configure.ac b/configure.ac
index da8fb64..a17d0ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,12 +158,11 @@ AC_ARG_ENABLE(usb, AC_HELP_STRING([--enable-usb],
AM_CONDITIONAL(USB, test "${enable_usb}" = "yes" &&
test "${enable_server}" != "no")
-AC_ARG_ENABLE(nokia_backup, AC_HELP_STRING([--enable-nokia-backup],
- [enable nokia-backup plugin]), [
- enable_nokia_backup=${enableval}
+AC_ARG_ENABLE(pcsuite, AC_HELP_STRING([--enable-pcsuite],
+ [enable Nokia PcSuite plugin]), [
+ enable_pcsuite=${enableval}
])
-AM_CONDITIONAL(NOKIA_BACKUP, test "${enable_nokia_backup}" = "yes" &&
- test "${enable_server}" != "no")
+AM_CONDITIONAL(NOKIA_PCSUITE, test "${enable_pcsuite}" = "yes")
AC_ARG_ENABLE(client, AC_HELP_STRING([--disable-client],
[disable compilation of OBEX client]), [
diff --git a/plugins/ftp.c b/plugins/ftp.c
index 38d058c..b6ee75b 100644
--- a/plugins/ftp.c
+++ b/plugins/ftp.c
@@ -50,6 +50,7 @@
#include "dbus.h"
#include "mimetype.h"
#include "service.h"
+#include "ftp.h"
#define LST_TYPE "x-obex/folder-listing"
#define CAP_TYPE "x-obex/capability"
@@ -189,7 +190,7 @@ static int get_by_type(struct ftp_session *ftp, const char *type)
return err;
}
-static void *ftp_connect(struct obex_session *os, int *err)
+void *ftp_connect(struct obex_session *os, int *err)
{
struct ftp_session *ftp;
const char *root_folder;
@@ -212,8 +213,8 @@ static void *ftp_connect(struct obex_session *os, int *err)
return ftp;
}
-static int ftp_get(struct obex_session *os, obex_object_t *obj,
- gboolean *stream, void *user_data)
+int ftp_get(struct obex_session *os, obex_object_t *obj, gboolean *stream,
+ void *user_data)
{
struct ftp_session *ftp = user_data;
const char *type = obex_get_type(os);
@@ -254,7 +255,7 @@ static int ftp_delete(struct ftp_session *ftp, const char *name)
return ret;
}
-static int ftp_chkput(struct obex_session *os, void *user_data)
+int ftp_chkput(struct obex_session *os, void *user_data)
{
struct ftp_session *ftp = user_data;
const char *name = obex_get_name(os);
@@ -278,8 +279,7 @@ static int ftp_chkput(struct obex_session *os, void *user_data)
return ret;
}
-static int ftp_put(struct obex_session *os, obex_object_t *obj,
- void *user_data)
+int ftp_put(struct obex_session *os, obex_object_t *obj, void *user_data)
{
struct ftp_session *ftp = user_data;
const char *name = obex_get_name(os);
@@ -299,8 +299,7 @@ static int ftp_put(struct obex_session *os, obex_object_t *obj,
return 0;
}
-static int ftp_setpath(struct obex_session *os, obex_object_t *obj,
- void *user_data)
+int ftp_setpath(struct obex_session *os, obex_object_t *obj, void *user_data)
{
struct ftp_session *ftp = user_data;
const char *root_folder, *name;
@@ -404,7 +403,7 @@ done:
return err;
}
-static void ftp_disconnect(struct obex_session *os, void *user_data)
+void ftp_disconnect(struct obex_session *os, void *user_data)
{
struct ftp_session *ftp = user_data;
@@ -416,145 +415,6 @@ static void ftp_disconnect(struct obex_session *os, void *user_data)
g_free(ftp);
}
-static void *pcsuite_connect(struct obex_session *os, int *err)
-{
- struct pcsuite_session *pcsuite;
- struct ftp_session *ftp;
- int fd;
- char *filename;
-
- DBG("");
-
- ftp = ftp_connect(os, err);
- if (ftp == NULL)
- return NULL;
-
- filename = g_build_filename(g_get_home_dir(), ".pcsuite", NULL);
-
- fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0644);
- if (fd < 0 && errno != EEXIST) {
- error("open(%s): %s(%d)", filename, strerror(errno), errno);
- goto fail;
- }
-
- /* Try to remove the file before retrying since it could be
- that some process left/crash without removing it */
- if (fd < 0) {
- if (remove(filename) < 0) {
- error("remove(%s): %s(%d)", filename, strerror(errno),
- errno);
- goto fail;
- }
-
- fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0644);
- if (fd < 0) {
- error("open(%s): %s(%d)", filename, strerror(errno),
- errno);
- goto fail;
- }
- }
-
- DBG("%s created", filename);
-
- pcsuite = g_new0(struct pcsuite_session, 1);
- pcsuite->ftp = ftp;
- pcsuite->lock_file = filename;
- pcsuite->fd = fd;
-
- DBG("session %p created", pcsuite);
-
- if (err)
- *err = 0;
-
- return pcsuite;
-
-fail:
- if (ftp)
- ftp_disconnect(os, ftp);
- if (err)
- *err = -errno;
-
- g_free(filename);
-
- return NULL;
-}
-
-static int pcsuite_get(struct obex_session *os, obex_object_t *obj,
- gboolean *stream, void *user_data)
-{
- struct pcsuite_session *pcsuite = user_data;
-
- DBG("%p", pcsuite);
-
- return ftp_get(os, obj, stream, pcsuite->ftp);
-}
-
-static int pcsuite_chkput(struct obex_session *os, void *user_data)
-{
- struct pcsuite_session *pcsuite = user_data;
-
- DBG("%p", pcsuite);
-
- return ftp_chkput(os, pcsuite->ftp);
-}
-
-static int pcsuite_put(struct obex_session *os, obex_object_t *obj,
- void *user_data)
-{
- struct pcsuite_session *pcsuite = user_data;
-
- DBG("%p", pcsuite);
-
- return ftp_put(os, obj, pcsuite->ftp);
-}
-
-static int pcsuite_setpath(struct obex_session *os, obex_object_t *obj,
- void *user_data)
-{
- struct pcsuite_session *pcsuite = user_data;
-
- DBG("%p", pcsuite);
-
- return ftp_setpath(os, obj, pcsuite->ftp);
-}
-
-static void pcsuite_disconnect(struct obex_session *os, void *user_data)
-{
- struct pcsuite_session *pcsuite = user_data;
-
- DBG("%p", pcsuite);
-
- if (pcsuite->fd >= 0)
- close(pcsuite->fd);
-
- if (pcsuite->lock_file) {
- remove(pcsuite->lock_file);
- g_free(pcsuite->lock_file);
- }
-
- if (pcsuite->ftp)
- ftp_disconnect(os, pcsuite->ftp);
-
- g_free(pcsuite);
-}
-
-static struct obex_service_driver pcsuite = {
- .name = "Nokia OBEX PC Suite Services",
- .service = OBEX_PCSUITE,
- .channel = PCSUITE_CHANNEL,
- .record = PCSUITE_RECORD,
- .target = FTP_TARGET,
- .target_size = TARGET_SIZE,
- .who = PCSUITE_WHO,
- .who_size = PCSUITE_WHO_SIZE,
- .connect = pcsuite_connect,
- .get = pcsuite_get,
- .put = pcsuite_put,
- .chkput = pcsuite_chkput,
- .setpath = pcsuite_setpath,
- .disconnect = pcsuite_disconnect
-};
-
static struct obex_service_driver ftp = {
.name = "File Transfer server",
.service = OBEX_FTP,
@@ -572,19 +432,12 @@ static struct obex_service_driver ftp = {
static int ftp_init(void)
{
- int err;
-
- err = obex_service_driver_register(&ftp);
- if (err < 0)
- return err;
-
- return obex_service_driver_register(&pcsuite);
+ return obex_service_driver_register(&ftp);
}
static void ftp_exit(void)
{
obex_service_driver_unregister(&ftp);
- obex_service_driver_unregister(&pcsuite);
}
OBEX_PLUGIN_DEFINE(ftp, ftp_init, ftp_exit)
diff --git a/plugins/nokia-backup.c b/plugins/nokia-backup.c
deleted file mode 100644
index cf17e16..0000000
--- a/plugins/nokia-backup.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- *
- * OBEX Server
- *
- * Copyright (C) 2010 Nokia Corporation
- * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org>
- *
- *
- * 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
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/statvfs.h>
-#include <fcntl.h>
-#include <wait.h>
-
-#include <glib.h>
-#include "gdbus.h"
-
-
-#include <openobex/obex.h>
-#include <openobex/obex_const.h>
-
-#include "plugin.h"
-#include "log.h"
-#include "obex.h"
-#include "mimetype.h"
-#include "service.h"
-
-#define BACKUP_BUS_NAME "com.nokia.backup.plugin"
-#define BACKUP_PATH "/com/nokia/backup"
-#define BACKUP_PLUGIN_INTERFACE "com.nokia.backup.plugin"
-#define BACKUP_DBUS_TIMEOUT (1000 * 60 * 15)
-
-static const uint8_t FTP_TARGET[TARGET_SIZE] = {
- 0xF9, 0xEC, 0x7B, 0xC4, 0x95, 0x3C, 0x11, 0xD2,
- 0x98, 0x4E, 0x52, 0x54, 0x00, 0xDC, 0x9E, 0x09 };
-
-struct backup_object{
- gchar *cmd;
- int fd;
- int oflag;
- int error_code;
- mode_t mode;
- DBusPendingCall *pending_call;
- DBusConnection *conn;
-};
-
-static void on_backup_dbus_notify(DBusPendingCall *pending_call,
- void *user_data)
-{
- struct backup_object *obj = user_data;
- DBusMessage *reply;
- const char *filename;
- int error_code;
-
- DBG("Notification received for pending call - %s", obj->cmd);
-
- reply = dbus_pending_call_steal_reply(pending_call);
-
- if (reply && dbus_message_get_args(reply, NULL, DBUS_TYPE_INT32,
- &error_code, DBUS_TYPE_STRING,
- &filename, DBUS_TYPE_INVALID)) {
-
- obj->error_code = error_code;
-
- if (filename) {
- DBG("Notification - file path = %s, error_code = %d",
- filename, error_code);
- if (error_code == 0)
- obj->fd = open(filename,obj->oflag,obj->mode);
- }
-
- } else
- DBG("Notification timed out or connection got closed");
-
- if (reply)
- dbus_message_unref(reply);
-
- dbus_pending_call_unref(pending_call);
- obj->pending_call = NULL;
- dbus_connection_unref(obj->conn);
- obj->conn = NULL;
-
- if (obj->fd >= 0) {
- DBG("File opened, setting io flags, cmd = %s",
- obj->cmd);
- if (obj->oflag == O_RDONLY)
- obex_object_set_io_flags(user_data, G_IO_IN, 0);
- else
- obex_object_set_io_flags(user_data, G_IO_OUT, 0);
- } else {
- DBG("File open error, setting io error, cmd = %s",
- obj->cmd);
- obex_object_set_io_flags(user_data, G_IO_ERR, -EPERM);
- }
-}
-
-static gboolean send_backup_dbus_message(const char *oper,
- struct backup_object *obj,
- size_t *size)
-{
- DBusConnection *conn;
- DBusMessage *msg;
- DBusPendingCall *pending_call;
- gboolean ret = FALSE;
- dbus_uint32_t file_size;
-
- file_size = size ? *size : 0;
-
- conn = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL);
-
- if (conn == NULL)
- return FALSE;
-
- msg = dbus_message_new_method_call(BACKUP_BUS_NAME, BACKUP_PATH,
- BACKUP_PLUGIN_INTERFACE,
- "request");
- if (msg == NULL) {
- dbus_connection_unref(conn);
- return FALSE;
- }
-
- dbus_message_append_args(msg, DBUS_TYPE_STRING, &oper,
- DBUS_TYPE_STRING, &obj->cmd,
- DBUS_TYPE_INT32, &file_size,
- DBUS_TYPE_INVALID);
-
- if (strcmp(oper, "open") == 0) {
- ret = dbus_connection_send_with_reply(conn, msg, &pending_call,
- BACKUP_DBUS_TIMEOUT);
- dbus_message_unref(msg);
- if (ret) {
- obj->conn = conn;
- obj->pending_call = pending_call;
- ret = dbus_pending_call_set_notify(pending_call,
- on_backup_dbus_notify,
- obj, NULL);
- } else
- dbus_connection_unref(conn);
- } else {
- ret = dbus_connection_send(conn, msg, NULL);
- dbus_message_unref(msg);
- dbus_connection_unref(conn);
- }
-
- return ret;
-}
-
-static void *backup_open(const char *name, int oflag, mode_t mode,
- void *context, size_t *size, int *err)
-{
- struct backup_object *obj = g_new0(struct backup_object, 1);
-
- DBG("cmd = %s", name);
-
- obj->cmd = g_path_get_basename(name);
- obj->oflag = oflag;
- obj->mode = mode;
- obj->fd = -1;
- obj->pending_call = NULL;
- obj->conn = NULL;
- obj->error_code = 0;
-
- if (send_backup_dbus_message("open", obj, size) == FALSE) {
- g_free(obj);
- obj = NULL;
- }
-
- if (err)
- *err = 0;
-
- return obj;
-}
-
-static int backup_close(void *object)
-{
- struct backup_object *obj = object;
- size_t size = 0;
-
- DBG("cmd = %s", obj->cmd);
-
- if (obj->fd != -1)
- close(obj->fd);
-
- if (obj->pending_call) {
- dbus_pending_call_cancel(obj->pending_call);
- dbus_pending_call_unref(obj->pending_call);
- dbus_connection_unref(obj->conn);
- }
-
- send_backup_dbus_message("close", obj, &size);
-
- g_free(obj->cmd);
- g_free(obj);
-
- return 0;
-}
-
-static ssize_t backup_read(void *object, void *buf, size_t count,
- uint8_t *hi, unsigned int *flags)
-{
- struct backup_object *obj = object;
- ssize_t ret = 0;
-
- *hi = OBEX_HDR_BODY;
-
- if (flags)
- *flags = 0;
-
- if (obj->pending_call) {
- DBG("cmd = %s, IN WAITING STAGE", obj->cmd);
- return -EAGAIN;
- }
-
- if (obj->fd != -1) {
- DBG("cmd = %s, READING DATA", obj->cmd);
- ret = read(obj->fd, buf, count);
- if (ret < 0)
- ret = -errno;
- } else {
- DBG("cmd = %s, PERMANENT FAILURE", obj->cmd);
- ret = obj->error_code ? -obj->error_code : -ENOENT;
- }
-
- return ret;
-}
-
-static ssize_t backup_write(void *object, const void *buf, size_t count)
-{
- struct backup_object *obj = object;
- ssize_t ret = 0;
-
- if (obj->pending_call) {
- DBG("cmd = %s, IN WAITING STAGE", obj->cmd);
- return -EAGAIN;
- }
-
- if (obj->fd != -1) {
- ret = write(obj->fd, buf, count);
-
- DBG("cmd = %s, WRITTING", obj->cmd);
-
- if (ret < 0) {
- error("backup: cmd = %s", obj->cmd);
- ret = -errno;
- }
- } else {
- error("backup: cmd = %s", obj->cmd);
- ret = obj->error_code ? -obj->error_code : -ENOENT;
- }
-
- return ret;
-}
-
-static int backup_flush(void *object)
-{
- DBG("%p", object);
-
- return 0;
-}
-
-static struct obex_mime_type_driver backup = {
- .target = FTP_TARGET,
- .target_size = TARGET_SIZE,
- .mimetype = "application/vnd.nokia-backup",
- .open = backup_open,
- .close = backup_close,
- .read = backup_read,
- .write = backup_write,
- .flush = backup_flush,
-};
-
-static int backup_init(void)
-{
- return obex_mime_type_driver_register(&backup);
-}
-
-static void backup_exit(void)
-{
- obex_mime_type_driver_unregister(&backup);
-}
-
-OBEX_PLUGIN_DEFINE(backup, backup_init, backup_exit)
--
1.7.1
^ permalink raw reply related
* [PATCH 5/5 v2] Remove redundante check for server when checking for usb
From: Luiz Augusto von Dentz @ 2011-02-22 14:53 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
There is a check for this already on Makefile.am
---
configure.ac | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index a17d0ca..9194843 100644
--- a/configure.ac
+++ b/configure.ac
@@ -155,8 +155,7 @@ AC_ARG_ENABLE(usb, AC_HELP_STRING([--enable-usb],
[enable usb plugin]), [
enable_usb=${enableval}
])
-AM_CONDITIONAL(USB, test "${enable_usb}" = "yes" &&
- test "${enable_server}" != "no")
+AM_CONDITIONAL(USB, test "${enable_usb}" = "yes")
AC_ARG_ENABLE(pcsuite, AC_HELP_STRING([--enable-pcsuite],
[enable Nokia PcSuite plugin]), [
--
1.7.1
^ permalink raw reply related
* Re: [RFC v2 01/14] Move 64 and 128 bits byte order functions to bluetooth.h
From: Anderson Lizardo @ 2011-02-22 17:16 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1298068173-16518-2-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
On Fri, Feb 18, 2011 at 7:29 PM, Claudio Takahasi
<claudio.takahasi@openbossa.org> wrote:
> ---
> attrib/example.c | 1 +
> attrib/gatt.c | 1 +
> attrib/interactive.c | 1 +
> health/hdp_manager.c | 1 +
> health/mcap_sync.c | 17 -----------------
> lib/bluetooth.h | 41 +++++++++++++++++++++++++++++++++++++++++
> lib/sdp.c | 43 -------------------------------------------
> lib/sdp.h | 4 ----
> src/sdp-xml.c | 1 +
> test/hciemu.c | 16 ----------------
> 10 files changed, 46 insertions(+), 80 deletions(-)
Can we have this patch applied upstream? It seems a good refactoring
because removes duplicated code.
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* Re: [PATCH] Fix not setting global mode when SetProperty is used
From: Johan Hedberg @ 2011-02-22 17:20 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1298366773-5781-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Tue, Feb 22, 2011, Luiz Augusto von Dentz wrote:
> Global mode should be overwrite if user application change the adapter
> mode by using SetProperty while there are sessions active, otherwise
> when this sessions are released the mode restored will be the global
> mode from before the sessions were created and not the mode set with
> SetProperty.
> ---
> src/adapter.c | 14 +++++++++++---
> 1 files changed, 11 insertions(+), 3 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [RFC v2 03/14] Add att_get_u128
From: Anderson Lizardo @ 2011-02-22 17:24 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1298068173-16518-4-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
On Fri, Feb 18, 2011 at 7:29 PM, Claudio Takahasi
<claudio.takahasi@openbossa.org> wrote:
> Function to convert 128-bits values from little endian to host
> order. Different than SDP, ATT uses little endian format.
> ---
> attrib/att.c | 12 ++++++++----
> attrib/att.h | 10 ++++++++++
> attrib/gatt.c | 13 ++++++++-----
> attrib/gatttool.c | 6 ++++--
> 4 files changed, 30 insertions(+), 11 deletions(-)
This patch could be refactored by adding a hton128() call before
calling sdp_uuid128_create(). This way we fix the valid bug where we
are not passing big-endian ordered bytes to sdp_uuid28_create(). What
do you think?
At least the att_get_u128() function is still valid and needs to be
applied IMHO.
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* Re: [RFC v2 13/14] Add att_put_u128
From: Anderson Lizardo @ 2011-02-22 17:27 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1298068173-16518-14-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
On Fri, Feb 18, 2011 at 7:29 PM, Claudio Takahasi
<claudio.takahasi@openbossa.org> wrote:
> ATT protocol uses little endian byte order, before to add a UUID128
> value in the PDU it needs to converted from host order to little endian.
> ---
> attrib/att.c | 4 ++--
> attrib/att.h | 7 +++++++
> 2 files changed, 9 insertions(+), 2 deletions(-)
Similarly, this part of the original code is still buggy and we need a
ntoh128() call before att_put_u128().
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply
* [PATCH] Fix potential bug in le_advertising_report()
From: Andre Guedes @ 2011-02-22 17:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andre Guedes
In the current implementation of le_advertising_report(), the variable
'info' has an invalid memory address after the 'for' loop. If 'info'
is dereferenced it will access invalid memory.
This patch fixes this potential bug and improves the code's readability.
---
plugins/hciops.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/plugins/hciops.c b/plugins/hciops.c
index c3d6290..fd19ef4 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -2184,14 +2184,19 @@ static inline void le_advertising_report(int index, evt_le_meta_event *meta)
{
struct dev_info *dev = &devs[index];
le_advertising_info *info;
- uint8_t num, i;
+ uint8_t num_reports;
+ const uint8_t RSSI_SIZE = 1;
- num = meta->data[0];
- info = (le_advertising_info *) (meta->data + 1);
+ num_reports = meta->data[0];
- for (i = 0; i < num; i++) {
+ info = (le_advertising_info *) &meta->data[1];
+ btd_event_advertising_report(&dev->bdaddr, info);
+ num_reports--;
+
+ while (num_reports--) {
+ info = (le_advertising_info *) (info->data + info->length +
+ RSSI_SIZE);
btd_event_advertising_report(&dev->bdaddr, info);
- info = (le_advertising_info *) (info->data + info->length + 1);
}
}
--
1.7.1
^ permalink raw reply related
* [PATCH v2] Bluetooth: Use ERR_PTR as return error from hci_connect
From: anderson.briglia @ 2011-02-22 19:10 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ville Tervo, Anderson Briglia
From: Ville Tervo <ville.tervo@nokia.com>
Use ERR_PTR mechanism to return error from hci_connect.
Signed-off-by: Ville Tervo <ville.tervo@nokia.com>
Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org>
---
net/bluetooth/hci_conn.c | 4 ++--
net/bluetooth/l2cap_core.c | 10 ++++------
net/bluetooth/mgmt.c | 4 ++--
net/bluetooth/sco.c | 6 +++---
4 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 4504cb6..7a6f56b 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -431,10 +431,10 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
if (type == LE_LINK) {
le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
if (le)
- return NULL;
+ return ERR_PTR(-EBUSY);
le = hci_conn_add(hdev, LE_LINK, dst);
if (!le)
- return NULL;
+ return ERR_PTR(-ENOMEM);
if (le->state == BT_OPEN)
hci_le_connect(le);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index efcef0d..e76e9e5 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -841,7 +841,7 @@ int l2cap_do_connect(struct sock *sk)
struct hci_conn *hcon;
struct hci_dev *hdev;
__u8 auth_type;
- int err;
+ int err = 0;
BT_DBG("%s -> %s psm 0x%2.2x", batostr(src), batostr(dst),
l2cap_pi(sk)->psm);
@@ -852,8 +852,6 @@ int l2cap_do_connect(struct sock *sk)
hci_dev_lock_bh(hdev);
- err = -ENOMEM;
-
auth_type = l2cap_get_auth_type(sk);
if (l2cap_pi(sk)->dcid == L2CAP_CID_LE_DATA)
@@ -863,8 +861,10 @@ int l2cap_do_connect(struct sock *sk)
hcon = hci_connect(hdev, ACL_LINK, dst,
l2cap_pi(sk)->sec_level, auth_type);
- if (!hcon)
+ if (IS_ERR(hcon)) {
+ err = PTR_ERR(hcon);
goto done;
+ }
conn = l2cap_conn_add(hcon, 0);
if (!conn) {
@@ -872,8 +872,6 @@ int l2cap_do_connect(struct sock *sk)
goto done;
}
- err = 0;
-
/* Update source addr of the socket */
bacpy(src, conn->src);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 982becd..37cabb5 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1149,8 +1149,8 @@ static int pair_device(struct sock *sk, unsigned char *data, u16 len)
}
conn = hci_connect(hdev, ACL_LINK, &cp->bdaddr, sec_level, auth_type);
- if (!conn) {
- err = -ENOMEM;
+ if (IS_ERR(conn)) {
+ err = PTR_ERR(conn);
goto unlock;
}
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index c9348dd..26f2f04 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -190,16 +190,16 @@ static int sco_connect(struct sock *sk)
hci_dev_lock_bh(hdev);
- err = -ENOMEM;
-
if (lmp_esco_capable(hdev) && !disable_esco)
type = ESCO_LINK;
else
type = SCO_LINK;
hcon = hci_connect(hdev, type, dst, BT_SECURITY_LOW, HCI_AT_NO_BONDING);
- if (!hcon)
+ if (IS_ERR(hcon)) {
+ err = PTR_ERR(hcon);
goto done;
+ }
conn = sco_conn_add(hcon, 0);
if (!conn) {
--
1.7.1
^ permalink raw reply related
* [PATCH v2 1/7] Improve help messages in interactive gatttool
From: Sheldon Demario @ 2011-02-22 19:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <1298328606-7993-1-git-send-email-sheldon.demario@openbossa.org>
Includes the parameters info on help.
---
attrib/interactive.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/attrib/interactive.c b/attrib/interactive.c
index edc465a..b491314 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -217,13 +217,19 @@ static void cmd_primary(int argcp, char **argvp)
static struct {
const char *cmd;
void (*func)(int argcp, char **argvp);
+ const char *params;
const char *desc;
} commands[] = {
- { "help", cmd_help, "Show this help"},
- { "exit", cmd_exit, "Exit interactive mode"},
- { "connect", cmd_connect, "Connect to a remote device"},
- { "disconnect", cmd_disconnect, "Disconnect from a remote device"},
- { "primary", cmd_primary, "Primary Service Discovery"},
+ { "help", cmd_help, "",
+ "Show this help"},
+ { "exit", cmd_exit, "",
+ "Exit interactive mode" },
+ { "connect", cmd_connect, "[address]",
+ "Connect to a remote device" },
+ { "disconnect", cmd_disconnect, "",
+ "Disconnect from a remote device" },
+ { "primary", cmd_primary, "[UUID]",
+ "Primary Service Discovery" },
{ NULL, NULL, NULL}
};
@@ -232,7 +238,8 @@ 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);
+ printf("%-15s %-25s %s\n", commands[i].cmd,
+ commands[i].params, commands[i].desc);
}
static void parse_line(char *line_read)
--
1.7.1
^ permalink raw reply related
* [PATCH v2 2/7] Add Characteristics Discovery option to interactive gatttool
From: Sheldon Demario @ 2011-02-22 19:11 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <1298328606-7993-1-git-send-email-sheldon.demario@openbossa.org>
---
attrib/interactive.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 61 insertions(+), 0 deletions(-)
diff --git a/attrib/interactive.c b/attrib/interactive.c
index b491314..7cc03bc 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -22,6 +22,7 @@
*/
#include <string.h>
#include <stdlib.h>
+#include <errno.h>
#include <stdio.h>
#include <glib.h>
@@ -145,6 +146,29 @@ static void primary_by_uuid_cb(GSList *ranges, guint8 status,
rl_forced_update_display();
}
+static void char_cb(GSList *characteristics, guint8 status, gpointer user_data)
+{
+ GSList *l;
+
+ if (status) {
+ printf("Discover all characteristics failed: %s\n",
+ att_ecode2str(status));
+ return;
+ }
+
+ printf("\n");
+ for (l = characteristics; l; l = l->next) {
+ struct att_char *chars = l->data;
+
+ printf("handle: 0x%04x, char properties: 0x%02x, char value "
+ "handle: 0x%04x, uuid: %s\n", chars->handle,
+ chars->properties, chars->value_handle,
+ chars->uuid);
+ }
+
+ rl_forced_update_display();
+}
+
static void cmd_exit(int argcp, char **argvp)
{
rl_callback_handler_remove();
@@ -214,6 +238,41 @@ static void cmd_primary(int argcp, char **argvp)
gatt_discover_primary(attrib, &uuid, primary_by_uuid_cb, NULL);
}
+static void cmd_char(int argcp, char **argvp)
+{
+ int start = 0x0001;
+ int end = 0xffff;
+
+ if (conn_state != STATE_CONNECTED) {
+ printf("Command failed: disconnected\n");
+ return;
+ }
+
+ if (argcp > 1) {
+ char *e;
+
+ start = strtoll(argvp[1], &e, 16);
+ if (errno != 0 || *e != '\0') {
+ printf("Invalid start handle: %s\n", argvp[1]);
+ return;
+ }
+ }
+
+ if (argcp > 2) {
+ char *e;
+
+ end = strtoll(argvp[2], &e, 16);
+ if (errno != 0 || *e != '\0') {
+ printf("Invalid end handle: %s\n", argvp[2]);
+ return;
+ }
+ }
+
+ gatt_discover_char(attrib, start, end, char_cb, NULL);
+
+ return;
+}
+
static struct {
const char *cmd;
void (*func)(int argcp, char **argvp);
@@ -230,6 +289,8 @@ static struct {
"Disconnect from a remote device" },
{ "primary", cmd_primary, "[UUID]",
"Primary Service Discovery" },
+ { "characteristics", cmd_char, "[start hnd] [end hnd]",
+ "Characteristics Discovery" },
{ NULL, NULL, NULL}
};
--
1.7.1
^ permalink raw reply related
* [PATCH v2 3/7] Create helper functions to deal with handles on interactive gatttool
From: Sheldon Demario @ 2011-02-22 19:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <1298328606-7993-1-git-send-email-sheldon.demario@openbossa.org>
---
attrib/interactive.c | 46 ++++++++++++++++++++++++++++++----------------
1 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 7cc03bc..e9f6019 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -238,36 +238,50 @@ static void cmd_primary(int argcp, char **argvp)
gatt_discover_primary(attrib, &uuid, primary_by_uuid_cb, NULL);
}
-static void cmd_char(int argcp, char **argvp)
+static int strtohandle(int *dst, const char *src)
{
- int start = 0x0001;
- int end = 0xffff;
+ char *e;
- if (conn_state != STATE_CONNECTED) {
- printf("Command failed: disconnected\n");
- return;
+ *dst = strtoll(src, &e, 16);
+ if (errno != 0 || *e != '\0') {
+ return -1;
}
- if (argcp > 1) {
- char *e;
+ return 0;
+}
- start = strtoll(argvp[1], &e, 16);
- if (errno != 0 || *e != '\0') {
+static int set_handles(int *start, int *end, int argcp, char **argvp)
+{
+ if (argcp > 1) {
+ if (strtohandle(start, argvp[1])) {
printf("Invalid start handle: %s\n", argvp[1]);
- return;
+ return -1;
}
}
if (argcp > 2) {
- char *e;
-
- end = strtoll(argvp[2], &e, 16);
- if (errno != 0 || *e != '\0') {
+ if (strtohandle(end, argvp[2])) {
printf("Invalid end handle: %s\n", argvp[2]);
- return;
+ return -1;
}
}
+ return 0;
+}
+
+static void cmd_char(int argcp, char **argvp)
+{
+ int start = 0x0001;
+ int end = 0xffff;
+
+ if (conn_state != STATE_CONNECTED) {
+ printf("Command failed: disconnected\n");
+ return;
+ }
+
+ if (set_handles(&start, &end, argcp, argvp))
+ return;
+
gatt_discover_char(attrib, start, end, char_cb, NULL);
return;
--
1.7.1
^ permalink raw reply related
* [PATCH v2 4/7] Add Characteristics Descriptor Discovery option in interactive gatttool
From: Sheldon Demario @ 2011-02-22 19:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <1298328606-7993-1-git-send-email-sheldon.demario@openbossa.org>
---
attrib/interactive.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 61 insertions(+), 0 deletions(-)
diff --git a/attrib/interactive.c b/attrib/interactive.c
index e9f6019..9389686 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -169,6 +169,47 @@ static void char_cb(GSList *characteristics, guint8 status, gpointer user_data)
rl_forced_update_display();
}
+static void char_desc_cb(guint8 status, const guint8 *pdu, guint16 plen,
+ gpointer user_data)
+{
+ struct att_data_list *list;
+ guint8 format;
+ int i;
+
+ if (status != 0) {
+ printf("Discover all characteristic descriptors failed: "
+ "%s\n", att_ecode2str(status));
+ return;
+ }
+
+ list = dec_find_info_resp(pdu, plen, &format);
+ if (list == NULL)
+ return;
+
+ printf("\n");
+ for (i = 0; i < list->num; i++) {
+ char uuidstr[MAX_LEN_UUID_STR];
+ uint16_t handle;
+ uint8_t *value;
+ uuid_t uuid;
+
+ value = list->data[i];
+ handle = att_get_u16(value);
+
+ if (format == 0x01)
+ sdp_uuid16_create(&uuid, att_get_u16(&value[2]));
+ else
+ sdp_uuid128_create(&uuid, &value[2]);
+
+ sdp_uuid2strn(&uuid, uuidstr, MAX_LEN_UUID_STR);
+ printf("handle: 0x%04x, uuid: %s\n", handle, uuidstr);
+ }
+
+ att_data_list_free(list);
+
+ rl_forced_update_display();
+}
+
static void cmd_exit(int argcp, char **argvp)
{
rl_callback_handler_remove();
@@ -287,6 +328,24 @@ static void cmd_char(int argcp, char **argvp)
return;
}
+static void cmd_char_desc(int argcp, char **argvp)
+{
+ int start = 0x0001;
+ int end = 0xffff;
+
+ if (conn_state != STATE_CONNECTED) {
+ printf("Command failed: disconnected\n");
+ return;
+ }
+
+ if (set_handles(&start, &end, argcp, argvp))
+ return;
+
+ gatt_find_info(attrib, start, end, char_desc_cb, NULL);
+
+ return;
+}
+
static struct {
const char *cmd;
void (*func)(int argcp, char **argvp);
@@ -305,6 +364,8 @@ static struct {
"Primary Service Discovery" },
{ "characteristics", cmd_char, "[start hnd] [end hnd]",
"Characteristics Discovery" },
+ { "char-desc", cmd_char_desc, "[start hnd] [end hnd]",
+ "Characteristics Descriptor Discovery" },
{ NULL, NULL, NULL}
};
--
1.7.1
^ permalink raw reply related
* [PATCH v2 5/7] Add characteristics read options in interactive gatttool
From: Sheldon Demario @ 2011-02-22 19:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <1298328606-7993-1-git-send-email-sheldon.demario@openbossa.org>
---
Add forgoten conn_state check on cmd_read_hnd()
attrib/interactive.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 146 insertions(+), 1 deletions(-)
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 9389686..a1c5671 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -50,6 +50,13 @@ static gchar *opt_sec_level = NULL;
static int opt_psm = 0;
static int opt_mtu = 0;
+struct characteristic_data {
+ uint16_t orig_start;
+ uint16_t start;
+ uint16_t end;
+ uuid_t uuid;
+};
+
static void cmd_help(int argcp, char **argvp);
enum state {
@@ -210,6 +217,79 @@ static void char_desc_cb(guint8 status, const guint8 *pdu, guint16 plen,
rl_forced_update_display();
}
+static void char_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
+ gpointer user_data)
+{
+ uint8_t value[ATT_MAX_MTU];
+ int i, vlen;
+
+ if (status != 0) {
+ printf("Characteristic value/descriptor read failed: %s\n",
+ att_ecode2str(status));
+ return;
+ }
+
+ if (!dec_read_resp(pdu, plen, value, &vlen)) {
+ printf("Protocol error\n");
+ return;
+ }
+
+ printf("\nCharacteristic value/descriptor: ");
+ for (i = 0; i < vlen; i++)
+ printf("%02x ", value[i]);
+ printf("\n");
+
+ rl_forced_update_display();
+}
+
+static void char_read_by_uuid_cb(guint8 status, const guint8 *pdu,
+ guint16 plen, gpointer user_data)
+{
+ struct characteristic_data *char_data = user_data;
+ struct att_data_list *list;
+ int i;
+
+ if (status == ATT_ECODE_ATTR_NOT_FOUND &&
+ char_data->start != char_data->orig_start)
+ goto done;
+
+ if (status != 0) {
+ printf("Read characteristics by UUID failed: %s\n",
+ att_ecode2str(status));
+ goto done;
+ }
+
+ list = dec_read_by_type_resp(pdu, plen);
+ if (list == NULL)
+ goto done;
+
+ for (i = 0; i < list->num; i++) {
+ uint8_t *value = list->data[i];
+ int j;
+
+ char_data->start = att_get_u16(value) + 1;
+
+ printf("\nhandle: 0x%04x \t value: ", att_get_u16(value));
+ value += 2;
+ for (j = 0; j < list->len - 2; j++, value++)
+ printf("%02x ", *value);
+ printf("\n");
+ }
+
+ att_data_list_free(list);
+
+ gatt_read_char_by_uuid(attrib, char_data->start, char_data->end,
+ &char_data->uuid, char_read_by_uuid_cb,
+ char_data);
+
+ rl_forced_update_display();
+
+ return;
+
+done:
+ g_free(char_data);
+}
+
static void cmd_exit(int argcp, char **argvp)
{
rl_callback_handler_remove();
@@ -346,6 +426,67 @@ static void cmd_char_desc(int argcp, char **argvp)
return;
}
+static void cmd_read_hnd(int argcp, char **argvp)
+{
+ int handle;
+
+ if (conn_state != STATE_CONNECTED) {
+ printf("Command failed: disconnected\n");
+ return;
+ }
+
+ if (argcp < 2) {
+ printf("Missing argument: handle\n");
+ return;
+ }
+
+ if (strtohandle(&handle, argvp[1])) {
+ printf("Invalid handle: %s\n", argvp[1]);
+ return;
+ }
+
+ gatt_read_char(attrib, handle, char_read_cb, attrib);
+
+ return;
+}
+
+static void cmd_read_uuid(int argcp, char **argvp)
+{
+ struct characteristic_data *char_data;
+ int start = 0x0001;
+ int end = 0xffff;
+ uuid_t uuid;
+
+ if (conn_state != STATE_CONNECTED) {
+ printf("Command failed: disconnected\n");
+ return;
+ }
+
+ if (argcp < 2) {
+ printf("Missing argument: UUID\n");
+ return;
+ }
+
+ if (bt_string2uuid(&uuid, argvp[1]) < 0) {
+ printf("Invalid UUID\n");
+ return;
+ }
+
+ if (set_handles(&start, &end, argcp - 1, argvp + 1))
+ return;
+
+ char_data = g_new(struct characteristic_data, 1);
+ char_data->orig_start = start;
+ char_data->start = start;
+ char_data->end = end;
+ char_data->uuid = uuid;
+
+ gatt_read_char_by_uuid(attrib, start, end, &char_data->uuid,
+ char_read_by_uuid_cb, char_data);
+
+ return;
+}
+
static struct {
const char *cmd;
void (*func)(int argcp, char **argvp);
@@ -366,6 +507,10 @@ static struct {
"Characteristics Discovery" },
{ "char-desc", cmd_char_desc, "[start hnd] [end hnd]",
"Characteristics Descriptor Discovery" },
+ { "char-read-hnd", cmd_read_hnd, "<handle>",
+ "Characteristics Value/Descriptor Read by handle" },
+ { "char-read-uuid", cmd_read_uuid, "<UUID> [start hnd] [end hnd]",
+ "Characteristics Value/Descriptor Read by UUID" },
{ NULL, NULL, NULL}
};
@@ -374,7 +519,7 @@ static void cmd_help(int argcp, char **argvp)
int i;
for (i = 0; commands[i].cmd; i++)
- printf("%-15s %-25s %s\n", commands[i].cmd,
+ printf("%-15s %-30s %s\n", commands[i].cmd,
commands[i].params, commands[i].desc);
}
--
1.7.1
^ permalink raw reply related
* [PATCH v2 6/7] Move attr_data_from_string() to utils.c
From: Sheldon Demario @ 2011-02-22 19:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1298328606-7993-1-git-send-email-sheldon.demario@openbossa.org>
From: Bruna Moreira <bruna.moreira@openbossa.org>
The attr_data_from_string() function will be used in interactive and
usual gatttool so this function was moved to common file utils.c.
---
attrib/gatttool.c | 23 ++---------------------
attrib/gatttool.h | 1 +
attrib/utils.c | 19 +++++++++++++++++++
3 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 7478043..d7887c6 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -313,25 +313,6 @@ static gboolean characteristics_read(gpointer user_data)
return FALSE;
}
-static size_t attr_data_from_string(const char *str, uint8_t **data)
-{
- char tmp[3];
- size_t size, i;
-
- size = strlen(str) / 2;
- *data = g_try_malloc0(size);
- if (*data == NULL)
- return 0;
-
- tmp[2] = '\0';
- for (i = 0; i < size; i++) {
- memcpy(tmp, str + (i * 2), 2);
- (*data)[i] = (uint8_t) strtol(tmp, NULL, 16);
- }
-
- return size;
-}
-
static void mainloop_quit(gpointer user_data)
{
uint8_t *value = user_data;
@@ -356,7 +337,7 @@ static gboolean characteristics_write(gpointer user_data)
goto error;
}
- len = attr_data_from_string(opt_value, &value);
+ len = gatt_attr_data_from_string(opt_value, &value);
if (len == 0) {
g_printerr("Invalid value\n");
goto error;
@@ -408,7 +389,7 @@ static gboolean characteristics_write_req(gpointer user_data)
goto error;
}
- len = attr_data_from_string(opt_value, &value);
+ len = gatt_attr_data_from_string(opt_value, &value);
if (len == 0) {
g_printerr("Invalid value\n");
goto error;
diff --git a/attrib/gatttool.h b/attrib/gatttool.h
index 7eae18d..2fd4a46 100644
--- a/attrib/gatttool.h
+++ b/attrib/gatttool.h
@@ -25,3 +25,4 @@ int interactive(gchar *dst, gboolean le);
GIOChannel *gatt_connect(const gchar *src, const gchar *dst,
const gchar *sec_level, int psm, int mtu,
BtIOConnect connect_cb);
+size_t gatt_attr_data_from_string(const char *str, uint8_t **data);
diff --git a/attrib/utils.c b/attrib/utils.c
index 4d0000d..8d1ca74 100644
--- a/attrib/utils.c
+++ b/attrib/utils.c
@@ -104,3 +104,22 @@ GIOChannel *gatt_connect(const gchar *src, const gchar *dst,
return chan;
}
+
+size_t gatt_attr_data_from_string(const char *str, uint8_t **data)
+{
+ char tmp[3];
+ size_t size, i;
+
+ size = strlen(str) / 2;
+ *data = g_try_malloc0(size);
+ if (*data == NULL)
+ return 0;
+
+ tmp[2] = '\0';
+ for (i = 0; i < size; i++) {
+ memcpy(tmp, str + (i * 2), 2);
+ (*data)[i] = (uint8_t) strtol(tmp, NULL, 16);
+ }
+
+ return size;
+}
--
1.7.1
^ permalink raw reply related
* [PATCH v2 7/7] Add Write Request in interactive gatttool
From: Sheldon Demario @ 2011-02-22 19:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1298328606-7993-1-git-send-email-sheldon.demario@openbossa.org>
From: Bruna Moreira <bruna.moreira@openbossa.org>
---
Add forgoten conn_state check on cmd_char_write_req()
attrib/interactive.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/attrib/interactive.c b/attrib/interactive.c
index a1c5671..9af3daa 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -487,6 +487,56 @@ static void cmd_read_uuid(int argcp, char **argvp)
return;
}
+static void char_write_req_cb(guint8 status, const guint8 *pdu, guint16 plen,
+ gpointer user_data)
+{
+ if (status != 0) {
+ printf("Characteristic Write Request failed: "
+ "%s\n", att_ecode2str(status));
+ return;
+ }
+
+ if (!dec_write_resp(pdu, plen)) {
+ printf("Protocol error\n");
+ return;
+ }
+
+ printf("Characteristic value was written successfully\n");
+}
+
+static void cmd_char_write_req(int argcp, char **argvp)
+{
+ uint8_t *value;
+ size_t plen;
+ int handle;
+
+ if (conn_state != STATE_CONNECTED) {
+ printf("Command failed: disconnected\n");
+ return;
+ }
+
+ if (argcp < 3) {
+ printf("Usage: char-write-req <handle> <new value>\n");
+ return;
+ }
+
+ handle = strtoll(argvp[1], NULL, 16);
+ if (errno != 0 || handle <= 0) {
+ printf("A valid handle is required\n");
+ return;
+ }
+
+ plen = gatt_attr_data_from_string(argvp[2], &value);
+ if (plen == 0) {
+ g_printerr("Invalid value\n");
+ return;
+ }
+
+ gatt_write_char(attrib, handle, value, plen, char_write_req_cb, NULL);
+
+ g_free(value);
+}
+
static struct {
const char *cmd;
void (*func)(int argcp, char **argvp);
@@ -511,6 +561,8 @@ static struct {
"Characteristics Value/Descriptor Read by handle" },
{ "char-read-uuid", cmd_read_uuid, "<UUID> [start hnd] [end hnd]",
"Characteristics Value/Descriptor Read by UUID" },
+ { "char-write-req", cmd_char_write_req, "<handle> <new value>",
+ "Characteristic Value Write (Write Request)" },
{ NULL, NULL, NULL}
};
--
1.7.1
^ permalink raw reply related
* Re: [PATCH 1/5] Add support for pcsuite lock file
From: Johan Hedberg @ 2011-02-22 19:14 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1298367822-27766-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Tue, Feb 22, 2011, Luiz Augusto von Dentz wrote:
> This should make others applications able to detect when pcsuite is
> connected.
> ---
> plugins/ftp.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 files changed, 154 insertions(+), 6 deletions(-)
Doesn't compile (ssize_t correct format string is %zd):
plugins/ftp.c: In function 'ftp_put':
plugins/ftp.c:288: error: format '%d' expects type 'int', but argument 6 has type 'ssize_t'
Also, all the added debug prints don't seem to relate to the commit
message in anyway. Probably better to split into a separate patch?
Johan
^ permalink raw reply
* Re: [PATCH 1/5] Add support for pcsuite lock file
From: Luiz Augusto von Dentz @ 2011-02-22 20:23 UTC (permalink / raw)
To: Luiz Augusto von Dentz, linux-bluetooth; +Cc: Johan Hedberg
In-Reply-To: <20110222191419.GA5469@jh-x301>
Hi,
On Tue, Feb 22, 2011 at 9:14 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Luiz,
>
> On Tue, Feb 22, 2011, Luiz Augusto von Dentz wrote:
>> This should make others applications able to detect when pcsuite is
>> connected.
>> ---
>> plugins/ftp.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>> 1 files changed, 154 insertions(+), 6 deletions(-)
>
> Doesn't compile (ssize_t correct format string is %zd):
>
> plugins/ftp.c: In function 'ftp_put':
> plugins/ftp.c:288: error: format '%d' expects type 'int', but argument 6 has type 'ssize_t'
Will fix it and send a new version.
> Also, all the added debug prints don't seem to relate to the commit
> message in anyway. Probably better to split into a separate patch?
Yep, will do it too.
--
Luiz Augusto von Dentz
Computer Engineer
^ permalink raw reply
* [PATCH 1/7] TODO: Changed item related to ATT parsing for hcidump
From: Claudio Takahasi @ 2011-02-22 20:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
---
TODO | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/TODO b/TODO
index 1357db9..3617777 100644
--- a/TODO
+++ b/TODO
@@ -87,7 +87,8 @@ ATT/GATT
Priority: Medium
Complexity: C1
-- Add ATT/GATT parsing to hcidump
+- ATT/GATT parsing to hcidump. Partially implemented, missing to fix
+ multiple advertises in the same event and RSSI.
Priority: Medium
Complexity: C2
--
1.7.4.1
^ permalink raw reply related
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