Linux bluetooth development
 help / color / mirror / Atom feed
* problem to disconnect with bluez-test
From: Goubert, TonyX @ 2010-12-21  8:53 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org

Hi all,

I use bluez-4.76.2.6 i586.rpm and bluez-test-4.76.2.6.i586.rpm in order to discover, connect, ...  

Link : repo.meego.com/MeeGo/builds/trunk/1.1.80.10.20101214.1/core/repos/ia32/packages/i586/

I have paired a handset with a laptop by using 'simple-agent' bluez-test script
BUT I can't disconnect it when I use the bluez stack.
I can remove it (./test-device remove xx:xx:xx:xx:xx:xx) but I want to be able to connect/disconnect/connect...

Is there a command?

Some handset traces:
[root@localhost test]# ./list-devices
    [ /org/bluez/369/hci0/dev_xx_xx_xx_xx_xx_xx ]
        Name = tllab54
        Paired = 1
        Adapter = /org/bluez/369/hci0
        Alias = tllab54
        Connected = 1
        UUIDs = 0x110a 0x110c 0x110e 0x1112 0x1115 0x1116 0x1117 0x111f 
        Address = xx:xx:xx:xx:xx:xx
        Services = dbus.Array([], signature=dbus.Signature('o'), variant_level=1)
        Class = 0x000000
        Trusted = 0
        Blocked = 0

[root@localhost test]# ./test-device disconnect xx:xx:xx:xx:xx:xx
Unknown command

[root@localhost test]# ./test-input disconnect xx:xx:xx:xx:xx:xx 
Traceback (most recent call last):
  File "./test-input", line 42, in <module>
    input.Disconnect()
  File "/usr/lib/python2.6/site-packages/dbus/proxies.py", line 68, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python2.6/site-packages/dbus/proxies.py", line 140, in __call__
    **keywords)
  File "/usr/lib/python2.6/site-packages/dbus/connection.py", line 630, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "Disconnect" wt

BR

--
Tony Goubert
tonyx.goubert@intel.com

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


^ permalink raw reply

* Re: problem to disconnect with bluez-test
From: Johan Hedberg @ 2010-12-21  9:24 UTC (permalink / raw)
  To: Goubert, TonyX; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <6E42A1B4DD2F7B4D80A1F26BB498BF9F8C9BD2CAB2@irsmsx501.ger.corp.intel.com>

Hi Tony,

On Tue, Dec 21, 2010, Goubert, TonyX wrote:
> I have paired a handset with a laptop by using 'simple-agent'
> bluez-test script BUT I can't disconnect it when I use the bluez
> stack.

I suppose you mean you can't disconnect it using the test scripts that
come with BlueZ (since I'm sure you *can* disconnect it with BlueZ as
long as you use the D-Bus interface directly).

> I can remove it (./test-device remove xx:xx:xx:xx:xx:xx) but I
> want to be able to connect/disconnect/connect...

The Device.Disconnect method is indeed something that should be added to
the test-device script. I just went ahead and pushed a patch for it
upstream.

> [root@localhost test]# ./test-device disconnect xx:xx:xx:xx:xx:xx
> Unknown command

This command should work with latest git now.

Johan

^ permalink raw reply

* [PATCH v3] Remove unneeded variable
From: Anderson Lizardo @ 2010-12-21 12:02 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1292885388-21703-1-git-send-email-claudio.takahasi@openbossa.org>

From: Claudio Takahasi <claudio.takahasi@openbossa.org>

---
 src/glib-helper.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/glib-helper.c b/src/glib-helper.c
index 0233eb7..bf39a83 100644
--- a/src/glib-helper.c
+++ b/src/glib-helper.c
@@ -514,7 +514,6 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
 {
 	struct gattrib_context *ctxt;
 	GIOChannel *io;
-	GError *gerr = NULL;
 
 	ctxt = g_try_new0(struct gattrib_context, 1);
 	if (ctxt == NULL)
@@ -527,14 +526,14 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
 	ctxt->destroy = destroy;
 
 	if (psm < 0)
-		io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
+		io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, NULL,
 				BT_IO_OPT_SOURCE_BDADDR, src,
 				BT_IO_OPT_DEST_BDADDR, dst,
 				BT_IO_OPT_CID, GATT_CID,
 				BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
 				BT_IO_OPT_INVALID);
 	else
-		io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
+		io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, NULL,
 				BT_IO_OPT_SOURCE_BDADDR, src,
 				BT_IO_OPT_DEST_BDADDR, dst,
 				BT_IO_OPT_PSM, psm,
-- 
1.7.0.4


^ permalink raw reply related

* Re: [PATCH v2 5/5] Remove unneeded variable
From: Anderson Lizardo @ 2010-12-21 12:03 UTC (permalink / raw)
  To: Claudio Takahasi, linux-bluetooth
In-Reply-To: <20101220230227.GC6365@jh-x301>

On Mon, Dec 20, 2010 at 7:02 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Claudio,
>
> On Mon, Dec 20, 2010, Claudio Takahasi wrote:
>> ---
>>  src/glib-helper.c |    5 ++---
>>  1 files changed, 2 insertions(+), 3 deletions(-)
>
> This patch seems fine but it doesn't apply (probably due to me not
> applying v2 2/5).

Just sent a rebased one that should apply to master branch.

Regards,
-- 
Anderson Lizardo
OpenBossa Labs - INdT
Manaus - Brazil

^ permalink raw reply

* Re: [PATCH v3] Remove unneeded variable
From: Johan Hedberg @ 2010-12-21 12:47 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth, Claudio Takahasi
In-Reply-To: <1292932968-3951-1-git-send-email-anderson.lizardo@openbossa.org>

Hi,

On Tue, Dec 21, 2010, Anderson Lizardo wrote:
> From: Claudio Takahasi <claudio.takahasi@openbossa.org>
> 
> ---
>  src/glib-helper.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)

Pushed upstream. Thanks.

Johan

^ permalink raw reply

* [PATCHv2] Bluetooth: Use non-flushable by default L2CAP data packets
From: Emeltchenko Andrei @ 2010-12-21 14:21 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>

Modification of Nick Pelly <npelly@google.com> patch.

With Bluetooth 2.1 ACL packets can be flushable or non-flushable. This commit
makes ACL data packets non-flushable by default on compatible chipsets, and
adds the BT_FLUSHABLE socket option to explicitly request flushable ACL
data packets for a given L2CAP socket. This is useful for A2DP data which can
be safely discarded if it can not be delivered within a short time (while
other ACL data should not be discarded).

Note that making ACL data flushable has no effect unless the automatic flush
timeout for that ACL link is changed from its default of 0 (infinite).

Default packet types (for compatible chipsets):
Frame 34: 13 bytes on wire (104 bits), 13 bytes captured (104 bits)
Bluetooth HCI H4
Bluetooth HCI ACL Packet
    .... 0000 0000 0010 = Connection Handle: 0x0002
    ..00 .... .... .... = PB Flag: First Non-automatically Flushable Packet (0)
    00.. .... .... .... = BC Flag: Point-To-Point (0)
    Data Total Length: 8
Bluetooth L2CAP Packet

After setting BT_FLUSHABLE
(sock.setsockopt(274 /*SOL_BLUETOOTH*/, 8 /* BT_FLUSHABLE */, 1 /* flush */))
Frame 34: 13 bytes on wire (104 bits), 13 bytes captured (104 bits)
Bluetooth HCI H4
Bluetooth HCI ACL Packet
    .... 0000 0000 0010 = Connection Handle: 0x0002
    ..10 .... .... .... = PB Flag: First Automatically Flushable Packet (2)
    00.. .... .... .... = BC Flag: Point-To-Point (0)
    Data Total Length: 8
Bluetooth L2CAP Packet

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
---
 include/net/bluetooth/bluetooth.h |    5 ++++
 include/net/bluetooth/hci.h       |    2 +
 include/net/bluetooth/hci_core.h  |    1 +
 include/net/bluetooth/l2cap.h     |    2 +
 net/bluetooth/hci_core.c          |    6 +++-
 net/bluetooth/l2cap.c             |   48 ++++++++++++++++++++++++++++++++++--
 6 files changed, 59 insertions(+), 5 deletions(-)

diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 0c5e725..ed7d775 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -64,6 +64,11 @@ struct bt_security {
 
 #define BT_DEFER_SETUP	7
 
+#define BT_FLUSHABLE	8
+
+#define BT_FLUSHABLE_OFF	0
+#define BT_FLUSHABLE_ON		1
+
 #define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg)
 #define BT_ERR(fmt, arg...)  printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg)
 #define BT_DBG(fmt, arg...)  pr_debug("%s: " fmt "\n" , __func__ , ## arg)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 29a7a8c..333d5cb 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -150,6 +150,7 @@ enum {
 #define EDR_ESCO_MASK  (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
 
 /* ACL flags */
+#define ACL_START_NO_FLUSH	0x00
 #define ACL_CONT		0x01
 #define ACL_START		0x02
 #define ACL_ACTIVE_BCAST	0x04
@@ -193,6 +194,7 @@ enum {
 #define LMP_EDR_ESCO_3M	0x40
 #define LMP_EDR_3S_ESCO	0x80
 
+#define LMP_NO_FLUSH	0x01
 #define LMP_SIMPLE_PAIR	0x08
 
 /* Connection modes */
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 1992fac..9778bc8 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -456,6 +456,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
 #define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR)
 #define lmp_esco_capable(dev)      ((dev)->features[3] & LMP_ESCO)
 #define lmp_ssp_capable(dev)       ((dev)->features[6] & LMP_SIMPLE_PAIR)
+#define lmp_no_flush_capable(dev)  ((dev)->features[6] & LMP_NO_FLUSH)
 
 /* ----- HCI protocols ----- */
 struct hci_proto {
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 7ad25ca..af35711 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -75,6 +75,7 @@ struct l2cap_conninfo {
 #define L2CAP_LM_TRUSTED	0x0008
 #define L2CAP_LM_RELIABLE	0x0010
 #define L2CAP_LM_SECURE		0x0020
+#define L2CAP_LM_FLUSHABLE	0x0040
 
 /* L2CAP command codes */
 #define L2CAP_COMMAND_REJ	0x01
@@ -327,6 +328,7 @@ struct l2cap_pinfo {
 	__u8		sec_level;
 	__u8		role_switch;
 	__u8		force_reliable;
+	__u8		flushable;
 
 	__u8		conf_req[64];
 	__u8		conf_len;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 51c61f7..c0d776b 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1380,7 +1380,7 @@ void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
 
 	skb->dev = (void *) hdev;
 	bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
-	hci_add_acl_hdr(skb, conn->handle, flags | ACL_START);
+	hci_add_acl_hdr(skb, conn->handle, flags);
 
 	list = skb_shinfo(skb)->frag_list;
 	if (!list) {
@@ -1398,12 +1398,14 @@ void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
 		spin_lock_bh(&conn->data_q.lock);
 
 		__skb_queue_tail(&conn->data_q, skb);
+		flags &= ~ACL_START;
+		flags |= ACL_CONT;
 		do {
 			skb = list; list = list->next;
 
 			skb->dev = (void *) hdev;
 			bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
-			hci_add_acl_hdr(skb, conn->handle, flags | ACL_CONT);
+			hci_add_acl_hdr(skb, conn->handle, flags);
 
 			BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len);
 
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index c791fcd..efa60eb 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -362,13 +362,19 @@ static inline u8 l2cap_get_ident(struct l2cap_conn *conn)
 static inline void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data)
 {
 	struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
+	u8 flags;
 
 	BT_DBG("code 0x%2.2x", code);
 
 	if (!skb)
 		return;
 
-	hci_send_acl(conn->hcon, skb, 0);
+	if (lmp_no_flush_capable(conn->hcon->hdev))
+		flags = ACL_START_NO_FLUSH;
+	else
+		flags = ACL_START;
+
+	hci_send_acl(conn->hcon, skb, flags);
 }
 
 static inline void l2cap_send_sframe(struct l2cap_pinfo *pi, u16 control)
@@ -900,6 +906,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
 		pi->sec_level = l2cap_pi(parent)->sec_level;
 		pi->role_switch = l2cap_pi(parent)->role_switch;
 		pi->force_reliable = l2cap_pi(parent)->force_reliable;
+		pi->flushable = l2cap_pi(parent)->flushable;
 	} else {
 		pi->imtu = L2CAP_DEFAULT_MTU;
 		pi->omtu = 0;
@@ -915,6 +922,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
 		pi->sec_level = BT_SECURITY_LOW;
 		pi->role_switch = 0;
 		pi->force_reliable = 0;
+		pi->flushable = BT_FLUSHABLE_OFF;
 	}
 
 	/* Default config options */
@@ -1450,10 +1458,17 @@ static void l2cap_drop_acked_frames(struct sock *sk)
 static inline void l2cap_do_send(struct sock *sk, struct sk_buff *skb)
 {
 	struct l2cap_pinfo *pi = l2cap_pi(sk);
+	struct hci_conn *hcon = pi->conn->hcon;
+	u16 flags;
 
 	BT_DBG("sk %p, skb %p len %d", sk, skb, skb->len);
 
-	hci_send_acl(pi->conn->hcon, skb, 0);
+	if (lmp_no_flush_capable(hcon->hdev) && !l2cap_pi(sk)->flushable)
+		flags = ACL_START_NO_FLUSH;
+	else
+		flags = ACL_START;
+
+	hci_send_acl(hcon, skb, flags);
 }
 
 static void l2cap_streaming_send(struct sock *sk)
@@ -2045,6 +2060,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
 static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
 {
 	struct sock *sk = sock->sk;
+	struct hci_conn *hcon = l2cap_pi(sk)->conn->hcon;
 	struct bt_security sec;
 	int len, err = 0;
 	u32 opt;
@@ -2098,6 +2114,26 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
 		bt_sk(sk)->defer_setup = opt;
 		break;
 
+	case BT_FLUSHABLE:
+		if (get_user(opt, (u32 __user *) optval)) {
+			err = -EFAULT;
+			break;
+		}
+
+		if (opt > BT_FLUSHABLE_ON) {
+			err = -EINVAL;
+			break;
+		}
+
+		if (opt == BT_FLUSHABLE_OFF &&
+				!lmp_no_flush_capable(hcon->hdev)) {
+			err = -EINVAL;
+			break;
+		}
+
+		l2cap_pi(sk)->flushable = opt;
+		break;
+
 	default:
 		err = -ENOPROTOOPT;
 		break;
@@ -2237,6 +2273,12 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
 
 		break;
 
+	case BT_FLUSHABLE:
+		if (put_user(l2cap_pi(sk)->flushable, (u32 __user *) optval))
+			err = -EFAULT;
+
+		break;
+
 	default:
 		err = -ENOPROTOOPT;
 		break;
@@ -4697,7 +4739,7 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
 
 	BT_DBG("conn %p len %d flags 0x%x", conn, skb->len, flags);
 
-	if (flags & ACL_START) {
+	if (!(flags & ACL_CONT)) {
 		struct l2cap_hdr *hdr;
 		struct sock *sk;
 		u16 cid;
-- 
1.7.1


^ permalink raw reply related

* [PATCH] Fix build in directory separate from source.
From: Michal Labedzki @ 2010-12-21 14:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Michal Labedzki

After bootstrapping can build bluez outside of sources. Patch add required
"include" paths, put all udev's rules to preprocess stage and change
behaviour on "./configure --prefix=PATH". When --prefix is set, all files
will be put in prefix-path. Otherwise, use path from PKG_CONFIG. This change
allow install all files in place which user chosen.
---
 Makefile.am                        |   10 ++++++----
 acinclude.m4                       |    2 +-
 configure.ac                       |    5 +++--
 scripts/bluetooth-hid2hci.rules    |   36 ------------------------------------
 scripts/bluetooth-hid2hci.rules.in |   36 ++++++++++++++++++++++++++++++++++++
 scripts/bluetooth-serial.rules     |   35 -----------------------------------
 scripts/bluetooth-serial.rules.in  |   35 +++++++++++++++++++++++++++++++++++
 7 files changed, 81 insertions(+), 78 deletions(-)
 delete mode 100644 scripts/bluetooth-hid2hci.rules
 create mode 100644 scripts/bluetooth-hid2hci.rules.in
 delete mode 100644 scripts/bluetooth-serial.rules
 create mode 100644 scripts/bluetooth-serial.rules.in

diff --git a/Makefile.am b/Makefile.am
index 5f96975..ab4b460 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -361,12 +361,14 @@ AM_YFLAGS = -d
 AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ @CAPNG_CFLAGS@ \
 		-DBLUETOOTH_PLUGIN_BUILTIN -DPLUGINDIR=\""$(plugindir)"\"
 
-INCLUDES = -I$(builddir)/lib -I$(builddir)/src -I$(srcdir)/src \
-			-I$(srcdir)/audio -I$(srcdir)/sbc -I$(srcdir)/gdbus \
-			-I$(srcdir)/attrib -I$(srcdir)/btio
+INCLUDES = -I$(builddir)/lib -I$(srcdir)/lib \
+		-I$(builddir)/tools -I$(srcdir)/tools \
+		-I$(builddir)/src -I$(srcdir)/src \
+		-I$(srcdir)/audio -I$(srcdir)/sbc -I$(srcdir)/gdbus \
+		-I$(srcdir)/attrib -I$(srcdir)/btio
 
 if MCAP
-INCLUDES += -I$(builddir)/health
+INCLUDES += -I$(builddir)/health -I$(srcdir)/health
 endif
 
 pkgconfigdir = $(libdir)/pkgconfig
diff --git a/acinclude.m4 b/acinclude.m4
index 287f07d..4f1aae4 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -84,7 +84,7 @@ AC_DEFUN([AC_INIT_BLUEZ], [
 	AC_SUBST(STORAGEDIR, "${storagedir}")
 
 	UDEV_DATADIR="`$PKG_CONFIG --variable=udevdir udev`"
-	if (test -z "${UDEV_DATADIR}"); then
+	if ((test "${prefix}" != "NONE") || (test -z "${UDEV_DATADIR}")); then
 		UDEV_DATADIR="${sysconfdir}/udev/rules.d"
 	else
 		UDEV_DATADIR="${UDEV_DATADIR}/rules.d"
diff --git a/configure.ac b/configure.ac
index 5f09cb6..da567e6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,5 +55,6 @@ if (test "${enable_capng}" = "yes"); then
 	AC_DEFINE(HAVE_CAPNG, 1, [Define to 1 if you have capabilities library.])
 fi
 
-AC_OUTPUT(Makefile scripts/bluetooth.rules doc/version.xml
-					src/bluetoothd.8 bluez.pc)
+AC_OUTPUT(Makefile scripts/bluetooth.rules scripts/bluetooth-hid2hci.rules
+		scripts/bluetooth-serial.rules doc/version.xml src/bluetoothd.8
+		bluez.pc)
diff --git a/scripts/bluetooth-hid2hci.rules b/scripts/bluetooth-hid2hci.rules
deleted file mode 100644
index 1b231d1..0000000
--- a/scripts/bluetooth-hid2hci.rules
+++ /dev/null
@@ -1,36 +0,0 @@
-# Variety of Dell Bluetooth devices
-#
-# it looks like a bit of an odd rule, because it is matching
-# on a mouse device that is self powered, but that is where
-# a HID report needs to be sent to switch modes.
-#
-# Known supported devices:
-#   413c:8154
-#   413c:8158
-#   413c:8162
-ACTION=="add", ENV{ID_VENDOR}=="413c", ENV{ID_CLASS}=="mouse", ATTRS{bmAttributes}=="e0", KERNEL=="mouse*", RUN+="/usr/sbin/hid2hci --method dell -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-
-# Logitech devices
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c703" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c704" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c705" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70a" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70b" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70c" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70e" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c713" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c714" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c71b" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c71c" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-
-# CSR devices (in HID mode)
-ACTION=="add", ENV{ID_VENDOR}=="0a12", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="0458", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-
-# CSR devices (in HCI mode)
-#ACTION=="add", ENV{ID_VENDOR}=="0a12", ENV{ID_MODEL}=="0001" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
-#ACTION=="add", ENV{ID_VENDOR}=="0458", ENV{ID_MODEL}=="003f" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
-#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8203" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
-#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8204" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
-#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8207" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
diff --git a/scripts/bluetooth-hid2hci.rules.in b/scripts/bluetooth-hid2hci.rules.in
new file mode 100644
index 0000000..1b231d1
--- /dev/null
+++ b/scripts/bluetooth-hid2hci.rules.in
@@ -0,0 +1,36 @@
+# Variety of Dell Bluetooth devices
+#
+# it looks like a bit of an odd rule, because it is matching
+# on a mouse device that is self powered, but that is where
+# a HID report needs to be sent to switch modes.
+#
+# Known supported devices:
+#   413c:8154
+#   413c:8158
+#   413c:8162
+ACTION=="add", ENV{ID_VENDOR}=="413c", ENV{ID_CLASS}=="mouse", ATTRS{bmAttributes}=="e0", KERNEL=="mouse*", RUN+="/usr/sbin/hid2hci --method dell -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+
+# Logitech devices
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c703" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c704" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c705" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70a" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70b" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70c" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70e" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c713" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c714" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c71b" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c71c" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+
+# CSR devices (in HID mode)
+ACTION=="add", ENV{ID_VENDOR}=="0a12", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="0458", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+
+# CSR devices (in HCI mode)
+#ACTION=="add", ENV{ID_VENDOR}=="0a12", ENV{ID_MODEL}=="0001" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
+#ACTION=="add", ENV{ID_VENDOR}=="0458", ENV{ID_MODEL}=="003f" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
+#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8203" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
+#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8204" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
+#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8207" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
diff --git a/scripts/bluetooth-serial.rules b/scripts/bluetooth-serial.rules
deleted file mode 100644
index 072335f..0000000
--- a/scripts/bluetooth-serial.rules
+++ /dev/null
@@ -1,35 +0,0 @@
-# Brain Boxes BL-620 Bluetooth Adapter
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Brain Boxes", ATTRS{prod_id2}=="Bluetooth PC Card", ENV{HCIOPTS}="bboxes", RUN+="bluetooth_serial"
-
-# Xircom CreditCard Bluetooth Adapter
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Xircom", ATTRS{prod_id3}=="CBT", ENV{HCIOPTS}="xircom", RUN+="bluetooth_serial"
-
-# Xircom RealPort2 Bluetooth Adapter
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Xircom", ATTRS{prod_id3}=="CBT", ENV{HCIOPTS}="xircom", RUN+="bluetooth_serial"
-
-# IBM Bluetooth PC Card II
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="IBM", ATTRS{prod_id2}=="Bluetooth PC Card II", ENV{HCIOPTS}="tdk", RUN+="bluetooth_serial"
-
-# TDK Bluetooth PC Card
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="TDK", ATTRS{prod_id2}=="Bluetooth PC Card II", ENV{HCIOPTS}="tdk", RUN+="bluetooth_serial"
-
-# AmbiCom BT2000C Bluetooth PC/CF Card
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="AmbiCom BT2000C", ATTRS{prod_id2}=="Bluetooth PC/CF Card", ENV{HCIOPTS}="bt2000c", RUN+="bluetooth_serial"
-
-# COM One Platinium Bluetooth PC Card
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="COM1 SA", ATTRS{prod_id2}=="MC310 CARD", ENV{HCIOPTS}="comone", RUN+="bluetooth_serial"
-
-# Sphinx PICO Card
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="SPHINX", ATTRS{prod_id2}=="BT-CARD", ENV{HCIOPTS}="picocard", RUN+="bluetooth_serial"
-
-# H-Soft blue+Card
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="H-Soft", ATTRS{prod_id2}=="Blue+CARD", ENV{HCIOPTS}="$sysfs{manf_id},$sysfs{card_id}", RUN+="bluetooth_serial"
-
-# Compaq iPAQ Bluetooth Sleeve, Belkin F8T020, any other muppet who used an OXCF950 and didn't bother to program it appropriately.
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="CF CARD", ATTRS{prod_id2}=="GENERIC", ENV{HCIOPTS}="$sysfs{manf_id},$sysfs{card_id}", RUN+="bluetooth_serial"
-
-# Zoom Bluetooth Card and Sitecom CN-504 Card
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="PCMCIA", ATTRS{prod_id2}=="Bluetooth Card", ENV{HCIOPTS}="zoom", RUN+="bluetooth_serial"
-
-# CC&C BT0100M
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Bluetooth BT0100M", ENV{HCIOPTS}="bcsp 115200", RUN+="bluetooth_serial"
diff --git a/scripts/bluetooth-serial.rules.in b/scripts/bluetooth-serial.rules.in
new file mode 100644
index 0000000..072335f
--- /dev/null
+++ b/scripts/bluetooth-serial.rules.in
@@ -0,0 +1,35 @@
+# Brain Boxes BL-620 Bluetooth Adapter
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Brain Boxes", ATTRS{prod_id2}=="Bluetooth PC Card", ENV{HCIOPTS}="bboxes", RUN+="bluetooth_serial"
+
+# Xircom CreditCard Bluetooth Adapter
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Xircom", ATTRS{prod_id3}=="CBT", ENV{HCIOPTS}="xircom", RUN+="bluetooth_serial"
+
+# Xircom RealPort2 Bluetooth Adapter
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Xircom", ATTRS{prod_id3}=="CBT", ENV{HCIOPTS}="xircom", RUN+="bluetooth_serial"
+
+# IBM Bluetooth PC Card II
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="IBM", ATTRS{prod_id2}=="Bluetooth PC Card II", ENV{HCIOPTS}="tdk", RUN+="bluetooth_serial"
+
+# TDK Bluetooth PC Card
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="TDK", ATTRS{prod_id2}=="Bluetooth PC Card II", ENV{HCIOPTS}="tdk", RUN+="bluetooth_serial"
+
+# AmbiCom BT2000C Bluetooth PC/CF Card
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="AmbiCom BT2000C", ATTRS{prod_id2}=="Bluetooth PC/CF Card", ENV{HCIOPTS}="bt2000c", RUN+="bluetooth_serial"
+
+# COM One Platinium Bluetooth PC Card
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="COM1 SA", ATTRS{prod_id2}=="MC310 CARD", ENV{HCIOPTS}="comone", RUN+="bluetooth_serial"
+
+# Sphinx PICO Card
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="SPHINX", ATTRS{prod_id2}=="BT-CARD", ENV{HCIOPTS}="picocard", RUN+="bluetooth_serial"
+
+# H-Soft blue+Card
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="H-Soft", ATTRS{prod_id2}=="Blue+CARD", ENV{HCIOPTS}="$sysfs{manf_id},$sysfs{card_id}", RUN+="bluetooth_serial"
+
+# Compaq iPAQ Bluetooth Sleeve, Belkin F8T020, any other muppet who used an OXCF950 and didn't bother to program it appropriately.
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="CF CARD", ATTRS{prod_id2}=="GENERIC", ENV{HCIOPTS}="$sysfs{manf_id},$sysfs{card_id}", RUN+="bluetooth_serial"
+
+# Zoom Bluetooth Card and Sitecom CN-504 Card
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="PCMCIA", ATTRS{prod_id2}=="Bluetooth Card", ENV{HCIOPTS}="zoom", RUN+="bluetooth_serial"
+
+# CC&C BT0100M
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Bluetooth BT0100M", ENV{HCIOPTS}="bcsp 115200", RUN+="bluetooth_serial"
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH v4 2/5] Change CreatePairedDevice to support LE devices
From: Sheldon Demario @ 2010-12-21 14:34 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <20101221084243.GA14108@jh-x301>

CreatePairedDevice implements now the same behaviour of CreateDevice,
triggering Discover All Primary Services when needed. SMP negotiation
starts when the link is established. LE capable kernel is required to
test this method properly.

Limitation: For dual mode devices, Discover All Primary Services is not
being executed after SDP search if GATT record is found.
---
 src/adapter.c     |  102 +++++++++++++++++++++++++++++++++++++----------------
 src/device.c      |   89 ++++++++++++++++++++++++----------------------
 src/device.h      |    5 ++-
 src/glib-helper.c |   12 +++++-
 src/glib-helper.h |    1 +
 5 files changed, 132 insertions(+), 77 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index cf3566d..82f55ef 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1510,15 +1510,48 @@ static gboolean event_is_connectable(uint8_t type)
 	}
 }
 
+static struct btd_device *create_device_internal(DBusConnection *conn,
+						struct btd_adapter *adapter,
+						const gchar *address,
+						gboolean force, int *err)
+{
+	struct remote_dev_info *dev, match;
+	struct btd_device *device;
+	device_type_t type;
+
+	memset(&match, 0, sizeof(struct remote_dev_info));
+	str2ba(address, &match.bdaddr);
+	match.name_status = NAME_ANY;
+
+	dev = adapter_search_found_devices(adapter, &match);
+	if (dev && dev->flags)
+		type = flags2type(dev->flags);
+	else
+		type = DEVICE_TYPE_BREDR;
+
+	if (!force && type == DEVICE_TYPE_LE &&
+					!event_is_connectable(dev->evt_type)) {
+		if (err)
+			*err = -ENOTCONN;
+
+		return NULL;
+	}
+
+	device = adapter_create_device(conn, adapter, address, type);
+	if (!device && err)
+		*err = -ENOMEM;
+
+	return device;
+}
+
 static DBusMessage *create_device(DBusConnection *conn,
 					DBusMessage *msg, void *data)
 {
 	struct btd_adapter *adapter = data;
 	struct btd_device *device;
-	struct remote_dev_info *dev, match;
 	const gchar *address;
+	DBusMessage *reply;
 	int err;
-	device_type_t type;
 
 	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
 						DBUS_TYPE_INVALID) == FALSE)
@@ -1535,41 +1568,36 @@ static DBusMessage *create_device(DBusConnection *conn,
 
 	DBG("%s", address);
 
-	memset(&match, 0, sizeof(struct remote_dev_info));
-	str2ba(address, &match.bdaddr);
-	match.name_status = NAME_ANY;
+	device = create_device_internal(conn, adapter, address, TRUE, &err);
+	if (!device)
+		goto failed;
 
-	dev = adapter_search_found_devices(adapter, &match);
-	if (dev && dev->flags)
-		type = flags2type(dev->flags);
+	if (device_get_type(device) != DEVICE_TYPE_LE)
+		err = device_browse_sdp(device, conn, msg, NULL, FALSE);
 	else
-		type = DEVICE_TYPE_BREDR;
+		err = device_browse_primary(device, conn, msg, FALSE);
 
-	device = adapter_create_device(conn, adapter, address, type);
-	if (!device)
-		return NULL;
+	if (err < 0) {
+		adapter_remove_device(conn, adapter, device, TRUE);
+		return btd_error_failed(msg, strerror(-err));
+	}
 
-	if (type == DEVICE_TYPE_LE && !event_is_connectable(dev->evt_type)) {
+	return NULL;
+
+failed:
+	if (err == -ENOTCONN) {
 		/* Device is not connectable */
 		const char *path = device_get_path(device);
-		DBusMessage *reply;
 
 		reply = dbus_message_new_method_return(msg);
 
 		dbus_message_append_args(reply,
-					DBUS_TYPE_OBJECT_PATH, &path,
-					DBUS_TYPE_INVALID);
-
-		return reply;
-	}
-
-	err = device_browse(device, conn, msg, NULL, FALSE);
-	if (err < 0) {
-		adapter_remove_device(conn, adapter, device, TRUE);
-		return btd_error_failed(msg, strerror(-err));
-	}
+				DBUS_TYPE_OBJECT_PATH, &path,
+				DBUS_TYPE_INVALID);
+	} else
+		reply = btd_error_failed(msg, strerror(-err));
 
-	return NULL;
+	return reply;
 }
 
 static uint8_t parse_io_capability(const char *capability)
@@ -1594,6 +1622,7 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
 	struct btd_device *device;
 	const gchar *address, *agent_path, *capability, *sender;
 	uint8_t cap;
+	int err;
 
 	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
 					DBUS_TYPE_OBJECT_PATH, &agent_path,
@@ -1618,12 +1647,23 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
 	if (cap == IO_CAPABILITY_INVALID)
 		return btd_error_invalid_args(msg);
 
-	device = adapter_get_device(conn, adapter, address);
-	if (!device)
-		return btd_error_failed(msg,
-				"Unable to create a new device object");
+	device = adapter_find_device(adapter, address);
+	if (!device) {
+		device = create_device_internal(conn, adapter, address,
+								FALSE, &err);
+		if (!device)
+			return btd_error_failed(msg, strerror(-err));
+	}
+
+	if (device_get_type(device) != DEVICE_TYPE_LE)
+		return device_create_bonding(device, conn, msg,
+							agent_path, cap);
 
-	return device_create_bonding(device, conn, msg, agent_path, cap);
+	err = device_browse_primary(device, conn, msg, TRUE);
+	if (err < 0)
+		return btd_error_failed(msg, strerror(-err));
+
+	return NULL;
 }
 
 static gint device_path_cmp(struct btd_device *device, const gchar *path)
diff --git a/src/device.c b/src/device.c
index bef8e71..87a6647 100644
--- a/src/device.c
+++ b/src/device.c
@@ -583,7 +583,7 @@ static DBusMessage *discover_services(DBusConnection *conn,
 		return btd_error_invalid_args(msg);
 
 	if (strlen(pattern) == 0) {
-		err = device_browse(device, conn, msg, NULL, FALSE);
+		err = device_browse_sdp(device, conn, msg, NULL, FALSE);
 		if (err < 0)
 			goto fail;
 	} else {
@@ -594,7 +594,7 @@ static DBusMessage *discover_services(DBusConnection *conn,
 
 		sdp_uuid128_to_uuid(&uuid);
 
-		err = device_browse(device, conn, msg, &uuid, FALSE);
+		err = device_browse_sdp(device, conn, msg, &uuid, FALSE);
 		if (err < 0)
 			goto fail;
 	}
@@ -985,6 +985,11 @@ void device_get_name(struct btd_device *device, char *name, size_t len)
 	strncpy(name, device->name, len);
 }
 
+device_type_t device_get_type(struct btd_device *device)
+{
+	return device->type;
+}
+
 void device_remove_bonding(struct btd_device *device)
 {
 	char filename[PATH_MAX + 1];
@@ -1537,41 +1542,62 @@ done:
 	browse_request_free(req);
 }
 
-static struct browse_req *browse_primary(struct btd_device *device, int *err)
+int device_browse_primary(struct btd_device *device, DBusConnection *conn,
+				DBusMessage *msg, gboolean secure)
 {
 	struct btd_adapter *adapter = device->adapter;
 	struct browse_req *req;
 	bdaddr_t src;
-	int ret;
+	int err;
+
+	if (device->browse)
+		return -EBUSY;
 
 	req = g_new0(struct browse_req, 1);
 	req->device = btd_device_ref(device);
 
 	adapter_get_address(adapter, &src);
 
-	ret = bt_discover_primary(&src, &device->bdaddr, -1, primary_cb, req,
-									NULL);
-
-	if (ret < 0) {
+	err = bt_discover_primary(&src, &device->bdaddr, -1, primary_cb, req,
+							secure, NULL);
+	if (err < 0) {
 		browse_request_free(req);
-		if (err)
-			*err = ret;
+		return err;
+	}
 
-		return NULL;
+	if (conn == NULL)
+		conn = get_dbus_connection();
+
+	req->conn = dbus_connection_ref(conn);
+	device->browse = req;
+
+	if (msg) {
+		const char *sender = dbus_message_get_sender(msg);
+
+		req->msg = dbus_message_ref(msg);
+		/* Track the request owner to cancel it
+		 * automatically if the owner exits */
+		req->listener_id = g_dbus_add_disconnect_watch(conn,
+						sender,
+						discover_services_req_exit,
+						req, NULL);
 	}
 
-	return req;
+	return err;
 }
 
-static struct browse_req *browse_sdp(struct btd_device *device, uuid_t *search,
-						gboolean reverse, int *err)
+int device_browse_sdp(struct btd_device *device, DBusConnection *conn,
+			DBusMessage *msg, uuid_t *search, gboolean reverse)
 {
 	struct btd_adapter *adapter = device->adapter;
 	struct browse_req *req;
 	bt_callback_t cb;
 	bdaddr_t src;
 	uuid_t uuid;
-	int ret;
+	int err;
+
+	if (device->browse)
+		return -EBUSY;
 
 	adapter_get_address(adapter, &src);
 
@@ -1586,34 +1612,11 @@ static struct browse_req *browse_sdp(struct btd_device *device, uuid_t *search,
 		cb = browse_cb;
 	}
 
-	ret = bt_search_service(&src, &device->bdaddr, &uuid, cb, req, NULL);
-	if (ret < 0) {
+	err = bt_search_service(&src, &device->bdaddr, &uuid, cb, req, NULL);
+	if (err < 0) {
 		browse_request_free(req);
-		if (err)
-			*err = ret;
-
-		return NULL;
-	}
-
-	return req;
-}
-
-int device_browse(struct btd_device *device, DBusConnection *conn,
-			DBusMessage *msg, uuid_t *search, gboolean reverse)
-{
-	struct browse_req *req;
-	int err = 0;
-
-	if (device->browse)
-		return -EBUSY;
-
-	if (device->type == DEVICE_TYPE_LE)
-		req = browse_primary(device, &err);
-	else
-		req = browse_sdp(device, search, reverse, &err);
-
-	if (req == NULL)
 		return err;
+	}
 
 	if (conn == NULL)
 		conn = get_dbus_connection();
@@ -1716,7 +1719,7 @@ static gboolean start_discovery(gpointer user_data)
 {
 	struct btd_device *device = user_data;
 
-	device_browse(device, NULL, NULL, NULL, TRUE);
+	device_browse_sdp(device, NULL, NULL, NULL, TRUE);
 
 	device->discov_timer = 0;
 
@@ -2053,7 +2056,7 @@ void device_bonding_complete(struct btd_device *device, uint8_t status)
 			device->discov_timer = 0;
 		}
 
-		device_browse(device, bonding->conn, bonding->msg,
+		device_browse_sdp(device, bonding->conn, bonding->msg,
 				NULL, FALSE);
 
 		bonding_request_free(bonding);
diff --git a/src/device.h b/src/device.h
index 74b968c..9c645df 100644
--- a/src/device.h
+++ b/src/device.h
@@ -46,9 +46,12 @@ struct btd_device *device_create(DBusConnection *conn,
 				const gchar *address, device_type_t type);
 void device_set_name(struct btd_device *device, const char *name);
 void device_get_name(struct btd_device *device, char *name, size_t len);
+device_type_t device_get_type(struct btd_device *device);
 void device_remove(struct btd_device *device, gboolean remove_stored);
 gint device_address_cmp(struct btd_device *device, const gchar *address);
-int device_browse(struct btd_device *device, DBusConnection *conn,
+int device_browse_primary(struct btd_device *device, DBusConnection *conn,
+				DBusMessage *msg, gboolean secure);
+int device_browse_sdp(struct btd_device *device, DBusConnection *conn,
 			DBusMessage *msg, uuid_t *search, gboolean reverse);
 void device_probe_drivers(struct btd_device *device, GSList *profiles);
 const sdp_record_t *btd_device_get_record(struct btd_device *device,
diff --git a/src/glib-helper.c b/src/glib-helper.c
index c440e60..459a21c 100644
--- a/src/glib-helper.c
+++ b/src/glib-helper.c
@@ -520,9 +520,11 @@ static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
 
 int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
 					bt_primary_t cb, void *user_data,
+					gboolean secure,
 					bt_destroy_t destroy)
 {
 	struct gattrib_context *ctxt;
+	BtIOSecLevel sec_level;
 	GIOChannel *io;
 	GError *gerr = NULL;
 
@@ -536,19 +538,25 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
 	ctxt->cb = cb;
 	ctxt->destroy = destroy;
 
+	if (secure == TRUE)
+		sec_level = BT_IO_SEC_HIGH;
+	else
+		sec_level = BT_IO_SEC_LOW;
+
+
 	if (psm < 0)
 		io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
 				BT_IO_OPT_SOURCE_BDADDR, src,
 				BT_IO_OPT_DEST_BDADDR, dst,
 				BT_IO_OPT_CID, GATT_CID,
-				BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
+				BT_IO_OPT_SEC_LEVEL, sec_level,
 				BT_IO_OPT_INVALID);
 	else
 		io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
 				BT_IO_OPT_SOURCE_BDADDR, src,
 				BT_IO_OPT_DEST_BDADDR, dst,
 				BT_IO_OPT_PSM, psm,
-				BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
+				BT_IO_OPT_SEC_LEVEL, sec_level,
 				BT_IO_OPT_INVALID);
 
 	if (io == NULL) {
diff --git a/src/glib-helper.h b/src/glib-helper.h
index 10718bb..17739cf 100644
--- a/src/glib-helper.h
+++ b/src/glib-helper.h
@@ -35,6 +35,7 @@ int bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst);
 
 int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
 					bt_primary_t cb, void *user_data,
+					gboolean secure,
 					bt_destroy_t destroy);
 
 gchar *bt_uuid2string(uuid_t *uuid);
-- 
1.7.3.2


^ permalink raw reply related

* Re: [PATCH v4] Bluetooth: Fix __hci_request synchronization for hci_open_dev
From: Marcel Holtmann @ 2010-12-21 14:46 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1292590111-6564-1-git-send-email-johan.hedberg@gmail.com>

Hi Johan,

> 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>
> ---
> v4: Use __u16 instead of int for req_last_cmd
> 
>  include/net/bluetooth/hci_core.h |    3 ++-
>  net/bluetooth/hci_core.c         |   10 +++++++---
>  net/bluetooth/hci_event.c        |   33 +++++++++++++++++++++++----------
>  3 files changed, 32 insertions(+), 14 deletions(-)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 3786ee8..a29feb0 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -129,6 +129,7 @@ struct hci_dev {
>  	wait_queue_head_t	req_wait_q;
>  	__u32			req_status;
>  	__u32			req_result;
> +	__u16			req_last_cmd;
>  
>  	struct inquiry_cache	inq_cache;
>  	struct hci_conn_hash	conn_hash;
> @@ -693,6 +694,6 @@ struct hci_sec_filter {
>  #define hci_req_lock(d)		mutex_lock(&d->req_lock)
>  #define hci_req_unlock(d)	mutex_unlock(&d->req_lock)
>  
> -void hci_req_complete(struct hci_dev *hdev, int result);
> +void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result);
>  
>  #endif /* __HCI_CORE_H */
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 1a4ec97..787c8df 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -91,9 +91,12 @@ static void hci_notify(struct hci_dev *hdev, int event)
>  
>  /* ---- HCI requests ---- */
>  
> -void hci_req_complete(struct hci_dev *hdev, int result)
> +void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result)
>  {
> -	BT_DBG("%s result 0x%2.2x", hdev->name, result);
> +	BT_DBG("%s command 0x%04x result 0x%2.2x", hdev->name, cmd, result);
> +
> +	if (hdev->req_last_cmd && cmd != hdev->req_last_cmd)
> +		return;
>  
>  	if (hdev->req_status == HCI_REQ_PEND) {
>  		hdev->req_result = result;
> @@ -149,7 +152,7 @@ static int __hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *hdev,
>  		break;
>  	}
>  
> -	hdev->req_status = hdev->req_result = 0;
> +	hdev->req_last_cmd = hdev->req_status = hdev->req_result = 0;
>  
>  	BT_DBG("%s end: err %d", hdev->name, err);
>  
> @@ -252,6 +255,7 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
>  	/* Connection accept timeout ~20 secs */
>  	param = cpu_to_le16(0x7d00);
>  	hci_send_cmd(hdev, HCI_OP_WRITE_CA_TIMEOUT, 2, &param);
> +	hdev->req_last_cmd = HCI_OP_WRITE_CA_TIMEOUT;

just for style consistency add an empty line before this command.

And actually hci_init_req is not the only function where you would need
to add hdev->req_last_cmd entries. There are hci_reset_req and some
others. Without that, the rest of your patch makes hci_req_complete a
non functional operation.

Regards

Marcel



^ permalink raw reply

* Re: [PATCH v4] Bluetooth: Fix __hci_request synchronization for hci_open_dev
From: Johan Hedberg @ 2010-12-21 15:02 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1292942802.2658.49.camel@aeonflux>

Hi Marcel,

On Tue, Dec 21, 2010, Marcel Holtmann wrote:
> just for style consistency add an empty line before this command.

Sure.

> And actually hci_init_req is not the only function where you would need
> to add hdev->req_last_cmd entries. There are hci_reset_req and some
> others. Without that, the rest of your patch makes hci_req_complete a
> non functional operation.

Actually no, if req_last_cmd is 0 (which it is in all cases except
hci_init_req) then the comparison is not done:

> +	if (hdev->req_last_cmd && cmd != hdev->req_last_cmd)
> +		return;

I did this to keep the patch simple and to not have to change all the
single HCI command cases. I.e. only multi-HCI command requests need to
set this variable.

Johan

^ permalink raw reply

* Re: [PATCH v4] Bluetooth: Fix __hci_request synchronization for hci_open_dev
From: Marcel Holtmann @ 2010-12-21 15:06 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20101221150258.GA25824@jh-x301>

Hi Johan,

> > And actually hci_init_req is not the only function where you would need
> > to add hdev->req_last_cmd entries. There are hci_reset_req and some
> > others. Without that, the rest of your patch makes hci_req_complete a
> > non functional operation.
> 
> Actually no, if req_last_cmd is 0 (which it is in all cases except
> hci_init_req) then the comparison is not done:
> 
> > +	if (hdev->req_last_cmd && cmd != hdev->req_last_cmd)
> > +		return;
> 
> I did this to keep the patch simple and to not have to change all the
> single HCI command cases. I.e. only multi-HCI command requests need to
> set this variable.

not a huge fan of this, but if you put a comment on top then I could be
convinced ;)

Regards

Marcel



^ permalink raw reply

* [PATCH] Configure HFP/HSP endpoints if headset interface is already connected
From: Luiz Augusto von Dentz @ 2010-12-21 15:43 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

HFP/HSP can be connected when registering an endpoint which is different
than on a2dp where the sep cannot be configured already since it wasn't
available before.
---
 audio/media.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/audio/media.c b/audio/media.c
index b28bb33..97a60a1 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -42,6 +42,7 @@
 #include "transport.h"
 #include "a2dp.h"
 #include "headset.h"
+#include "manager.h"
 
 #ifndef DBUS_TYPE_UNIX_FD
 #define DBUS_TYPE_UNIX_FD -1
@@ -200,10 +201,18 @@ static struct media_endpoint *media_endpoint_create(struct media_adapter *adapte
 		if (endpoint->sep == NULL)
 			goto failed;
 	} else if (strcasecmp(uuid, HFP_AG_UUID) == 0 ||
-					g_strcmp0(uuid, HSP_AG_UUID) == 0)
+					g_strcmp0(uuid, HSP_AG_UUID) == 0) {
+		struct audio_device *dev;
+
 		endpoint->hs_watch = headset_add_state_cb(headset_state_changed,
 								endpoint);
-	else
+		dev = manager_find_device(NULL, &adapter->src, BDADDR_ANY,
+						AUDIO_HEADSET_INTERFACE, TRUE);
+		if (dev)
+			media_endpoint_set_configuration(endpoint, dev, NULL,
+							0, headset_setconf_cb,
+							dev);
+	} else
 		goto failed;
 
 	endpoint->watch = g_dbus_add_disconnect_watch(adapter->conn, sender,
-- 
1.7.1


^ permalink raw reply related

* RE: problem to disconnect with bluez-test
From: Goubert, TonyX @ 2010-12-21 15:57 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <20101221092421.GA17157@jh-x301>

Hi Johan,
Thank you for your answer.

Yes, in fact, I want to use the test scripts in bluez to disconnect a device.

Well, I download the latest version of bluez (Bluez-4.82) and I have not find the command 'disconnect' in the script 'test-device'.
There are : list, create, remove, ... no disconnect.

> I just went ahead and pushed a patch for it upstream.

Can you give me your patch?

BR


--
Tony Goubert
tonyx.goubert@intel.com


-----Original Message-----
From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-owner@vger.kernel.org] On Behalf Of Johan Hedberg
Sent: Tuesday, December 21, 2010 10:24 AM
To: Goubert, TonyX
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: problem to disconnect with bluez-test

Hi Tony,

On Tue, Dec 21, 2010, Goubert, TonyX wrote:
> I have paired a handset with a laptop by using 'simple-agent'
> bluez-test script BUT I can't disconnect it when I use the bluez
> stack.

I suppose you mean you can't disconnect it using the test scripts that
come with BlueZ (since I'm sure you *can* disconnect it with BlueZ as
long as you use the D-Bus interface directly).

> I can remove it (./test-device remove xx:xx:xx:xx:xx:xx) but I
> want to be able to connect/disconnect/connect...

The Device.Disconnect method is indeed something that should be added to
the test-device script. I just went ahead and pushed a patch for it
upstream.

> [root@localhost test]# ./test-device disconnect xx:xx:xx:xx:xx:xx
> Unknown command

This command should work with latest git now.

Johan
--
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
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


^ permalink raw reply

* [PATCH] sbc: detect when bitpool has changed
From: Luiz Augusto von Dentz @ 2010-12-21 16:58 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>

---
 sbc/sbc.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sbc/sbc.c b/sbc/sbc.c
index a6391ae..b3a7a09 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -965,7 +965,8 @@ ssize_t sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
 
 	framelen = sbc_unpack_frame(input, &priv->frame, input_len);
 
-	if (!priv->init) {
+	/* init if no previous frame was encode or bitpool has changed */
+	if (!priv->init || priv->frame.bitpool != sbc->bitpool) {
 		sbc_decoder_init(&priv->dec_state, &priv->frame);
 		priv->init = 1;
 
@@ -1035,7 +1036,8 @@ ssize_t sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
 	if (written)
 		*written = 0;
 
-	if (!priv->init) {
+	/* init if no previous frame was encode or bitpool has changed */
+	if (!priv->init || priv->frame.bitpool != sbc->bitpool) {
 		priv->frame.frequency = sbc->frequency;
 		priv->frame.mode = sbc->mode;
 		priv->frame.channels = sbc->mode == SBC_MODE_MONO ? 1 : 2;
@@ -1120,7 +1122,7 @@ size_t sbc_get_frame_length(sbc_t *sbc)
 	struct sbc_priv *priv;
 
 	priv = sbc->priv;
-	if (priv->init)
+	if (priv->init && priv->frame.bitpool == sbc->bitpool)
 		return priv->frame.length;
 
 	subbands = sbc->subbands ? 8 : 4;
-- 
1.7.1


^ permalink raw reply related

* Re: [RFC 0/1] Implement Compound (Multi-step) GATT Procedure Support
From: Brian Gix @ 2010-12-21 17:25 UTC (permalink / raw)
  To: claudio.takahasi, vinicius.gomes; +Cc: linux-bluetooth
In-Reply-To: <1292626132-30029-1-git-send-email-bgix@codeaurora.org>

Hi Claudio & Vinicius,


On Fri, 2010-12-17 at 14:48 -0800, Brian Gix wrote:
> The following two proposed patches implement a method for correctly
> staging GATT procedures that require multiple ATT req/resp exchanges.

If you guys get a chance, could you consider this proposed change
to gattrib.[ch] and the subsequent change to gatt.c? It differs from my
initial proposed patch which subverted the gattrib queuing mechanism. It
now lets each ATT command run to completion. It also fixes the memory
leak potential that Vinicius spotted.  I think it is important that you
give it at least a cursory look, because you guys know more about bluez
GATT than anyone else here at this point.  Otherwise, I will resubmit
this version as a patch request. -- thx

> 
> The first RFC / PATCH is gattrib.[ch], which allows the caller to specify
> a gboolean indicating that the command being queued is Compound
> (even if the procedure ends up being single/atomic) and a queue ID
> number, which allows the caller to cancel the GATT procedure at any
> stage of the transaction.
> 
> IF -
> The ATT opcode being queued is specified as compound, the resulting response
> will not cause the next item in the queue to be sent until *after* the
> response has been forwarded to the caller via the response callback.
> 
> IF -
> The ATT opcode being queued is *not* compound, the resulting response
> will service the pkt queue immediately (legacy functionality).
> 
> IF -
> The ID passed to g_attrib_send_seq is ZERO, the command pkt will
> be added to the TAIL of the queue, and a new ID assigned to it.
> (Legacy functionality)
> 
> IF -
> The ID passed to g_attrib_send_seq is NON-ZERO, the command pkt
> will be added to the HEAD of the queue, causing it to be the next
> pkt sent to the remote device.  The NON-ZERO ID is also then able
> to cancel the command.
> 
> 
> The second RFC / PATCH is to gatt.c. It modifies the existing gatt_read_char()
> function to recognize the need for a compound Read procedure, and implements
> it as a READ_REQ + READ_BLOB_REQ + READ_BLOB_REQ ...<etc> as needed, using
> the g_attrib_send_seq() logic from the first RFC / PATCH.
> 



^ permalink raw reply

* AVRCP connect failing with Interop headset-Buffalo
From: roystonr @ 2010-12-21 17:35 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: Luiz Augusto von Dentz, Johan Hedberg, roystonr, rshaffer,
	skrovvid

Hi,

During Interop testing with Buffalo headset (supporting A2DP+AVRCP), its
observed that the A2DP connection is failing.

>From the sniffer logs, it’s observed that the DUT (Device under test)
issues avrcp_connect even before the l2cap connections for avdtp transport
and signaling are completed. It’s also observed from the sniffer logs that
the remote side hasn’t responded to one of the DUT’s l2cap connection
request, before the DUT initiates the avrcp_connect.

As an experiment, by modifying the CONTROL_CONNECT_TIMEOUT (in device.c)
value from 2 to 5 seconds this issue with the mentioned headset is
avoided.

To my understanding, CONTROL_CONNECT_TIMEOUT controls the interval at
which the avrcp_connect is initiated from the DUT i.e. if the stream setup
is active then the timer is kicked in to delay the DUT side avrcp_connect.

Though by increasing the CONTROL_CONNECT_TIMEOUT value, this issue with
the headset under test is avoided. The ideal way would be to trigger the
DUT initiated avrcp_connect only after the l2cap connections are
completed. Correct me if my understanding is wrong.

Kindly provide reference as to how to control the DUT initiated
avrcp_connect only after ensuring that the l2cap connections are
completed. Or is it safe to the modify CONTROL_CONNECT_TIMEOUT value as
mentioned above.

Regards,
Royston Rodrigues.
"Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum."


^ permalink raw reply

* Re: [PATCH] sbc: detect when bitpool has changed
From: Brian Gix @ 2010-12-21 18:02 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1292950724-4918-1-git-send-email-luiz.dentz@gmail.com>

Hello Luiz,

On Tue, 2010-12-21 at 18:58 +0200, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
> 
> ---
>  sbc/sbc.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/sbc/sbc.c b/sbc/sbc.c
> index a6391ae..b3a7a09 100644
> --- a/sbc/sbc.c
> +++ b/sbc/sbc.c
> @@ -965,7 +965,8 @@ ssize_t sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
>  
>  	framelen = sbc_unpack_frame(input, &priv->frame, input_len);
>  
> -	if (!priv->init) {
> +	/* init if no previous frame was encode or bitpool has changed */
> +	if (!priv->init || priv->frame.bitpool != sbc->bitpool) {
>  		sbc_decoder_init(&priv->dec_state, &priv->frame);
>  		priv->init = 1;

I don't think it is a good idea to reinitialize the SBC decoder if a
change in bitpool size is detected.

The A2DP and AVDTP specifications do not allow most of the parameters to
change from one frame to the next (mode, channels, subbands, blocks,
allocation, frequency) but explicitly DO allow changes in bitpool size
midstream.  This allows for Variable Bit Rate (VBR) streaming, and adds
efficiency to the over-the-air link with no quality loss.  Also, the
space required for decoding does not change just because the bitpool has
changed, so re-initialization should not be required.

The only things that should be different from one SBC frame to the next
is the bitpool of course, and the framelen. That said, if a bitpool
change is detected the only thing within that "IF" block that should be
updated is:
sbc->bitpool

If any of the other afore mentioned parameters change, the stream should
be terminated.

>  
> @@ -1035,7 +1036,8 @@ ssize_t sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
>  	if (written)
>  		*written = 0;
>  
> -	if (!priv->init) {
> +	/* init if no previous frame was encode or bitpool has changed */
> +	if (!priv->init || priv->frame.bitpool != sbc->bitpool) {
>  		priv->frame.frequency = sbc->frequency;
>  		priv->frame.mode = sbc->mode;
>  		priv->frame.channels = sbc->mode == SBC_MODE_MONO ? 1 : 2;

Same basic comment here, although it is perfectly allowable for the
Encoder to not support VBR. However if the Encoder does change the
bitpool, then the list of fields that need to be updated are:
priv->frame.bitpool
priv->frame.length

But again, the sbc_encoder_init should *not* be re-run.  I would pull
those two variables out of that IF block, and set them in their own IF
block either directly before or directly after the !priv->init IF block.


> @@ -1120,7 +1122,7 @@ size_t sbc_get_frame_length(sbc_t *sbc)
>  	struct sbc_priv *priv;
>  
>  	priv = sbc->priv;
> -	if (priv->init)
> +	if (priv->init && priv->frame.bitpool == sbc->bitpool)
>  		return priv->frame.length;
>  
>  	subbands = sbc->subbands ? 8 : 4;

This is a valid change, because bitpool changes do indeed change the
frame.length.

-- 
Brian Gix
bgix@codeaurora.org
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum


^ permalink raw reply

* Re: [RFC 0/1] Implement Compound (Multi-step) GATT Procedure Support
From: Claudio Takahasi @ 2010-12-21 19:25 UTC (permalink / raw)
  To: Brian Gix; +Cc: vinicius.gomes, linux-bluetooth
In-Reply-To: <1292952355.14993.9.camel@sealablnx02.qualcomm.com>

Hi Brian,

On Tue, Dec 21, 2010 at 2:25 PM, Brian Gix <bgix@codeaurora.org> wrote:
> Hi Claudio & Vinicius,
>
>
> On Fri, 2010-12-17 at 14:48 -0800, Brian Gix wrote:
>> The following two proposed patches implement a method for correctly
>> staging GATT procedures that require multiple ATT req/resp exchanges.
>
> If you guys get a chance, could you consider this proposed change
> to gattrib.[ch] and the subsequent change to gatt.c? It differs from my
> initial proposed patch which subverted the gattrib queuing mechanism. It
> now lets each ATT command run to completion. It also fixes the memory
> leak potential that Vinicius spotted.  I think it is important that you
> give it at least a cursory look, because you guys know more about bluez
> GATT than anyone else here at this point.  Otherwise, I will resubmit
> this version as a patch request. -- thx
>

ok. We can review your patches.
Could you please send patches to change gatttool to support this new feature?
How are you testing it? Do you have a modified BlueZ attribute server
or another GATT server?

Claudio

^ permalink raw reply

* Re: [RFC 0/1] Implement Compound (Multi-step) GATT Procedure Support
From: Brian Gix @ 2010-12-21 19:50 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: vinicius.gomes, linux-bluetooth
In-Reply-To: <AANLkTin8BHWOhpnv36ncteMNRfXwU81r17owAAaixiD-@mail.gmail.com>

Hi Caudio,

On Tue, 2010-12-21 at 16:25 -0300, Claudio Takahasi wrote:
> Hi Brian,
> 
> On Tue, Dec 21, 2010 at 2:25 PM, Brian Gix <bgix@codeaurora.org> wrote:
> > Hi Claudio & Vinicius,
> >
> >
> > On Fri, 2010-12-17 at 14:48 -0800, Brian Gix wrote:
> >> The following two proposed patches implement a method for correctly
> >> staging GATT procedures that require multiple ATT req/resp exchanges.
> >
> > If you guys get a chance, could you consider this proposed change
> > to gattrib.[ch] and the subsequent change to gatt.c? It differs from my
> > initial proposed patch which subverted the gattrib queuing mechanism. It
> > now lets each ATT command run to completion. It also fixes the memory
> > leak potential that Vinicius spotted.  I think it is important that you
> > give it at least a cursory look, because you guys know more about bluez
> > GATT than anyone else here at this point.  Otherwise, I will resubmit
> > this version as a patch request. -- thx
> >
> 
> ok. We can review your patches.
> Could you please send patches to change gatttool to support this new feature?
> How are you testing it? Do you have a modified BlueZ attribute server
> or another GATT server?

There are no changes required to gatttool. The implemented high level
function is still to read an attribute, and the function works the same
if the remote attribute is shorter than 22 octets, and will be "long"
only if the first response indicates a remote attribute of 22 octets or
longer. (accounting for the one octet for the response hdr)

I am testing this against against the internal Qualcomm GATT server,
which has been tested at the past two UPFs. This is also the same stack
which I hope to use to pre-vet the SM changes you are leading, prior to
the UPF in Las Vegas.

As my next task, I could implement the capability to support long reads
in the BlueZ GATT server. (likely followed by long writes in both the
GATT client and server of BlueZ)

> 
> Claudio

Thanks,

-- 
Brian Gix
bgix@codeaurora.org
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum


^ permalink raw reply

* [RFC] LE General Discovery Procedure
From: Claudio Takahasi @ 2010-12-21 20:12 UTC (permalink / raw)
  To: BlueZ development

Hi folks,

I'd like to receive opinions of how we should implement the General
Discovery procedure aligned to UI/API and Bluetooth Qualification.
The current implementation reports all found devices using the D-Bus
signal DeviceFound(), Flags AD Type is ignored at the moment, meaning
that Broadcaster and Peripheral are reported.

>From Bluetooth SPEC: General Discovery Procedure -  page 1704

"The Host shall check for the Flags AD type in the advertising data.
If the Flags AD type is present and either the LE General Discoverable
Mode flag is set to one or the LE Limited Discoverable Mode flag is
set to one then the Host shall consider the device as a discovered
device, otherwise the advertising data shall be ignored."

GAP Test Requirement document says that "General Discovery Procedure
Does not find Broadcast device"

We may need to represent the Broadcaster devices creating a D-Bus
device object, it is still unclear to me at the moment. So I have
three suggestions(I prefer the first):
1. Report Peripheral and Broadcaster using DeviceFound() signal and
add an property to identify the role. eg: Broadcaster=false/true
2. Ignore the Broadcaster devices. Means that it will not be possible
to call CreateDevice for these devices.
3. Add a config option to change the discovery behavior to ignore
Broadcaster devices. For qualification test only.

If we choose the first, for qualification test I guess it will be
enough to add an extra filter to ignore the broadcaster devices in the
BlueZ test script.

Regards,
Claudio

^ permalink raw reply

* Re: [RFC] LE General Discovery Procedure
From: Brian Gix @ 2010-12-21 20:24 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: BlueZ development
In-Reply-To: <AANLkTi=px0CQY+W9PqrjMHZGQ6RdXgbd-iQo=K8AA_H6@mail.gmail.com>

Hi Claudio,

On Tue, 2010-12-21 at 17:12 -0300, Claudio Takahasi wrote:
> Hi folks,
> 
[snip]
> We may need to represent the Broadcaster devices creating a D-Bus
> device object, it is still unclear to me at the moment. So I have
> three suggestions(I prefer the first):
> 1. Report Peripheral and Broadcaster using DeviceFound() signal and
> add an property to identify the role. eg: Broadcaster=false/true

I also prefer this solution. The higher layer app or entity should then
filter out any devices that it is not interested in, and should be
examining the properties of all the devices reported to it.  Along with
a Broadcaster property, there should be other properties that indicate
other details such as Pubic/Private addresses, etc.

> 2. Ignore the Broadcaster devices. Means that it will not be possible
> to call CreateDevice for these devices.

Don't like this idea, because at some point BlueZ we be used in a device
which *will* need to be aware of the existence of Broadcaster devices.
And the CreateDevice paradigm is probably to best way to represent these
remote devices.

> 3. Add a config option to change the discovery behavior to ignore
> Broadcaster devices. For qualification test only.

Not a good idea. At the end of the day, a device should be qualifiable
regardless of it's configuration.

> 
> If we choose the first, for qualification test I guess it will be
> enough to add an extra filter to ignore the broadcaster devices in the
> BlueZ test script.

I agree.

> 
> Regards,
> Claudio

-- 
Brian Gix
bgix@codeaurora.org
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum


^ permalink raw reply

* [PATCH v5] Bluetooth: Fix __hci_request synchronization for hci_open_dev
From: johan.hedberg @ 2010-12-21 21:01 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@nokia.com>

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>
---
v5: comment added for req_last_cmd check as well as empty line added to
hci_init_req as requested

 include/net/bluetooth/hci_core.h |    3 ++-
 net/bluetooth/hci_core.c         |   15 ++++++++++++---
 net/bluetooth/hci_event.c        |   33 +++++++++++++++++++++++----------
 3 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 3786ee8..a29feb0 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -129,6 +129,7 @@ struct hci_dev {
 	wait_queue_head_t	req_wait_q;
 	__u32			req_status;
 	__u32			req_result;
+	__u16			req_last_cmd;
 
 	struct inquiry_cache	inq_cache;
 	struct hci_conn_hash	conn_hash;
@@ -693,6 +694,6 @@ struct hci_sec_filter {
 #define hci_req_lock(d)		mutex_lock(&d->req_lock)
 #define hci_req_unlock(d)	mutex_unlock(&d->req_lock)
 
-void hci_req_complete(struct hci_dev *hdev, int result);
+void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result);
 
 #endif /* __HCI_CORE_H */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 1a4ec97..8b602d8 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -91,9 +91,16 @@ static void hci_notify(struct hci_dev *hdev, int event)
 
 /* ---- HCI requests ---- */
 
-void hci_req_complete(struct hci_dev *hdev, int result)
+void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result)
 {
-	BT_DBG("%s result 0x%2.2x", hdev->name, result);
+	BT_DBG("%s command 0x%04x result 0x%2.2x", hdev->name, cmd, result);
+
+	/* If the request has set req_last_cmd (typical for multi-HCI
+	 * command requests) check if the completed command matches
+	 * this, and if not just return. Single HCI command requests
+	 * typically leave req_last_cmd as 0 */
+	if (hdev->req_last_cmd && cmd != hdev->req_last_cmd)
+		return;
 
 	if (hdev->req_status == HCI_REQ_PEND) {
 		hdev->req_result = result;
@@ -149,7 +156,7 @@ static int __hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *hdev,
 		break;
 	}
 
-	hdev->req_status = hdev->req_result = 0;
+	hdev->req_last_cmd = hdev->req_status = hdev->req_result = 0;
 
 	BT_DBG("%s end: err %d", hdev->name, err);
 
@@ -252,6 +259,8 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
 	/* Connection accept timeout ~20 secs */
 	param = cpu_to_le16(0x7d00);
 	hci_send_cmd(hdev, HCI_OP_WRITE_CA_TIMEOUT, 2, &param);
+
+	hdev->req_last_cmd = HCI_OP_WRITE_CA_TIMEOUT;
 }
 
 static void hci_scan_req(struct hci_dev *hdev, unsigned long opt)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 8923b36..3810017 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -58,7 +58,7 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
 
 	clear_bit(HCI_INQUIRY, &hdev->flags);
 
-	hci_req_complete(hdev, status);
+	hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status);
 
 	hci_conn_check_pending(hdev);
 }
@@ -174,7 +174,7 @@ static void hci_cc_write_def_link_policy(struct hci_dev *hdev, struct sk_buff *s
 	if (!status)
 		hdev->link_policy = get_unaligned_le16(sent);
 
-	hci_req_complete(hdev, status);
+	hci_req_complete(hdev, HCI_OP_WRITE_DEF_LINK_POLICY, status);
 }
 
 static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
@@ -183,7 +183,7 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
 
 	BT_DBG("%s status 0x%x", hdev->name, status);
 
-	hci_req_complete(hdev, status);
+	hci_req_complete(hdev, HCI_OP_RESET, status);
 }
 
 static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
@@ -235,7 +235,7 @@ static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb)
 			clear_bit(HCI_AUTH, &hdev->flags);
 	}
 
-	hci_req_complete(hdev, status);
+	hci_req_complete(hdev, HCI_OP_WRITE_AUTH_ENABLE, status);
 }
 
 static void hci_cc_write_encrypt_mode(struct hci_dev *hdev, struct sk_buff *skb)
@@ -258,7 +258,7 @@ static void hci_cc_write_encrypt_mode(struct hci_dev *hdev, struct sk_buff *skb)
 			clear_bit(HCI_ENCRYPT, &hdev->flags);
 	}
 
-	hci_req_complete(hdev, status);
+	hci_req_complete(hdev, HCI_OP_WRITE_ENCRYPT_MODE, status);
 }
 
 static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
@@ -285,7 +285,7 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
 			set_bit(HCI_PSCAN, &hdev->flags);
 	}
 
-	hci_req_complete(hdev, status);
+	hci_req_complete(hdev, HCI_OP_WRITE_SCAN_ENABLE, status);
 }
 
 static void hci_cc_read_class_of_dev(struct hci_dev *hdev, struct sk_buff *skb)
@@ -383,7 +383,7 @@ static void hci_cc_host_buffer_size(struct hci_dev *hdev, struct sk_buff *skb)
 
 	BT_DBG("%s status 0x%x", hdev->name, status);
 
-	hci_req_complete(hdev, status);
+	hci_req_complete(hdev, HCI_OP_HOST_BUFFER_SIZE, status);
 }
 
 static void hci_cc_read_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
@@ -536,7 +536,16 @@ static void hci_cc_read_bd_addr(struct hci_dev *hdev, struct sk_buff *skb)
 	if (!rp->status)
 		bacpy(&hdev->bdaddr, &rp->bdaddr);
 
-	hci_req_complete(hdev, rp->status);
+	hci_req_complete(hdev, HCI_OP_READ_BD_ADDR, rp->status);
+}
+
+static void hci_cc_write_ca_timeout(struct hci_dev *hdev, struct sk_buff *skb)
+{
+	__u8 status = *((__u8 *) skb->data);
+
+	BT_DBG("%s status 0x%x", hdev->name, status);
+
+	hci_req_complete(hdev, HCI_OP_WRITE_CA_TIMEOUT, status);
 }
 
 static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
@@ -544,7 +553,7 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
 	BT_DBG("%s status 0x%x", hdev->name, status);
 
 	if (status) {
-		hci_req_complete(hdev, status);
+		hci_req_complete(hdev, HCI_OP_INQUIRY, status);
 
 		hci_conn_check_pending(hdev);
 	} else
@@ -871,7 +880,7 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff
 
 	clear_bit(HCI_INQUIRY, &hdev->flags);
 
-	hci_req_complete(hdev, status);
+	hci_req_complete(hdev, HCI_OP_INQUIRY, status);
 
 	hci_conn_check_pending(hdev);
 }
@@ -1379,6 +1388,10 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
 		hci_cc_read_bd_addr(hdev, skb);
 		break;
 
+	case HCI_OP_WRITE_CA_TIMEOUT:
+		hci_cc_write_ca_timeout(hdev, skb);
+		break;
+
 	default:
 		BT_DBG("%s opcode 0x%x", hdev->name, opcode);
 		break;
-- 
1.7.2.3


^ permalink raw reply related

* [PATCH 00/18] Making GATT a first class citizen
From: Vinicius Costa Gomes @ 2010-12-21 21:26 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Vinicius Costa Gomes

Hi,

These are the first steps in the direction of making GATT a first
class citizen in Bluez.

For this, the first step is to move the primary service discovery
procedure to the core bluetoothd. For that we needed to move a lot of
code around, and add a few features, for example, we now are able to
store the remote device type and restore it from storage, it is useful
when deciding which medium should be used for service discovery.

While doing this, I noticed something that could cause some confusion:
in the Attribute API, both the Device Service hierarchy
([prefix]/{hci0}/{device0}/{service0}) and the Device Characteristic
([prefix]/{hci0}/{device0}/{service0}/{characteristic0}) have the same
Interface name (org.bluez.Characteristic). Is that on purpose?


Cheers,
--

Sheldon Demario (1):
  Move primary service storage to device.c

Vinicius Costa Gomes (17):
  Fix attrib plugin deregistration
  Fix memory leaks in the attrib-server
  Add a way to store the remote device type
  Add support for storing the device type
  Add support for creating devices from stored types
  Add support for creating devices from stored primary services
  Add a way to retrieve ATT primary services
  Remove GATT information when the device is removed
  Add the btd_ prefix to device_add_service
  Remove duplicated code for discovering GATT services
  Clean up the primary service DBus registration
  Add support for making LE connections to GATT client
  Add a Discover method to the GATT Client
  Remove GetCharacteristics DBus method
  Add support for adding services to the Services property
  Add GetProperties method the Service Interface
  Add a "services" command to test-device

 attrib/att.c        |    5 +
 attrib/att.h        |    7 +
 attrib/client.c     |  449 ++++++++++-----------------------------------------
 attrib/gattrib.c    |    1 +
 input/device.c      |    4 +-
 plugins/hciops.c    |    2 +-
 serial/port.c       |    2 +
 src/adapter.c       |  105 ++++++++++++
 src/attrib-server.c |    6 +
 src/device.c        |   82 +++++++++-
 src/device.h        |    6 +-
 src/glib-helper.c   |   23 ++-
 src/storage.c       |   40 +++++
 src/storage.h       |    3 +
 test/test-device    |   13 ++
 15 files changed, 366 insertions(+), 382 deletions(-)

--
1.7.3.4


^ permalink raw reply

* [PATCH 01/18] Fix attrib plugin deregistration
From: Vinicius Costa Gomes @ 2010-12-21 21:26 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Vinicius Costa Gomes
In-Reply-To: <1292966800-6264-1-git-send-email-vinicius.gomes@openbossa.org>

As the comparison method used for find what to de-register was
wrong, it was causing the btd_device reference that the attrib
plugin was keeping never to be dropped.
---
 attrib/client.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/attrib/client.c b/attrib/client.c
index 8e96af4..69e4fb8 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -167,7 +167,7 @@ static int gatt_dev_cmp(gconstpointer a, gconstpointer b)
 	const struct gatt_service *gatt = a;
 	const struct btd_device *dev = b;
 
-	return gatt->dev == dev;
+	return gatt->dev != dev;
 }
 
 static int characteristic_handle_cmp(gconstpointer a, gconstpointer b)
-- 
1.7.3.4


^ permalink raw reply related

* [PATCH 02/18] Fix memory leaks in the attrib-server
From: Vinicius Costa Gomes @ 2010-12-21 21:26 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Vinicius Costa Gomes
In-Reply-To: <1292966800-6264-1-git-send-email-vinicius.gomes@openbossa.org>

---
 src/attrib-server.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/attrib-server.c b/src/attrib-server.c
index 18759e7..cbc01ee 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -724,6 +724,7 @@ static void connect_event(GIOChannel *io, GError *err, void *user_data)
 
 	channel->attrib = g_attrib_new(io);
 	channel->mtu = ATT_DEFAULT_MTU;
+	g_io_channel_unref(io);
 
 	channel->id = g_attrib_register(channel->attrib, GATTRIB_ALL_EVENTS,
 				channel_handler, channel, NULL);
@@ -803,6 +804,11 @@ failed:
 	g_io_channel_unref(l2cap_io);
 	l2cap_io = NULL;
 
+	if (le_io) {
+		g_io_channel_unref(le_io);
+		le_io = NULL;
+	}
+
 	return -1;
 }
 
-- 
1.7.3.4


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox