Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] [RFC] Add generic descriptor support to Attribute API
From: Elvis Pfützenreuter @ 2011-02-08 19:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: epx

This patch proposes extensions to Attribute API, giving access to all
characteristic descriptors (beyond 'Description' and 'Format').
---
 doc/attribute-api.txt |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/doc/attribute-api.txt b/doc/attribute-api.txt
index 23808e6..eff49b2 100644
--- a/doc/attribute-api.txt
+++ b/doc/attribute-api.txt
@@ -104,6 +104,13 @@ Methods		dict GetProperties()
 
 			Possible Errors: org.bluez.Error.InvalidArguments
 
+		void SetDescriptorValue(object descriptor, array{byte} value)
+
+			Sets descriptor value, provided that it is writable.
+
+			Possible Errors: org.bluez.Error.InvalidArguments
+					 org.bluez.Error.NotAuthorized
+
 Properties 	string UUID [readonly]
 
 			UUID128 of this characteristic.
@@ -143,6 +150,24 @@ Properties 	string UUID [readonly]
 			Friendly representation of the Characteristic Value
 			based on the format attribute.
 
+		dict Descriptors [readonly]
+
+			List of descriptors for this characteristic.
+
+			This list contains only the descriptors not already
+			covered by other properties (v.g. Description, Format).
+
+			Each descriptor is mapped to an unique object path,
+			which is the key for the dict.
+
+			Each dict value is, in turn, a dict with at least
+			the following keys:
+
+			{
+				"UUID": string (descriptor UUID),
+				"Value": array of bytes (raw descriptor value)
+			}
+
 
 Characteristic Watcher hierarchy
 ===============================
-- 
1.7.1


^ permalink raw reply related

* [PATCH] Fix small typo
From: Elvis Pfützenreuter @ 2011-02-08 19:37 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: epx

---
 doc/health-api.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/doc/health-api.txt b/doc/health-api.txt
index a0a1685..3d0a717 100644
--- a/doc/health-api.txt
+++ b/doc/health-api.txt
@@ -18,7 +18,7 @@ Methods:
 
 		Returns the path of the new registered application.
 
-		Dict is defined as bellow:
+		Dict is defined as below:
 		{
 			"DataType": uint16, (mandatory)
 			"Role" : ("Source" or "Sink"), (mandatory)
-- 
1.7.1


^ permalink raw reply related

* Re: A2DP reconfigure with BMW Carkit (supporting multi streams) timeouts.
From: Johan Hedberg @ 2011-02-08 19:06 UTC (permalink / raw)
  To: Höglind, Henrik
  Cc: Lukasz Rymanowski, roystonr@codeaurora.org,
	Luiz Augusto von Dentz, linux-bluetooth@vger.kernel.org,
	skrovvid@codeaurora.org, rshaffer@codeaurora.org
In-Reply-To: <9A742367D258D34A9753780E2AE6B8BD2CB6E93748@SELDMBX04.corpusers.net>

Hi Henrik,

On Tue, Feb 08, 2011, Höglind, Henrik wrote:
> Hi Lukasz, Roystonr, Johan,
> 
> >> Have provided the patch to the tester to verify as we don't have the BMW
> >> CK available locally. Would update the feedback received.
> >
> >I'm just wondering, Is it working for you ?
> 
> We have been testing this patch and it fixes the problem.

Thanks for the confirmation. I've now pushed a patch for this upstream.

Johan

^ permalink raw reply

* [PATCH 3/3] Bluetooth: update L2CAP SCO, and bluetooth.ko versions
From: Gustavo F. Padovan @ 2011-02-08 18:51 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1297191061-8246-2-git-send-email-padovan@profusion.mobi>

Update to reflect the l2cap.ko sco.ko and bluetooth.ko modules merge.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
 net/bluetooth/af_bluetooth.c |    2 +-
 net/bluetooth/l2cap_core.c   |    2 +-
 net/bluetooth/sco.c          |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index d1413d4..c258027 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -40,7 +40,7 @@
 
 #include <net/bluetooth/bluetooth.h>
 
-#define VERSION "2.15"
+#define VERSION "2.16"
 
 /* Bluetooth sockets */
 #define BT_MAX_PROTO	8
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d4cf883..51672ed 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -55,7 +55,7 @@
 #include <net/bluetooth/hci_core.h>
 #include <net/bluetooth/l2cap.h>
 
-#define VERSION "2.15"
+#define VERSION "2.16"
 
 int disable_ertm;
 
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index db40a35..3520938 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -50,7 +50,7 @@
 #include <net/bluetooth/hci_core.h>
 #include <net/bluetooth/sco.h>
 
-#define VERSION "0.6"
+#define VERSION "0.7"
 
 static int disable_esco;
 
-- 
1.7.4


^ permalink raw reply related

* [PATCH 2/3] Bluetooth: remove l2cap_load() hack
From: Gustavo F. Padovan @ 2011-02-08 18:51 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1297191061-8246-1-git-send-email-padovan@profusion.mobi>

l2cap_load() was added to trigger l2cap.ko module loading from the RFCOMM
and BNEP modules. Now that L2CAP module is gone, we don't need it anymore.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
 net/bluetooth/bnep/core.c   |    2 --
 net/bluetooth/l2cap_core.c  |    8 --------
 net/bluetooth/rfcomm/core.c |    2 --
 3 files changed, 0 insertions(+), 12 deletions(-)

diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 5868597..03d4d12 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -708,8 +708,6 @@ static int __init bnep_init(void)
 {
 	char flt[50] = "";
 
-	l2cap_load();
-
 #ifdef CONFIG_BT_BNEP_PROTO_FILTER
 	strcat(flt, "protocol ");
 #endif
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 518d940..d4cf883 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3858,13 +3858,5 @@ void l2cap_exit(void)
 	l2cap_cleanup_sockets();
 }
 
-void l2cap_load(void)
-{
-	/* Dummy function to trigger automatic L2CAP module loading by
-	 * other modules that use L2CAP sockets but don't use any other
-	 * symbols from it. */
-}
-EXPORT_SYMBOL(l2cap_load);
-
 module_param(disable_ertm, bool, 0644);
 MODULE_PARM_DESC(disable_ertm, "Disable enhanced retransmission mode");
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 6b83776..c997393 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -2154,8 +2154,6 @@ static int __init rfcomm_init(void)
 {
 	int err;
 
-	l2cap_load();
-
 	hci_register_cb(&rfcomm_cb);
 
 	rfcomm_thread = kthread_run(rfcomm_run, NULL, "krfcommd");
-- 
1.7.4


^ permalink raw reply related

* [PATCH 1/3] Bluetooth: Merge L2CAP and SCO modules into bluetooth.ko
From: Gustavo F. Padovan @ 2011-02-08 18:50 UTC (permalink / raw)
  To: linux-bluetooth

Actually doesn't make sense have these modules built separately.
The L2CAP layer is needed by almost all Bluetooth protocols and profiles.
There isn't any real use case without having L2CAP loaded.
SCO is only essential for Audio transfers, but it is so small that we can
have it loaded always in bluetooth.ko without problems.
If you really doesn't want it you can disable SCO in the kernel config.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
 include/net/bluetooth/bluetooth.h |   28 ++++++++++++++++++++++++++++
 net/bluetooth/Kconfig             |   10 ++--------
 net/bluetooth/Makefile            |    5 ++---
 net/bluetooth/af_bluetooth.c      |   30 +++++++++++++++++++++++++++++-
 net/bluetooth/l2cap_core.c        |   13 ++-----------
 net/bluetooth/sco.c               |   13 ++-----------
 6 files changed, 65 insertions(+), 34 deletions(-)

diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index ed7d775..4375043 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -205,4 +205,32 @@ extern void bt_sysfs_cleanup(void);
 
 extern struct dentry *bt_debugfs;
 
+#ifdef CONFIG_BT_L2CAP
+int l2cap_init(void);
+void l2cap_exit(void);
+#else
+static inline int l2cap_init(void)
+{
+	return 0;
+}
+
+static inline void l2cap_exit(void)
+{
+}
+#endif
+
+#ifdef CONFIG_BT_SCO
+int sco_init(void);
+void sco_exit(void);
+#else
+static inline int sco_init(void)
+{
+	return 0;
+}
+
+static inline void sco_exit(void)
+{
+}
+#endif
+
 #endif /* __BLUETOOTH_H */
diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig
index e45eae6..c6f9c2f 100644
--- a/net/bluetooth/Kconfig
+++ b/net/bluetooth/Kconfig
@@ -32,7 +32,7 @@ menuconfig BT
 	  more information, see <http://www.bluez.org/>.
 
 config BT_L2CAP
-	tristate "L2CAP protocol support"
+	bool "L2CAP protocol support"
 	depends on BT
 	select CRC16
 	help
@@ -40,19 +40,13 @@ config BT_L2CAP
 	  connection oriented and connection-less data transport.  L2CAP
 	  support is required for most Bluetooth applications.
 
-	  Say Y here to compile L2CAP support into the kernel or say M to
-	  compile it as module (l2cap).
-
 config BT_SCO
-	tristate "SCO links support"
+	bool "SCO links support"
 	depends on BT
 	help
 	  SCO link provides voice transport over Bluetooth.  SCO support is
 	  required for voice applications like Headset and Audio.
 
-	  Say Y here to compile SCO support into the kernel or say M to
-	  compile it as module (sco).
-
 source "net/bluetooth/rfcomm/Kconfig"
 
 source "net/bluetooth/bnep/Kconfig"
diff --git a/net/bluetooth/Makefile b/net/bluetooth/Makefile
index 339b429..f04fe9a 100644
--- a/net/bluetooth/Makefile
+++ b/net/bluetooth/Makefile
@@ -3,12 +3,11 @@
 #
 
 obj-$(CONFIG_BT)	+= bluetooth.o
-obj-$(CONFIG_BT_L2CAP)	+= l2cap.o
-obj-$(CONFIG_BT_SCO)	+= sco.o
 obj-$(CONFIG_BT_RFCOMM)	+= rfcomm/
 obj-$(CONFIG_BT_BNEP)	+= bnep/
 obj-$(CONFIG_BT_CMTP)	+= cmtp/
 obj-$(CONFIG_BT_HIDP)	+= hidp/
 
 bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o hci_sock.o hci_sysfs.o lib.o
-l2cap-y := l2cap_core.o l2cap_sock.o
+bluetooth-$(CONFIG_BT_L2CAP)	+= l2cap_core.o l2cap_sock.o
+bluetooth-$(CONFIG_BT_SCO)	+= sco.o
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 2abfe2f..d1413d4 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -545,13 +545,41 @@ static int __init bt_init(void)
 
 	BT_INFO("HCI device and connection manager initialized");
 
-	hci_sock_init();
+	err = hci_sock_init();
+	if (err < 0)
+		goto error;
+
+	err = l2cap_init();
+	if (err < 0) {
+		hci_sock_cleanup();
+		goto sock_err;
+	}
+
+	err = sco_init();
+	if (err < 0) {
+		l2cap_exit();
+		goto sock_err;
+	}
 
 	return 0;
+
+sock_err:
+	hci_sock_cleanup();
+
+error:
+	sock_unregister(PF_BLUETOOTH);
+	bt_sysfs_cleanup();
+
+	return err;
 }
 
 static void __exit bt_exit(void)
 {
+
+	sco_exit();
+
+	l2cap_exit();
+
 	hci_sock_cleanup();
 
 	sock_unregister(PF_BLUETOOTH);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index ba7f9da..518d940 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3806,7 +3806,7 @@ static struct hci_proto l2cap_hci_proto = {
 	.recv_acldata	= l2cap_recv_acldata
 };
 
-static int __init l2cap_init(void)
+int __init l2cap_init(void)
 {
 	int err;
 
@@ -3845,7 +3845,7 @@ error:
 	return err;
 }
 
-static void __exit l2cap_exit(void)
+void l2cap_exit(void)
 {
 	debugfs_remove(l2cap_debugfs);
 
@@ -3866,14 +3866,5 @@ void l2cap_load(void)
 }
 EXPORT_SYMBOL(l2cap_load);
 
-module_init(l2cap_init);
-module_exit(l2cap_exit);
-
 module_param(disable_ertm, bool, 0644);
 MODULE_PARM_DESC(disable_ertm, "Disable enhanced retransmission mode");
-
-MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
-MODULE_DESCRIPTION("Bluetooth L2CAP ver " VERSION);
-MODULE_VERSION(VERSION);
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("bt-proto-0");
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 960c6d1..db40a35 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -1023,7 +1023,7 @@ static struct hci_proto sco_hci_proto = {
 	.recv_scodata	= sco_recv_scodata
 };
 
-static int __init sco_init(void)
+int __init sco_init(void)
 {
 	int err;
 
@@ -1061,7 +1061,7 @@ error:
 	return err;
 }
 
-static void __exit sco_exit(void)
+void __exit sco_exit(void)
 {
 	debugfs_remove(sco_debugfs);
 
@@ -1074,14 +1074,5 @@ static void __exit sco_exit(void)
 	proto_unregister(&sco_proto);
 }
 
-module_init(sco_init);
-module_exit(sco_exit);
-
 module_param(disable_esco, bool, 0644);
 MODULE_PARM_DESC(disable_esco, "Disable eSCO connection creation");
-
-MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
-MODULE_DESCRIPTION("Bluetooth SCO ver " VERSION);
-MODULE_VERSION(VERSION);
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("bt-proto-2");
-- 
1.7.4


^ permalink raw reply related

* Re: [PATCH v9] Bluetooth: btwilink driver
From: Gustavo F. Padovan @ 2011-02-08 18:16 UTC (permalink / raw)
  To: pavan_savoy; +Cc: linux-bluetooth, marcel
In-Reply-To: <1297080737-21032-1-git-send-email-pavan_savoy@ti.com>

Hi Pavan,

* pavan_savoy@ti.com <pavan_savoy@ti.com> [2011-02-07 06:12:17 -0600]:

> From: Pavan Savoy <pavan_savoy@ti.com>
> 
> Gustavo,
> 
> Find below the patch version v9.
> Have taken care of Ville's comments.
> In addition fixed the issue seen when built as module, with
> repeated probe/remove of the platform driver.
> 
> patch v8 comments taken care,
> 
> As suggested, the modifications to TI ST driver to remove the bluetooth
> references have been made and the changes have been merged to the
> linux-next tree.
> 
> Find below the patch for the btwilink driver,
> I have taken care of your following comments,
> 1. channel IDs and the offsets are now being taken from the
> header file hci.h.
> 2. removed the un-necessary BT_ERR.
> 3. changed the order during return from st_register.
> 4. continue to unregister even if 1st unregister fails.
> 
> Please review and provide comments,
> 
> Thanks & Regards,
> Pavan Savoy
> 
> -- patch description --
> 
> This is the bluetooth protocol driver for the TI WiLink7 chipsets.
> Texas Instrument's WiLink chipsets combine wireless technologies
> like BT, FM, GPS and WLAN onto a single chip.
> 
> This Bluetooth driver works on top of the TI_ST shared transport
> line discipline driver which also allows other drivers like
> FM V4L2 and GPS character driver to make use of the same UART interface.
> 
> Kconfig and Makefile modifications to enable the Bluetooth
> driver for Texas Instrument's WiLink 7 chipset.
> 
> Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
> ---
>  drivers/bluetooth/Kconfig    |   10 +
>  drivers/bluetooth/Makefile   |    1 +
>  drivers/bluetooth/btwilink.c |  397 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 408 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/bluetooth/btwilink.c
> 
> diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
> index 02deef4..8e0de9a 100644
> --- a/drivers/bluetooth/Kconfig
> +++ b/drivers/bluetooth/Kconfig
> @@ -219,4 +219,14 @@ config BT_ATH3K
>  	  Say Y here to compile support for "Atheros firmware download driver"
>  	  into the kernel or say M to compile it as module (ath3k).
>  
> +config BT_WILINK
> +	tristate "Texas Instruments WiLink7 driver"
> +	depends on TI_ST
> +	help
> +	  This enables the Bluetooth driver for Texas Instrument's BT/FM/GPS
> +	  combo devices. This makes use of shared transport line discipline
> +	  core driver to communicate with the BT core of the combo chip.
> +
> +	  Say Y here to compile support for Texas Instrument's WiLink7 driver
> +	  into the kernel or say M to compile it as module.
>  endmenu
> diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
> index 71bdf13..f4460f4 100644
> --- a/drivers/bluetooth/Makefile
> +++ b/drivers/bluetooth/Makefile
> @@ -18,6 +18,7 @@ obj-$(CONFIG_BT_HCIBTSDIO)	+= btsdio.o
>  obj-$(CONFIG_BT_ATH3K)		+= ath3k.o
>  obj-$(CONFIG_BT_MRVL)		+= btmrvl.o
>  obj-$(CONFIG_BT_MRVL_SDIO)	+= btmrvl_sdio.o
> +obj-$(CONFIG_BT_WILINK)		+= btwilink.o
>  
>  btmrvl-y			:= btmrvl_main.o
>  btmrvl-$(CONFIG_DEBUG_FS)	+= btmrvl_debugfs.o
> diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
> new file mode 100644
> index 0000000..79c70c2
> --- /dev/null
> +++ b/drivers/bluetooth/btwilink.c
> @@ -0,0 +1,397 @@
> +/*
> + *  Texas Instrument's Bluetooth Driver For Shared Transport.
> + *
> + *  Bluetooth Driver acts as interface between HCI core and
> + *  TI Shared Transport Layer.
> + *
> + *  Copyright (C) 2009-2010 Texas Instruments
> + *  Author: Raja Mani <raja_mani@ti.com>
> + *	Pavan Savoy <pavan_savoy@ti.com>
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License version 2 as
> + *  published by the Free Software Foundation.
> + *
> + *  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + *
> + */
> +#define DEBUG
> +#include <linux/platform_device.h>
> +#include <net/bluetooth/bluetooth.h>
> +#include <net/bluetooth/hci_core.h>
> +#include <net/bluetooth/hci.h>
> +
> +#include <linux/ti_wilink_st.h>
> +
> +/* Bluetooth Driver Version */
> +#define VERSION               "1.0"
> +#define MAX_BT_CHNL_IDS		3
> +
> +/* Number of seconds to wait for registration completion
> + * when ST returns PENDING status.
> + */
> +#define BT_REGISTER_TIMEOUT   6000	/* 6 sec */
> +
> +/**
> + * struct ti_st - driver operation structure
> + * @hdev: hci device pointer which binds to bt driver
> + * @reg_status: ST registration callback status
> + * @st_write: write function provided by the ST driver
> + *	to be used by the driver during send_frame.
> + * @wait_reg_completion - completion sync between ti_st_open
> + *	and st_reg_completion_cb.
> + */
> +struct ti_st {
> +	struct hci_dev *hdev;
> +	char reg_status;
> +	long (*st_write) (struct sk_buff *);
> +	struct completion wait_reg_completion;
> +};
> +
> +/* Increments HCI counters based on pocket ID (cmd,acl,sco) */
> +static inline void ti_st_tx_complete(struct ti_st *hst, int pkt_type)
> +{
> +	struct hci_dev *hdev = hst->hdev;
> +
> +	/* Update HCI stat counters */
> +	switch (pkt_type) {
> +	case HCI_COMMAND_PKT:
> +		hdev->stat.cmd_tx++;
> +		break;
> +
> +	case HCI_ACLDATA_PKT:
> +		hdev->stat.acl_tx++;
> +		break;
> +
> +	case HCI_SCODATA_PKT:
> +		hdev->stat.sco_tx++;
> +		break;
> +	}
> +}
> +
> +/* ------- Interfaces to Shared Transport ------ */
> +
> +/* Called by ST layer to indicate protocol registration completion
> + * status.ti_st_open() function will wait for signal from this
> + * API when st_register() function returns ST_PENDING.
> + */
> +static void st_reg_completion_cb(void *priv_data, char data)
> +{
> +	struct ti_st *lhst = priv_data;
> +
> +	/* Save registration status for use in ti_st_open() */
> +	lhst->reg_status = data;
> +	/* complete the wait in ti_st_open() */
> +	complete(&lhst->wait_reg_completion);
> +}
> +
> +/* Called by Shared Transport layer when receive data is
> + * available */
> +static long st_receive(void *priv_data, struct sk_buff *skb)
> +{
> +	struct ti_st *lhst = priv_data;
> +	int err;
> +
> +	if (!skb)
> +		return -EFAULT;
> +
> +	if (!lhst) {
> +		kfree_skb(skb);
> +		return -EFAULT;
> +	}
> +
> +	skb->dev = (void *) lhst->hdev;
> +
> +	/* Forward skb to HCI core layer */
> +	err = hci_recv_frame(skb);
> +	if (err < 0) {
> +		BT_ERR("Unable to push skb to HCI core(%d)", err);
> +		return err;
> +	}
> +
> +	lhst->hdev->stat.byte_rx += skb->len;
> +
> +	return 0;
> +}
> +
> +/* ------- Interfaces to HCI layer ------ */
> +/* protocol structure registered with shared transport */
> +static struct st_proto_s ti_st_proto[MAX_BT_CHNL_IDS] = {
> +	{
> +		.chnl_id = HCI_ACLDATA_PKT, /* ACL */
> +		.hdr_len = sizeof(struct hci_acl_hdr),
> +		.offset_len_in_hdr = offsetof(struct hci_acl_hdr, dlen),
> +		.len_size = 2,	/* sizeof(dlen) in struct hci_acl_hdr */
> +		.reserve = 8,
> +	},
> +	{
> +		.chnl_id = HCI_SCODATA_PKT, /* SCO */
> +		.hdr_len = sizeof(struct hci_sco_hdr),
> +		.offset_len_in_hdr = offsetof(struct hci_sco_hdr, dlen),
> +		.len_size = 1, /* sizeof(dlen) in struct hci_sco_hdr */
> +		.reserve = 8,
> +	},
> +	{
> +		.chnl_id = HCI_EVENT_PKT, /* HCI Events */
> +		.hdr_len = sizeof(struct hci_event_hdr),
> +		.offset_len_in_hdr = offsetof(struct hci_event_hdr, plen),
> +		.len_size = 1, /* sizeof(plen) in struct hci_event_hdr */
> +		.reserve = 8,
> +	},
> +};
> +
> +/* Called from HCI core to initialize the device */
> +static int ti_st_open(struct hci_dev *hdev)
> +{
> +	unsigned long timeleft;
> +	struct ti_st *hst;
> +	int err, i;
> +
> +	BT_DBG("%s %p", hdev->name, hdev);
> +
> +	if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
> +		return -EBUSY;
> +
> +	/* provide contexts for callbacks from ST */
> +	hst = hdev->driver_data;
> +
> +	for (i = 0; i < MAX_BT_CHNL_IDS; i++) {
> +		ti_st_proto[i].priv_data = hst;
> +		ti_st_proto[i].max_frame_size = HCI_MAX_FRAME_SIZE;
> +		ti_st_proto[i].recv = st_receive;
> +		ti_st_proto[i].reg_complete_cb = st_reg_completion_cb;
> +
> +		/* Prepare wait-for-completion handler */
> +		init_completion(&hst->wait_reg_completion);
> +
> +		err = st_register(&ti_st_proto[i]);
> +		if (!err)
> +			goto done_downloading_firmware;
> +
> +		if (err != -EINPROGRESS) {
> +			clear_bit(HCI_RUNNING, &hdev->flags);
> +			BT_ERR("st_register failed %d", err);
> +			return err;
> +		}
> +
> +		/* ST is busy with either protocol
> +		 * registration or firmware download.
> +		 */
> +
> +		/* Reset ST registration callback status flag,
> +		 * this value will be updated in
> +		 * st_reg_completion_cb()
> +		 * function whenever it called from ST driver.
> +		 */
> +		hst->reg_status = -EINPROGRESS;
> +
> +		BT_DBG("waiting for registration "
> +				"completion signal from ST");
> +		timeleft = wait_for_completion_timeout
> +			(&hst->wait_reg_completion,
> +			 msecs_to_jiffies(BT_REGISTER_TIMEOUT));
> +		if (!timeleft) {
> +			clear_bit(HCI_RUNNING, &hdev->flags);
> +			BT_ERR("Timeout(%d sec),didn't get reg "
> +					"completion signal from ST",
> +					BT_REGISTER_TIMEOUT / 1000);
> +			return -ETIMEDOUT;
> +		}
> +
> +		/* Is ST registration callback
> +		 * called with ERROR status? */
> +		if (hst->reg_status != 0) {
> +			clear_bit(HCI_RUNNING, &hdev->flags);
> +			BT_ERR("ST registration completed with invalid "
> +					"status %d", hst->reg_status);
> +			return -EAGAIN;
> +		}
> +
> +done_downloading_firmware:

done_downloading_firmware is way too big, please use just "done".

> +		hst->st_write = ti_st_proto[i].write;
> +		if (!hst->st_write) {
> +			BT_ERR("undefined ST write function");
> +			clear_bit(HCI_RUNNING, &hdev->flags);
> +			for (i = 0; i < MAX_BT_CHNL_IDS; i++) {
> +				/* Undo registration with ST */
> +				err = st_unregister(&ti_st_proto[i]);
> +				if (err)
> +					BT_ERR("st_unregister() failed with "
> +							"error %d", err);
> +				hst->st_write = NULL;
> +			}
> +			return -EIO;
> +		}
> +	}
> +	return 0;
> +}
> +
> +/* Close device */
> +static int ti_st_close(struct hci_dev *hdev)
> +{
> +	int err, i;
> +	struct ti_st *hst = hdev->driver_data;
> +
> +	if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
> +		return 0;
> +
> +	for (i = 0; i < MAX_BT_CHNL_IDS; i++) {
> +		err = st_unregister(&ti_st_proto[i]);
> +		if (err)
> +			BT_ERR("st_unregister(%d) failed with error %d",
> +					ti_st_proto[i].chnl_id, err);
> +	}
> +
> +	hst->st_write = NULL;
> +
> +	return err;
> +}
> +
> +static int ti_st_send_frame(struct sk_buff *skb)
> +{
> +	struct hci_dev *hdev;
> +	struct ti_st *hst;
> +	long len;
> +
> +	hdev = (struct hci_dev *)skb->dev;
> +
> +	if (!test_bit(HCI_RUNNING, &hdev->flags))
> +		return -EBUSY;
> +
> +	hst = hdev->driver_data;
> +
> +	/* Prepend skb with frame type */
> +	memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
> +
> +	BT_DBG("%s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type,
> +			skb->len);
> +
> +	/* Insert skb to shared transport layer's transmit queue.
> +	 * Freeing skb memory is taken care in shared transport layer,
> +	 * so don't free skb memory here.
> +	 */
> +	len = hst->st_write(skb);
> +	if (len < 0) {
> +		kfree_skb(skb);
> +		BT_ERR("ST write failed (%ld)", len);
> +		/* Try Again, would only fail if UART has gone bad */
> +		return -EAGAIN;
> +	}
> +
> +	/* ST accepted our skb. So, Go ahead and do rest */
> +	hdev->stat.byte_tx += len;
> +	ti_st_tx_complete(hst, bt_cb(skb)->pkt_type);
> +
> +	return 0;
> +}
> +
> +static void ti_st_destruct(struct hci_dev *hdev)
> +{
> +	BT_DBG("%s", hdev->name);
> +	/* do nothing here, since platform remove
> +	 * would free the hdev->driver_data
> +	 */
> +}

Then remove this function...

> +
> +static int bt_ti_probe(struct platform_device *pdev)
> +{
> +	static struct ti_st *hst;
> +	struct hci_dev *hdev;
> +	int err;
> +
> +	hst = kzalloc(sizeof(struct ti_st), GFP_KERNEL);
> +	if (!hst)
> +		return -ENOMEM;
> +
> +	/* Expose "hciX" device to user space */
> +	hdev = hci_alloc_dev();
> +	if (!hdev) {
> +		kfree(hst);
> +		return -ENOMEM;
> +	}
> +
> +	BT_DBG("hdev %p", hdev);
> +
> +	hst->hdev = hdev;
> +	hdev->bus = HCI_UART;
> +	hdev->driver_data = hst;
> +	hdev->open = ti_st_open;
> +	hdev->close = ti_st_close;
> +	hdev->flush = NULL;
> +	hdev->send = ti_st_send_frame;
> +	hdev->destruct = ti_st_destruct;

...and also the line that sets it.

-- 
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply

* Re: Frequent SM test failure at UPF
From: Brian Gix @ 2011-02-08 17:35 UTC (permalink / raw)
  To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <20110208135849.GA31237@piper>

Hi Vinicius,

On 2/8/2011 5:58 AM, Vinicius Costa Gomes wrote:
> Hi Brian,
>
> On 17:22 Mon 07 Feb, Brian Gix wrote:
>> On 2/7/2011 4:26 PM, Brian Gix wrote:
>>>
>>> Testing of Shorter than 16 octet keys.
>>>
>>> In smp_cmd_pairing_random() when the STK is generated, it needs to be
>>> truncated to the MIN of conn->preq[4] and conn->pres[4].
>>>
>>> This Min value may need to be saved for later as well, because it needs
>>> to also limit the LTK key exchange.
>>>
>>> This failure showed up with the PTS tool, and at least one other device
>>> during the days testing. I have mocked up a fix, but have not had a
>>> chance to test it yet.
>>>
>>>
>
> First, thanks for the reports. This particular issue should be fixed soon.
>

When testing this morning, I successfully negotiated and paired with a 
device, where we both said that we could accept and produce all keys 
(key mask 0x07).  We were the responder, and sent all keys (0x06 through 
0x0A) then we received all keys from remote device (0x06 through 0x0A). 
  The apparent problem was that we sent the all of our keys a second 
time.  This caused no problems, but was noticable on the hcidump trace:

 > ACL data: handle 10 flags 0x02 dlen 11
     L2CAP(d): cid 0x0006 len 7 [psm 0]
       0000: 01 03 00 00 10 07 07                              .......
< ACL data: handle 10 flags 0x00 dlen 11
     0000: 07 00 06 00 02 03 00 00  10 07 07                 ...........
 > HCI Event: Number of Completed Packets (0x13) plen 5
     handle 10 packets 1
 > ACL data: handle 10 flags 0x02 dlen 21
     L2CAP(d): cid 0x0006 len 17 [psm 0]
       0000: 03 de 36 99 3f ed 4a 13  78 2c 3e dd 6f 3c 0f 2f 
..6.?.J.x,>.o<./
       0010: 6e                                                n
< ACL data: handle 10 flags 0x00 dlen 21
     0000: 11 00 06 00 03 df 4b f0  b0 f1 8e 1c 5e b6 f9 9c 
......K.....^...
     0010: c4 65 c3 9e 3d                                    .e..=
 > HCI Event: Number of Completed Packets (0x13) plen 5
     handle 10 packets 1
 > ACL data: handle 10 flags 0x02 dlen 21
     L2CAP(d): cid 0x0006 len 17 [psm 0]
       0000: 04 91 91 91 91 91 91 91  91 91 91 91 91 91 91 91 
................
       0010: 91                                                .
< ACL data: handle 10 flags 0x00 dlen 21
     0000: 11 00 06 00 04 56 54 2b  45 81 16 6a d4 58 5c 73 
.....VT+E..j.X\s
     0010: 77 08 43 e5 6f                                    w.C.o
 > HCI Event: Number of Completed Packets (0x13) plen 5
     handle 10 packets 1
 > HCI Event: LE Meta Event (0x3e) plen 13
     LE Long Term Key Request
     0000: 0a 00 00 00 00 00 00 00  00 00 00 00              ............
< HCI Command: LE Long Term Key Request Reply (0x08|0x001a) plen 18
   0000: 0a 00 16 51 6d 0c c3 59  fc 71 e2 e1 64 59 a7 81  ...Qm..Y.q..dY..
   0010: c1 72                                             .r
 > HCI Event: Command Complete (0x0e) plen 6
     LE Long Term Key Request Reply (0x08|0x001a) ncmd 1
     0000: 00 0a 00                                          ...
 > HCI Event: Encrypt Change (0x08) plen 4
     status 0x00 handle 10 encrypt 0x01
< ACL data: handle 10 flags 0x00 dlen 21
     0000: 11 00 06 00 06 01 01 01  01 01 01 01 01 01 01 01 
................
     0010: 01 01 01 01 01                                    .....
< ACL data: handle 10 flags 0x00 dlen 15
     0000: 0b 00 06 00 07 02 02 02  02 02 02 02 02 02 02     ...............
< ACL data: handle 10 flags 0x00 dlen 21
     0000: 11 00 06 00 08 04 04 04  04 04 04 04 04 04 04 04 
................
     0010: 04 04 04 04 04                                    .....
< ACL data: handle 10 flags 0x00 dlen 12
     0000: 08 00 06 00 09 00 53 53  53 53 53 53              ......SSSSSS
< ACL data: handle 10 flags 0x00 dlen 21
     0000: 11 00 06 00 0a 05 05 05  05 05 05 05 05 05 05 05 
................
     0010: 05 05 05 05 05                                    .....
 > HCI Event: Number of Completed Packets (0x13) plen 5
     handle 10 packets 4
 > HCI Event: Number of Completed Packets (0x13) plen 5
     handle 10 packets 1
 > ACL data: handle 10 flags 0x02 dlen 21
     L2CAP(d): cid 0x0006 len 17 [psm 0]
       0000: 06 87 87 87 87 87 87 87  87 87 87 87 87 87 87 87 
................
       0010: 87                                                .
 > ACL data: handle 10 flags 0x02 dlen 15
     L2CAP(d): cid 0x0006 len 11 [psm 0]
       0000: 07 33 22 91 91 91 91 91  91 91 91                 .3"........
 > ACL data: handle 10 flags 0x02 dlen 21
     L2CAP(d): cid 0x0006 len 17 [psm 0]
       0000: 08 98 98 98 98 98 98 98  98 98 98 98 98 98 98 98 
................
       0010: 98                                                .
 > ACL data: handle 10 flags 0x02 dlen 12
     L2CAP(d): cid 0x0006 len 8 [psm 0]
       0000: 09 00 45 98 76 98 34 67                           ..E.v.4g
 > ACL data: handle 10 flags 0x02 dlen 21
     L2CAP(d): cid 0x0006 len 17 [psm 0]
       0000: 0a 99 99 99 99 99 99 99  99 99 99 99 99 99 99 99 
................
       0010: 99                                                .
< ACL data: handle 10 flags 0x00 dlen 21
     0000: 11 00 06 00 06 01 01 01  01 01 01 01 01 01 01 01 
................
     0010: 01 01 01 01 01                                    .....
< ACL data: handle 10 flags 0x00 dlen 15
     0000: 0b 00 06 00 07 02 02 02  02 02 02 02 02 02 02     ...............
< ACL data: handle 10 flags 0x00 dlen 21
     0000: 11 00 06 00 08 04 04 04  04 04 04 04 04 04 04 04 
................
     0010: 04 04 04 04 04                                    .....
< ACL data: handle 10 flags 0x00 dlen 12
     0000: 08 00 06 00 09 00 53 53  53 53 53 53              ......SSSSSS
< ACL data: handle 10 flags 0x00 dlen 21
     0000: 11 00 06 00 0a 05 05 05  05 05 05 05 05 05 05 05 
................
     0010: 05 05 05 05 05                                    .....
 > HCI Event: Number of Completed Packets (0x13) plen 5
     handle 10 packets 3
 > HCI Event: Number of Completed Packets (0x13) plen 5
     handle 10 packets 1
 > HCI Event: Number of Completed Packets (0x13) plen 5
     handle 10 packets 1
 > HCI Event: Disconn Complete (0x05) plen 4
     status 0x00 handle 10 reason 0x13
     Reason: Remote User Terminated Connection






-- 
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

* pull request: bluetooth-next-2.6 2011-02-08
From: Gustavo F. Padovan @ 2011-02-08 17:29 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, linux-bluetooth

Hi John,

That is a big one. The major things here are the HCI management interface and
the l2cap.c file split. On the HCI management interface Johan Hedberg took a
big step implement support for many HCI commandsi/events in kernel side.
I did the l2cap.c split, that file was almost 5000 lines big a more code is
expected to come soon.
The rest are only bug fixes, expect a patch from Andrei Emeltchenko to add
support to configure the flushable flag in LMP.

Please pull. Thanks. 


The following changes since commit 3ad97fbcc233a295f2ccc2c6bdeb32323e360a5e:

  mac80211: remove unneeded check (2011-02-07 16:18:28 -0500)

are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth-next-2.6.git master

Andrei Emeltchenko (3):
      Bluetooth: Use non-flushable by default L2CAP data packets
      Bluetooth: Do not use assignments in IF conditions
      Bluetooth: fix crash by disabling tasklet in sock accept

Bao Liang (1):
      Bluetooth: Set conn state to BT_DISCONN to avoid multiple responses

Cho, Yu-Chen (1):
      Bluetooth: add Atheros BT AR9285 fw supported

Gustavo F. Padovan (19):
      Merge branch 'master' of git://git.kernel.org/.../padovan/bluetooth-2.6 into wireless
      Bluetooth: Fix setting of MTU for ERTM and Streaming Mode
      Bluetooth: Rename l2cap.c to l2cap_core.c
      Bluetooth: Initial work for L2CAP split.
      Bluetooth: move l2cap_sock_ops to l2cap_sock.c
      Bluetooth: move l2cap_sock_release() to l2cap_sock.c
      Bluetooth: move l2cap_sock_bind()/listen() to l2cap_sock.c
      Bluetooth: move l2cap_sock_accept() to l2cap_sock.c
      Bluetooth: move l2cap_sock_getname() to l2cap_sock.c
      Bluetooth: move l2cap_sock_setsockopt() to l2cap_sock.c
      Bluetooth: move l2cap_sock_getsockopt() to l2cap_sock.c
      Bluetooth: move l2cap_sock_connect() to l2cap_sock.c
      Bluetooth: move l2cap_sock_recvmsg() to l2cap_sock.c
      Bluetooth: move l2cap_sock_shutdown() to l2cap_sock.c
      Bluetooth: move l2cap_sock_sendmsg() to l2cap_sock.c
      Bluetooth: move L2CAP sock timers function to l2cap_sock.c
      Bluetooth: move l2cap_sock_kill() to l2cap_sock.c
      Bluetooth: move __l2cap_sock_close() to l2cap_sock.c
      Bluetooth: update Bluetooth daemon name in Kconfig help

Jesper Juhl (1):
      Bluetooth: Fix failure to release lock in read_index_list()

Johan Hedberg (25):
      Bluetooth: Implement automatic setup procedure for local adapters
      Bluetooth: Add support for management powered event
      Bluetooth: Add support for set_powered management command
      Bluetooth: Add support for set_discoverable management command
      Bluetooth: Add set_connectable management command
      Bluetooth: Unify mode related management messages to a single struct
      Bluetooth: Add flag to track managment controlled adapters
      Bluetooth: Add send_mode_rsp convenience function for mgmt.c
      Bluetooth: Implement set_pairable managment command
      Bluetooth: Implement UUID handling through the management interface
      Bluetooth: Implement debugfs support for listing UUIDs
      Bluetooth: Reject pairing requests when in non-pairable mode
      Bluetooth: Add special handling with __hci_request and HCI_INIT
      Bluetooth: Add controller side link key clearing to hci_init_req
      Bluetooth: Remove page timeout setting from HCI init sequence
      Bluetooth: Implement a more complete adapter initialization sequence
      Bluetooth: Add class of device control to the management interface
      Bluetooth: Implement link key handling for the management interface
      Bluetooth: Add connected/disconnected management events
      Bluetooth: Add disconnect managment command
      Bluetooth: Add support for connect failed management event
      Bluetooth: Add get_connections managment interface command
      Bluetooth: Create common cmd_complete function for mgmt.c
      Bluetooth: Add support for PIN code handling in the management interface
      Bluetooth: Add set_io_capability management command

Rogério Brito (1):
      Bluetooth: ath3k: Avoid duplication of code

 drivers/bluetooth/ath3k.c               |   10 +-
 drivers/bluetooth/btusb.c               |    3 +
 include/net/bluetooth/bluetooth.h       |    5 +
 include/net/bluetooth/hci.h             |   57 ++
 include/net/bluetooth/hci_core.h        |   62 ++-
 include/net/bluetooth/l2cap.h           |   32 +
 include/net/bluetooth/mgmt.h            |  142 +++
 net/bluetooth/Kconfig                   |    6 +-
 net/bluetooth/Makefile                  |    1 +
 net/bluetooth/af_bluetooth.c            |   19 +-
 net/bluetooth/cmtp/capi.c               |    3 +-
 net/bluetooth/cmtp/core.c               |    9 +-
 net/bluetooth/hci_conn.c                |    1 +
 net/bluetooth/hci_core.c                |  230 ++++-
 net/bluetooth/hci_event.c               |  457 +++++++++-
 net/bluetooth/hci_sock.c                |    6 +-
 net/bluetooth/hci_sysfs.c               |   52 +
 net/bluetooth/hidp/core.c               |    9 +-
 net/bluetooth/{l2cap.c => l2cap_core.c} | 1618 ++++++-------------------------
 net/bluetooth/l2cap_sock.c              | 1150 ++++++++++++++++++++++
 net/bluetooth/mgmt.c                    | 1310 +++++++++++++++++++++++---
 21 files changed, 3668 insertions(+), 1514 deletions(-)
 rename net/bluetooth/{l2cap.c => l2cap_core.c} (78%)
 create mode 100644 net/bluetooth/l2cap_sock.c

--
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply

* Re: ID_SERIAL for udev bluetooth joystick events
From: Dmitry Torokhov @ 2011-02-08 17:08 UTC (permalink / raw)
  To: Antonio Ospite; +Cc: linux-bluetooth, linux-input, Alan Ott
In-Reply-To: <20110208120533.12613888.ospite@studenti.unina.it>

On Tue, Feb 08, 2011 at 12:05:33PM +0100, Antonio Ospite wrote:
> On Mon, 7 Feb 2011 23:48:42 -0800
> Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> 
> > On Fri, Feb 04, 2011 at 11:34:27PM +0100, Antonio Ospite wrote:
> > > Hi,
> > > 
> > > I have a question about udev events generated by a bluetooth joystick:
> > > when the bt joystick generates the joystick event, the ID_SERIAL
> > > property matches the one of the bt adapter not the one of the joystick.
> > > 
> > > For example (using "udevadm monitor --property"), when connecting the
> > > Sony Sixaxis via usb I get:
> > > ID_SERIAL=Sony_PLAYSTATION_R_3_Controller
> > > in the input and joystick events, but when I connect it via bt, I get:
> > > ID_SERIAL=Broadcom_Corp_ANYCOM_Blue_USB-200_250
> > > which matches my bluetooth adapter.
> > > 
> [...]
> 
> > This should be directed to udev list as composition of ID_SERIAL is
> > done exclusively by udev. It looks like it scans parent till it finds
> > first USB device (thus skipping all BT-specific data).
> > 
> 
> Thanks Dmitry, I'll resend this to linux-hotplug.
> 
> Is it OK for cases like this to still keep linux-bluetooth and
> linux-input in CC?

Sure, why not.

-- 
Dmitry

^ permalink raw reply

* [PATCH 5/5] Add connect/disconnect options on interactive mode of gatttool
From: Sheldon Demario @ 2011-02-08 15:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <1297179136-14750-1-git-send-email-sheldon.demario@openbossa.org>

---
 attrib/gatttool.c  |    4 +-
 attrib/gatttool.h  |    1 +
 attrib/igatttool.c |  103 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 105 insertions(+), 3 deletions(-)

diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index e0de05b..ac9bb60 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -86,7 +86,7 @@ static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
 	}
 }
 
-static GIOChannel *do_connect(gboolean le)
+GIOChannel *do_connect(gboolean le, BtIOConnect connect_cb)
 {
 	GIOChannel *chan;
 	bdaddr_t sba, dba;
@@ -630,7 +630,7 @@ int main(int argc, char *argv[])
 		goto done;
 	}
 
-	chan = do_connect(main_opts.le);
+	chan = do_connect(main_opts.le, connect_cb);
 	if (chan == NULL) {
 		got_error = TRUE;
 		goto done;
diff --git a/attrib/gatttool.h b/attrib/gatttool.h
index 0f78aa8..6fec2b0 100644
--- a/attrib/gatttool.h
+++ b/attrib/gatttool.h
@@ -43,3 +43,4 @@ struct main_opts {
 } main_opts;
 
 int do_interactive(void);
+GIOChannel *do_connect(gboolean le, BtIOConnect connect_cb);
diff --git a/attrib/igatttool.c b/attrib/igatttool.c
index cac97f0..fa014c3 100644
--- a/attrib/igatttool.c
+++ b/attrib/igatttool.c
@@ -25,15 +25,24 @@
 #include <stdio.h>
 #include <glib.h>
 
+#include <bluetooth/sdp.h>
+
 #include <readline/readline.h>
 #include <readline/history.h>
 
+#include "btio.h"
+#include "gattrib.h"
 #include "gatttool.h"
 
+static GIOChannel *iochannel = NULL;
+static GAttrib *attrib = NULL;
 static GMainLoop *event_loop;
+static GString *prompt;
 
 static void cmd_help(int argcp, char **argvp);
 static void cmd_exit(int argcp, char **argvp);
+static void cmd_connect(int argcp, char **argvp);
+static void cmd_disconnect(int argcp, char **argvp);
 
 static struct {
 	const char *cmd;
@@ -42,9 +51,62 @@ static struct {
 } 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"},
 	{ NULL, NULL, NULL}
 };
 
+enum state {
+	STATE_DISCONNECTED,
+	STATE_CONNECTING,
+	STATE_CONNECTED
+} conn_state;
+
+static char *get_prompt(void)
+{
+	if (conn_state == STATE_CONNECTING) {
+		g_string_assign(prompt, "Connecting... ");
+		return prompt->str;
+	}
+
+	if (conn_state == STATE_CONNECTED)
+		g_string_assign(prompt, "[CON]");
+	else
+		g_string_assign(prompt, "[   ]");
+
+	if (main_opts.dst)
+		g_string_append_printf(prompt, "[%17s]", main_opts.dst);
+	else
+		g_string_append_printf(prompt, "[%17s]", "");
+
+	if (main_opts.le)
+		g_string_append(prompt, "[LE]");
+	else
+		g_string_append(prompt, "[BR]");
+
+	g_string_append(prompt, "> ");
+
+	return prompt->str;
+}
+
+static void set_state(enum state st)
+{
+	conn_state = st;
+	rl_set_prompt(get_prompt());
+	rl_redisplay();
+}
+
+static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
+{
+	if (err) {
+		printf("connect error: %s\n", err->message);
+		return;
+	}
+
+	attrib = g_attrib_new(iochannel);
+	set_state(STATE_CONNECTED);
+}
+
 static void cmd_help(int argcp, char **argvp)
 {
 	int i;
@@ -59,6 +121,41 @@ static void cmd_exit(int argcp, char **argvp)
 	g_main_loop_quit(event_loop);
 }
 
+static void cmd_connect(int argcp, char **argvp)
+{
+	if (conn_state != STATE_DISCONNECTED)
+		return;
+
+	if (main_opts.dst == NULL) {
+		printf("Remote Bluetooth address required\n");
+		return;
+	}
+
+	set_state(STATE_CONNECTING);
+	iochannel = do_connect(main_opts.le, connect_cb);
+	if (iochannel == NULL)
+		set_state(STATE_DISCONNECTED);
+
+	return;
+}
+
+static void cmd_disconnect(int argcp, char **argvp)
+{
+	if (conn_state == STATE_DISCONNECTED)
+		return;
+
+	g_attrib_unref(attrib);
+	attrib = NULL;
+
+	g_io_channel_shutdown(iochannel, FALSE, NULL);
+	g_io_channel_unref(iochannel);
+	iochannel = NULL;
+
+	set_state(STATE_DISCONNECTED);
+
+	return;
+}
+
 static void parse_line(char *line_read)
 {
 	gchar **argvp;
@@ -110,6 +207,8 @@ int do_interactive(void)
 	GIOChannel *pchan;
 	gint events;
 
+	prompt = g_string_new(NULL);
+
 	event_loop = g_main_loop_new(NULL, FALSE);
 
 	pchan = g_io_channel_unix_new(fileno(stdin));
@@ -117,13 +216,15 @@ int do_interactive(void)
 	events = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
 	g_io_add_watch(pchan, events, prompt_read, NULL);
 
-	rl_callback_handler_install("> ", parse_line);
+	rl_callback_handler_install(get_prompt(), parse_line);
 
 	g_main_loop_run(event_loop);
 
 	rl_callback_handler_remove();
+	cmd_disconnect(0, NULL);
 	g_io_channel_unref(pchan);
 	g_main_loop_unref(event_loop);
+	g_string_free(prompt, TRUE);
 
 	return 0;
 }
-- 
1.7.1


^ permalink raw reply related

* [PATCH 4/5] Move main_opts from gatttool.c to header file
From: Sheldon Demario @ 2011-02-08 15:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <1297179136-14750-1-git-send-email-sheldon.demario@openbossa.org>

---
 attrib/gatttool.c |   21 ---------------------
 attrib/gatttool.h |   21 +++++++++++++++++++++
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 3eb3b0b..e0de05b 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -50,27 +50,6 @@
 static GMainLoop *event_loop;
 static gboolean got_error = FALSE;
 
-static struct main_opts {
-	gchar *src;
-	gchar *dst;
-	gchar *value;
-	gchar *sec_level;
-	uuid_t *uuid;
-	int start;
-	int end;
-	int handle;
-	int mtu;
-	int psm;
-	gboolean primary;
-	gboolean char_disc;
-	gboolean char_read;
-	gboolean listen;
-	gboolean char_desc;
-	gboolean le;
-	gboolean char_write;
-	gboolean interactive;
-} main_opts;
-
 struct characteristic_data {
 	GAttrib *attrib;
 	uint16_t start;
diff --git a/attrib/gatttool.h b/attrib/gatttool.h
index 9190730..0f78aa8 100644
--- a/attrib/gatttool.h
+++ b/attrib/gatttool.h
@@ -21,4 +21,25 @@
  *
  */
 
+struct main_opts {
+	gchar *src;
+	gchar *dst;
+	gchar *value;
+	gchar *sec_level;
+	uuid_t *uuid;
+	int start;
+	int end;
+	int handle;
+	int mtu;
+	int psm;
+	gboolean primary;
+	gboolean char_disc;
+	gboolean char_read;
+	gboolean listen;
+	gboolean char_desc;
+	gboolean le;
+	gboolean char_write;
+	gboolean interactive;
+} main_opts;
+
 int do_interactive(void);
-- 
1.7.1


^ permalink raw reply related

* [PATCH 3/5] Add an initial interactive mode to gatttool
From: Sheldon Demario @ 2011-02-08 15:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <1297179136-14750-1-git-send-email-sheldon.demario@openbossa.org>

Mode required to allow better GATT procedures control. Some scenarios
require sequential commands without disconnection and delay between
operations. It is also desirable to change some connection parameters
of an active connection.
---
 Makefile.am        |    8 ++-
 attrib/gatttool.c  |    9 ++++
 attrib/gatttool.h  |   24 ++++++++++
 attrib/igatttool.c |  129 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac       |    1 +
 5 files changed, 169 insertions(+), 2 deletions(-)
 create mode 100644 attrib/gatttool.h
 create mode 100644 attrib/igatttool.c

diff --git a/Makefile.am b/Makefile.am
index e6639a7..ee3cd82 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -175,12 +175,16 @@ builtin_sources += plugins/service.c
 endif
 
 if ATTRIBPLUGIN
+
+if READLINE
 bin_PROGRAMS += attrib/gatttool
 
 attrib_gatttool_SOURCES = attrib/gatttool.c attrib/att.c attrib/gatt.c \
 			  attrib/gattrib.c btio/btio.c \
-			  src/glib-helper.h src/glib-helper.c
-attrib_gatttool_LDADD = lib/libbluetooth.la @GLIB_LIBS@
+			  src/glib-helper.h src/glib-helper.c \
+			  attrib/gatttool.h attrib/igatttool.c
+attrib_gatttool_LDADD = lib/libbluetooth.la @GLIB_LIBS@ @READLINE_LIBS@
+endif
 
 builtin_modules += attrib
 builtin_sources += attrib/main.c \
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index c612309..3eb3b0b 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -42,6 +42,7 @@
 #include "gattrib.h"
 #include "glib-helper.h"
 #include "gatt.h"
+#include "gatttool.h"
 
 /* Minimum MTU for L2CAP connections over BR/EDR */
 #define ATT_MIN_MTU_L2CAP 48
@@ -67,6 +68,7 @@ static struct main_opts {
 	gboolean char_desc;
 	gboolean le;
 	gboolean char_write;
+	gboolean interactive;
 } main_opts;
 
 struct characteristic_data {
@@ -565,6 +567,8 @@ static GOptionEntry gatt_options[] = {
 		"Listen for notifications and indications", NULL },
 	{ "le", 0, 0, G_OPTION_ARG_NONE, &main_opts.le,
 		"Use Bluetooth Low Energy transport", NULL },
+	{ "interactive", 'I', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE,
+		&main_opts.interactive, "Use interactive mode", NULL },
 	{ NULL },
 };
 
@@ -624,6 +628,11 @@ int main(int argc, char *argv[])
 		g_error_free(gerr);
 	}
 
+	if (main_opts.interactive) {
+		do_interactive();
+		goto done;
+	}
+
 	if (main_opts.primary)
 		callback = primary;
 	else if (main_opts.char_disc)
diff --git a/attrib/gatttool.h b/attrib/gatttool.h
new file mode 100644
index 0000000..9190730
--- /dev/null
+++ b/attrib/gatttool.h
@@ -0,0 +1,24 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2011  Nokia Corporation
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+int do_interactive(void);
diff --git a/attrib/igatttool.c b/attrib/igatttool.c
new file mode 100644
index 0000000..cac97f0
--- /dev/null
+++ b/attrib/igatttool.c
@@ -0,0 +1,129 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2011  Nokia Corporation
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+#include <strings.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <glib.h>
+
+#include <readline/readline.h>
+#include <readline/history.h>
+
+#include "gatttool.h"
+
+static GMainLoop *event_loop;
+
+static void cmd_help(int argcp, char **argvp);
+static void cmd_exit(int argcp, char **argvp);
+
+static struct {
+	const char *cmd;
+	void (*func)(int argcp, char **argvp);
+	const char *desc;
+} commands[] = {
+	{ "help",	cmd_help,	"Show this help"},
+	{ "exit",	cmd_exit,	"Exit interactive mode"},
+	{ NULL, NULL, NULL}
+};
+
+static void cmd_help(int argcp, char **argvp)
+{
+	int i;
+
+	for (i = 0; commands[i].cmd; i++)
+		printf("%-12s\t%s\n", commands[i].cmd, commands[i].desc);
+}
+
+static void cmd_exit(int argcp, char **argvp)
+{
+	rl_callback_handler_remove();
+	g_main_loop_quit(event_loop);
+}
+
+static void parse_line(char *line_read)
+{
+	gchar **argvp;
+	int argcp;
+	int i;
+
+	if (line_read == NULL) {
+		printf("\n");
+		cmd_exit(0, NULL);
+		return;
+	}
+
+	line_read = g_strstrip(line_read);
+
+	if (*line_read == '\0')
+		return;
+
+	add_history(line_read);
+
+	g_shell_parse_argv(line_read, &argcp, &argvp, NULL);
+
+	for (i = 0; commands[i].cmd; i++)
+		if (strcasecmp(commands[i].cmd, argvp[0]) == 0)
+			break;
+
+	if (commands[i].cmd)
+		commands[i].func(argcp, argvp);
+	else
+		printf("%s: command not found\n", argvp[0]);
+
+	g_strfreev(argvp);
+}
+
+static gboolean prompt_read(GIOChannel *chan, GIOCondition cond,
+							gpointer user_data)
+{
+	if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
+		g_io_channel_unref(chan);
+		return FALSE;
+	}
+
+	rl_callback_read_char();
+
+	return TRUE;
+}
+
+int do_interactive(void)
+{
+	GIOChannel *pchan;
+	gint events;
+
+	event_loop = g_main_loop_new(NULL, FALSE);
+
+	pchan = g_io_channel_unix_new(fileno(stdin));
+	g_io_channel_set_close_on_unref(pchan, TRUE);
+	events = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
+	g_io_add_watch(pchan, events, prompt_read, NULL);
+
+	rl_callback_handler_install("> ", parse_line);
+
+	g_main_loop_run(event_loop);
+
+	rl_callback_handler_remove();
+	g_io_channel_unref(pchan);
+	g_main_loop_unref(event_loop);
+
+	return 0;
+}
diff --git a/configure.ac b/configure.ac
index bebdc9c..a8e8fc6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,6 +42,7 @@ AC_PATH_GSTREAMER
 AC_PATH_USB
 AC_PATH_SNDFILE
 AC_PATH_OUI
+AC_PATH_READLINE
 
 AC_ARG_BLUEZ
 
-- 
1.7.1


^ permalink raw reply related

* [PATCH 2/5] Include check to readline lib on acinlude.m4
From: Sheldon Demario @ 2011-02-08 15:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <1297179136-14750-1-git-send-email-sheldon.demario@openbossa.org>

---
 acinclude.m4 |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 9d3f6b2..91e0956 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -153,6 +153,15 @@ AC_DEFUN([AC_PATH_SNDFILE], [
 	AC_SUBST(SNDFILE_LIBS)
 ])
 
+AC_DEFUN([AC_PATH_READLINE], [
+	AC_CHECK_HEADER(readline/readline.h,
+		AC_CHECK_LIB(readline, main,
+			[ readline_found=yes
+			AC_SUBST(READLINE_LIBS, "-lreadline")
+			], readline_found=no),
+		[])
+])
+
 AC_DEFUN([AC_PATH_OUI], [
 	AC_ARG_WITH(ouifile,
 		    AS_HELP_STRING([--with-ouifile=PATH],[Path to the oui.txt file @<:@auto@:>@]),
@@ -356,6 +365,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [
 	AM_CONDITIONAL(HEALTHPLUGIN, test "${health_enable}" = "yes")
 	AM_CONDITIONAL(MCAP, test "${health_enable}" = "yes")
 	AM_CONDITIONAL(HAL, test "${hal_enable}" = "yes")
+	AM_CONDITIONAL(READLINE, test "${readline_found}" = "yes")
 	AM_CONDITIONAL(ATTRIBPLUGIN, test "${attrib_enable}" = "yes")
 	AM_CONDITIONAL(ECHOPLUGIN, test "no" = "yes")
 	AM_CONDITIONAL(PNATPLUGIN, test "${pnat_enable}" = "yes")
-- 
1.7.1


^ permalink raw reply related

* [PATCH 1/5] Put all gatttool global options in a unique struct
From: Sheldon Demario @ 2011-02-08 15:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Sheldon Demario

---
 attrib/gatttool.c |  186 +++++++++++++++++++++++++++++++----------------------
 1 files changed, 108 insertions(+), 78 deletions(-)

diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 8e8ed8e..c612309 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -46,32 +46,56 @@
 /* Minimum MTU for L2CAP connections over BR/EDR */
 #define ATT_MIN_MTU_L2CAP 48
 
-static gchar *opt_src = NULL;
-static gchar *opt_dst = NULL;
-static gchar *opt_value = NULL;
-static gchar *opt_sec_level = "low";
-static uuid_t *opt_uuid = NULL;
-static int opt_start = 0x0001;
-static int opt_end = 0xffff;
-static int opt_handle = -1;
-static int opt_mtu = 0;
-static int opt_psm = 0x1f;
-static gboolean opt_primary = FALSE;
-static gboolean opt_characteristics = FALSE;
-static gboolean opt_char_read = FALSE;
-static gboolean opt_listen = FALSE;
-static gboolean opt_char_desc = FALSE;
-static gboolean opt_le = FALSE;
-static gboolean opt_char_write = FALSE;
 static GMainLoop *event_loop;
 static gboolean got_error = FALSE;
 
+static struct main_opts {
+	gchar *src;
+	gchar *dst;
+	gchar *value;
+	gchar *sec_level;
+	uuid_t *uuid;
+	int start;
+	int end;
+	int handle;
+	int mtu;
+	int psm;
+	gboolean primary;
+	gboolean char_disc;
+	gboolean char_read;
+	gboolean listen;
+	gboolean char_desc;
+	gboolean le;
+	gboolean char_write;
+} main_opts;
+
 struct characteristic_data {
 	GAttrib *attrib;
 	uint16_t start;
 	uint16_t end;
 };
 
+static void options_init(void)
+{
+	main_opts.src = NULL;
+	main_opts.dst = NULL;
+	main_opts.value = NULL;
+	main_opts.sec_level = "low";
+	main_opts.uuid = NULL;
+	main_opts.start = 0x0001;
+	main_opts.end = 0xffff;
+	main_opts.handle = -1;
+	main_opts.mtu = 0;
+	main_opts.psm = 0x1f;
+	main_opts.primary = FALSE;
+	main_opts.char_disc = FALSE;
+	main_opts.char_read = FALSE;
+	main_opts.listen = FALSE;
+	main_opts.char_desc = FALSE;
+	main_opts.le = FALSE;
+	main_opts.char_write = FALSE;
+}
+
 static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
 {
 	if (err) {
@@ -90,31 +114,31 @@ static GIOChannel *do_connect(gboolean le)
 
 	/* This check is required because currently setsockopt() returns no
 	 * errors for MTU values smaller than the allowed minimum. */
-	if (opt_mtu != 0 && opt_mtu < ATT_MIN_MTU_L2CAP) {
+	if (main_opts.mtu != 0 && main_opts.mtu < ATT_MIN_MTU_L2CAP) {
 		g_printerr("MTU cannot be smaller than %d\n",
 							ATT_MIN_MTU_L2CAP);
 		return NULL;
 	}
 
 	/* Remote device */
-	if (opt_dst == NULL) {
+	if (main_opts.dst == NULL) {
 		g_printerr("Remote Bluetooth address required\n");
 		return NULL;
 	}
-	str2ba(opt_dst, &dba);
+	str2ba(main_opts.dst, &dba);
 
 	/* Local adapter */
-	if (opt_src != NULL) {
-		if (!strncmp(opt_src, "hci", 3))
-			hci_devba(atoi(opt_src + 3), &sba);
+	if (main_opts.src != NULL) {
+		if (!strncmp(main_opts.src, "hci", 3))
+			hci_devba(atoi(main_opts.src + 3), &sba);
 		else
-			str2ba(opt_src, &sba);
+			str2ba(main_opts.src, &sba);
 	} else
 		bacpy(&sba, BDADDR_ANY);
 
-	if (strcmp(opt_sec_level, "medium") == 0)
+	if (strcmp(main_opts.sec_level, "medium") == 0)
 		sec_level = BT_IO_SEC_MEDIUM;
-	else if (strcmp(opt_sec_level, "high") == 0)
+	else if (strcmp(main_opts.sec_level, "high") == 0)
 		sec_level = BT_IO_SEC_HIGH;
 	else
 		sec_level = BT_IO_SEC_LOW;
@@ -124,15 +148,15 @@ static GIOChannel *do_connect(gboolean le)
 				BT_IO_OPT_SOURCE_BDADDR, &sba,
 				BT_IO_OPT_DEST_BDADDR, &dba,
 				BT_IO_OPT_CID, GATT_CID,
-				BT_IO_OPT_OMTU, opt_mtu,
+				BT_IO_OPT_OMTU, main_opts.mtu,
 				BT_IO_OPT_SEC_LEVEL, sec_level,
 				BT_IO_OPT_INVALID);
 	else
 		chan = bt_io_connect(BT_IO_L2CAP, connect_cb, NULL, NULL, &err,
 				BT_IO_OPT_SOURCE_BDADDR, &sba,
 				BT_IO_OPT_DEST_BDADDR, &dba,
-				BT_IO_OPT_PSM, opt_psm,
-				BT_IO_OPT_OMTU, opt_mtu,
+				BT_IO_OPT_PSM, main_opts.psm,
+				BT_IO_OPT_OMTU, main_opts.mtu,
 				BT_IO_OPT_SEC_LEVEL, sec_level,
 				BT_IO_OPT_INVALID);
 
@@ -236,9 +260,9 @@ static gboolean primary(gpointer user_data)
 {
 	GAttrib *attrib = user_data;
 
-	if (opt_uuid)
-		gatt_discover_primary(attrib, opt_uuid, primary_by_uuid_cb,
-									NULL);
+	if (main_opts.uuid)
+		gatt_discover_primary(attrib, main_opts.uuid,
+						primary_by_uuid_cb, NULL);
 	else
 		gatt_discover_primary(attrib, NULL, primary_all_cb, NULL);
 
@@ -272,7 +296,8 @@ static gboolean characteristics(gpointer user_data)
 {
 	GAttrib *attrib = user_data;
 
-	gatt_discover_char(attrib, opt_start, opt_end, char_discovered_cb, NULL);
+	gatt_discover_char(attrib, main_opts.start, main_opts.end,
+						char_discovered_cb, NULL);
 
 	return FALSE;
 }
@@ -298,7 +323,7 @@ static void char_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
 	g_print("\n");
 
 done:
-	if (opt_listen == FALSE)
+	if (main_opts.listen == FALSE)
 		g_main_loop_quit(event_loop);
 }
 
@@ -310,7 +335,7 @@ static void char_read_by_uuid_cb(guint8 status, const guint8 *pdu,
 	int i;
 
 	if (status == ATT_ECODE_ATTR_NOT_FOUND &&
-					char_data->start != opt_start)
+					char_data->start != main_opts.start)
 		goto done;
 
 	if (status != 0) {
@@ -339,7 +364,7 @@ static void char_read_by_uuid_cb(guint8 status, const guint8 *pdu,
 	att_data_list_free(list);
 
 	gatt_read_char_by_uuid(char_data->attrib, char_data->start,
-					char_data->end, opt_uuid,
+					char_data->end, main_opts.uuid,
 					char_read_by_uuid_cb,
 					char_data);
 
@@ -353,27 +378,28 @@ static gboolean characteristics_read(gpointer user_data)
 {
 	GAttrib *attrib = user_data;
 
-	if (opt_uuid != NULL) {
+	if (main_opts.uuid != NULL) {
 		struct characteristic_data *char_data;
 
 		char_data = g_new(struct characteristic_data, 1);
 		char_data->attrib = attrib;
-		char_data->start = opt_start;
-		char_data->end = opt_end;
+		char_data->start = main_opts.start;
+		char_data->end = main_opts.end;
 
-		gatt_read_char_by_uuid(attrib, opt_start, opt_end, opt_uuid,
-						char_read_by_uuid_cb, char_data);
+		gatt_read_char_by_uuid(attrib, main_opts.start, main_opts.end,
+					main_opts.uuid, char_read_by_uuid_cb,
+					char_data);
 
 		return FALSE;
 	}
 
-	if (opt_handle <= 0) {
+	if (main_opts.handle <= 0) {
 		g_printerr("A valid handle is required\n");
 		g_main_loop_quit(event_loop);
 		return FALSE;
 	}
 
-	gatt_read_char(attrib, opt_handle, char_read_cb, attrib);
+	gatt_read_char(attrib, main_opts.handle, char_read_cb, attrib);
 
 	return FALSE;
 }
@@ -411,23 +437,24 @@ static gboolean characteristics_write(gpointer user_data)
 	uint8_t *value;
 	size_t len;
 
-	if (opt_handle <= 0) {
+	if (main_opts.handle <= 0) {
 		g_printerr("A valid handle is required\n");
 		goto error;
 	}
 
-	if (opt_value == NULL || opt_value[0] == '\0') {
+	if (main_opts.value == NULL || main_opts.value[0] == '\0') {
 		g_printerr("A value is required\n");
 		goto error;
 	}
 
-	len = attr_data_from_string(opt_value, &value);
+	len = attr_data_from_string(main_opts.value, &value);
 	if (len == 0) {
 		g_printerr("Invalid value\n");
 		goto error;
 	}
 
-	gatt_write_cmd(attrib, opt_handle, value, len, mainloop_quit, value);
+	gatt_write_cmd(attrib, main_opts.handle, value, len, mainloop_quit,
+									value);
 
 	return FALSE;
 
@@ -474,7 +501,7 @@ static void char_desc_cb(guint8 status, const guint8 *pdu, guint16 plen,
 	att_data_list_free(list);
 
 done:
-	if (opt_listen == FALSE)
+	if (main_opts.listen == FALSE)
 		g_main_loop_quit(event_loop);
 }
 
@@ -482,7 +509,8 @@ static gboolean characteristics_desc(gpointer user_data)
 {
 	GAttrib *attrib = user_data;
 
-	gatt_find_info(attrib, opt_start, opt_end, char_desc_cb, NULL);
+	gatt_find_info(attrib, main_opts.start, main_opts.end,
+							char_desc_cb, NULL);
 
 	return FALSE;
 }
@@ -493,20 +521,20 @@ static gboolean parse_uuid(const char *key, const char *value,
 	if (!value)
 		return FALSE;
 
-	opt_uuid = g_try_malloc(sizeof(uuid_t));
-	if (opt_uuid == NULL)
+	main_opts.uuid = g_try_malloc(sizeof(uuid_t));
+	if (main_opts.uuid == NULL)
 		return FALSE;
 
-	if (bt_string2uuid(opt_uuid, value) < 0)
+	if (bt_string2uuid(main_opts.uuid, value) < 0)
 		return FALSE;
 
 	return TRUE;
 }
 
 static GOptionEntry primary_char_options[] = {
-	{ "start", 's' , 0, G_OPTION_ARG_INT, &opt_start,
+	{ "start", 's' , 0, G_OPTION_ARG_INT, &main_opts.start,
 		"Starting handle(optional)", "0x0001" },
-	{ "end", 'e' , 0, G_OPTION_ARG_INT, &opt_end,
+	{ "end", 'e' , 0, G_OPTION_ARG_INT, &main_opts.end,
 		"Ending handle(optional)", "0xffff" },
 	{ "uuid", 'u', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK,
 		parse_uuid, "UUID16 or UUID128(optional)", "0x1801"},
@@ -514,42 +542,42 @@ static GOptionEntry primary_char_options[] = {
 };
 
 static GOptionEntry char_rw_options[] = {
-	{ "handle", 'a' , 0, G_OPTION_ARG_INT, &opt_handle,
+	{ "handle", 'a' , 0, G_OPTION_ARG_INT, &main_opts.handle,
 		"Read/Write characteristic by handle(required)", "0x0001" },
-	{ "value", 'n' , 0, G_OPTION_ARG_STRING, &opt_value,
+	{ "value", 'n' , 0, G_OPTION_ARG_STRING, &main_opts.value,
 		"Write characteristic value (required for write operation)",
 		"0x0001" },
 	{NULL},
 };
 
 static GOptionEntry gatt_options[] = {
-	{ "primary", 0, 0, G_OPTION_ARG_NONE, &opt_primary,
+	{ "primary", 0, 0, G_OPTION_ARG_NONE, &main_opts.primary,
 		"Primary Service Discovery", NULL },
-	{ "characteristics", 0, 0, G_OPTION_ARG_NONE, &opt_characteristics,
+	{ "characteristics", 0, 0, G_OPTION_ARG_NONE, &main_opts.char_disc,
 		"Characteristics Discovery", NULL },
-	{ "char-read", 0, 0, G_OPTION_ARG_NONE, &opt_char_read,
+	{ "char-read", 0, 0, G_OPTION_ARG_NONE, &main_opts.char_read,
 		"Characteristics Value/Descriptor Read", NULL },
-	{ "char-write", 0, 0, G_OPTION_ARG_NONE, &opt_char_write,
+	{ "char-write", 0, 0, G_OPTION_ARG_NONE, &main_opts.char_write,
 		"Characteristics Value Write", NULL },
-	{ "char-desc", 0, 0, G_OPTION_ARG_NONE, &opt_char_desc,
+	{ "char-desc", 0, 0, G_OPTION_ARG_NONE, &main_opts.char_desc,
 		"Characteristics Descriptor Discovery", NULL },
-	{ "listen", 0, 0, G_OPTION_ARG_NONE, &opt_listen,
+	{ "listen", 0, 0, G_OPTION_ARG_NONE, &main_opts.listen,
 		"Listen for notifications and indications", NULL },
-	{ "le", 0, 0, G_OPTION_ARG_NONE, &opt_le,
+	{ "le", 0, 0, G_OPTION_ARG_NONE, &main_opts.le,
 		"Use Bluetooth Low Energy transport", NULL },
 	{ NULL },
 };
 
 static GOptionEntry options[] = {
-	{ "adapter", 'i', 0, G_OPTION_ARG_STRING, &opt_src,
+	{ "adapter", 'i', 0, G_OPTION_ARG_STRING, &main_opts.src,
 		"Specify local adapter interface", "hciX" },
-	{ "device", 'b', 0, G_OPTION_ARG_STRING, &opt_dst,
+	{ "device", 'b', 0, G_OPTION_ARG_STRING, &main_opts.dst,
 		"Specify remote Bluetooth address", "MAC" },
-	{ "mtu", 'm', 0, G_OPTION_ARG_INT, &opt_mtu,
+	{ "mtu", 'm', 0, G_OPTION_ARG_INT, &main_opts.mtu,
 		"Specify the MTU size", "MTU" },
-	{ "psm", 'p', 0, G_OPTION_ARG_INT, &opt_psm,
+	{ "psm", 'p', 0, G_OPTION_ARG_INT, &main_opts.psm,
 		"Specify the PSM for GATT/ATT over BR/EDR", "PSM" },
-	{ "sec-level", 'l', 0, G_OPTION_ARG_STRING, &opt_sec_level,
+	{ "sec-level", 'l', 0, G_OPTION_ARG_STRING, &main_opts.sec_level,
 		"Set security level. Default: low", "[low | medium | high]"},
 	{ NULL },
 };
@@ -563,6 +591,8 @@ int main(int argc, char *argv[])
 	GIOChannel *chan;
 	GSourceFunc callback;
 
+	options_init();
+
 	context = g_option_context_new(NULL);
 	g_option_context_add_main_entries(context, options, NULL);
 
@@ -594,15 +624,15 @@ int main(int argc, char *argv[])
 		g_error_free(gerr);
 	}
 
-	if (opt_primary)
+	if (main_opts.primary)
 		callback = primary;
-	else if (opt_characteristics)
+	else if (main_opts.char_disc)
 		callback = characteristics;
-	else if (opt_char_read)
+	else if (main_opts.char_read)
 		callback = characteristics_read;
-	else if (opt_char_write)
+	else if (main_opts.char_write)
 		callback = characteristics_write;
-	else if (opt_char_desc)
+	else if (main_opts.char_desc)
 		callback = characteristics_desc;
 	else {
 		gchar *help = g_option_context_get_help(context, TRUE, NULL);
@@ -612,7 +642,7 @@ int main(int argc, char *argv[])
 		goto done;
 	}
 
-	chan = do_connect(opt_le);
+	chan = do_connect(main_opts.le);
 	if (chan == NULL) {
 		got_error = TRUE;
 		goto done;
@@ -622,7 +652,7 @@ int main(int argc, char *argv[])
 
 	event_loop = g_main_loop_new(NULL, FALSE);
 
-	if (opt_listen)
+	if (main_opts.listen)
 		g_idle_add(listen_start, attrib);
 
 	g_idle_add(callback, attrib);
@@ -638,9 +668,9 @@ int main(int argc, char *argv[])
 
 done:
 	g_option_context_free(context);
-	g_free(opt_src);
-	g_free(opt_dst);
-	g_free(opt_uuid);
+	g_free(main_opts.src);
+	g_free(main_opts.dst);
+	g_free(main_opts.uuid);
 
 	if (got_error)
 		exit(EXIT_FAILURE);
-- 
1.7.1


^ permalink raw reply related

* RE: A2DP reconfigure with BMW Carkit (supporting multi streams) timeouts.
From: Höglind, Henrik @ 2011-02-08 14:59 UTC (permalink / raw)
  To: Lukasz Rymanowski, roystonr@codeaurora.org
  Cc: Luiz Augusto von Dentz, Johan Hedberg,
	linux-bluetooth@vger.kernel.org, skrovvid@codeaurora.org,
	rshaffer@codeaurora.org
In-Reply-To: <AANLkTinQ2heJzG_8u_2ZPoqiSy0tGzQCCZO=BZgE7A=Y@mail.gmail.com>

Hi Lukasz, Roystonr, Johan,

>> Have provided the patch to the tester to verify as we don't have the BMW
>> CK available locally. Would update the feedback received.
>
>I'm just wondering, Is it working for you ?

We have been testing this patch and it fixes the problem.

Best regards,
Henrik


^ permalink raw reply

* Re: Status of MAP and AVRCP
From: David Stockwell @ 2011-02-08 14:42 UTC (permalink / raw)
  To: dsaxena, BlueZ devel list
In-Reply-To: <20110207090836.GA26064@plexity.net>

Hello Deepak,


Hi,

I am wondering about the status of AVRCP and MAP profile support
in the current BlueZ tree. It looks like ther were a few GSOC
projects related to adding/extending these last year, but from
my quick skim, it does not look like these were integrated
upstream. Was an attempt made to push these changes and did
they get reject? Is someone still driving this work within the
BlueZ community to make sure it goes upstream?

+++++

I restarted work-in-earnest on an AVRCP layer a bit over two months ago (I 
also have a full-time day-job that has nothing to do with Bluetooth, Linux, 
Open Source, etc.). I am now resolving some issues in connecting from my 
custom built AVRCP remote (hardware and firmware), which connects, pairs, 
and connects with full AVRCP with my BlackBerry Torch, and the AVRCP stack 
on my laptop.  After working through that issue (I expect, by later this 
week), and verifying that the BB Torch can connect with my changes in place, 
I will complete fairly extensive testing and begin submitting patches with 
major surgery to audio/control.c, supporting the API doc worked out in the 
Portland meeting, with a couple of minor extensions.  This will bring BlueZ 
to AVRCP 1.3, figure by the end of this month.

I will also include message fragmentation support, which will be needed for 
1.4 (not really needed for 1.3, although it is in the 1.3 spec).  However, 
there are a number of issues with 1.4, the biggest being the amount of 
integration between the BlueZ stack/profile (which should remain pure) and 
the player(s), that are required to respond to queries for browsing track 
metadata, etc.  I think there will need to be a discussion about how much of 
1.4, if any, to support, and how.  I think Sander van Grieken's work with 
MPRIS may be a guide.  Also, I understand ST Ericsson (Shivendra Agrawal) is 
also proposing to provide 1.4 support.

Just my two cents...questions, please do not hesitate.

David Stockwell

+++++

Thanks,
~Deepak


-- 
"People think all we need to fix our predicament is a free source of
energy, but I think we need to change out behaviour. More energy would
just deplete the Earth's lifeblood faster." - Janine Benyius
--
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 


^ permalink raw reply

* Re: Frequent SM test failure at UPF
From: Vinicius Costa Gomes @ 2011-02-08 13:58 UTC (permalink / raw)
  To: Brian Gix; +Cc: linux-bluetooth
In-Reply-To: <4D509ABA.1010909@codeaurora.org>

Hi Brian,

On 17:22 Mon 07 Feb, Brian Gix wrote:
> On 2/7/2011 4:26 PM, Brian Gix wrote:
> >
> >Testing of Shorter than 16 octet keys.
> >
> >In smp_cmd_pairing_random() when the STK is generated, it needs to be
> >truncated to the MIN of conn->preq[4] and conn->pres[4].
> >
> >This Min value may need to be saved for later as well, because it needs
> >to also limit the LTK key exchange.
> >
> >This failure showed up with the PTS tool, and at least one other device
> >during the days testing. I have mocked up a fix, but have not had a
> >chance to test it yet.
> >
> >

First, thanks for the reports. This particular issue should be fixed soon.

> 
> PTS also did not like that we request No Bonding, but request to
> exchange keys.  I am not sure who is at fault there. At first
> glance, exchanging keys insinuates a bonded relationship, so I don't
> know what it means to request key exchange but not bond.  I think
> both sides need to agree to bond (bit 0x01 in offset 3 (4th octet)
> of the req and res) to remember the exchanged keys, but exchanging
> keys should still be OK for the duration of that session at least.
> They would then be discarded when the connection ended.
> 
> It also may not make sense to request Bonding, but not have keys to
> exchange, because I am not sure if you are really bonded if you have
> no keys exchanged with the remote device.  You could always just
> remember the remote device's BD Addr, I suppose and choose to accept
> or reject no-security connections based on that.
> 
> I am sorry, the above is mostly just me thinking out loud. I don't
> know for sure if any of that is actually correct.
> 

So, I will add something to the thinking out loud session ;-) seems to me that
the tests were written assuming that most of the limitations are in the slave,
when some of them find a limited (for now) SM implementation in the master 
side some things are not so clear.

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

Cheers,
-- 
Vinicius

^ permalink raw reply

* Re: ID_SERIAL for udev bluetooth joystick events
From: Antonio Ospite @ 2011-02-08 11:05 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-bluetooth, linux-input, Alan Ott
In-Reply-To: <20110208074842.GC865@core.coreip.homeip.net>

[-- Attachment #1: Type: text/plain, Size: 1345 bytes --]

On Mon, 7 Feb 2011 23:48:42 -0800
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:

> On Fri, Feb 04, 2011 at 11:34:27PM +0100, Antonio Ospite wrote:
> > Hi,
> > 
> > I have a question about udev events generated by a bluetooth joystick:
> > when the bt joystick generates the joystick event, the ID_SERIAL
> > property matches the one of the bt adapter not the one of the joystick.
> > 
> > For example (using "udevadm monitor --property"), when connecting the
> > Sony Sixaxis via usb I get:
> > ID_SERIAL=Sony_PLAYSTATION_R_3_Controller
> > in the input and joystick events, but when I connect it via bt, I get:
> > ID_SERIAL=Broadcom_Corp_ANYCOM_Blue_USB-200_250
> > which matches my bluetooth adapter.
> > 
[...]

> This should be directed to udev list as composition of ID_SERIAL is
> done exclusively by udev. It looks like it scans parent till it finds
> first USB device (thus skipping all BT-specific data).
> 

Thanks Dmitry, I'll resend this to linux-hotplug.

Is it OK for cases like this to still keep linux-bluetooth and
linux-input in CC?

Regards,
   Antonio

-- 
Antonio Ospite
http://ao2.it

PGP public key ID: 0x4553B001

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply

* Re: ID_SERIAL for udev bluetooth joystick events
From: Dmitry Torokhov @ 2011-02-08  7:48 UTC (permalink / raw)
  To: Antonio Ospite; +Cc: linux-bluetooth, linux-input, Alan Ott
In-Reply-To: <20110204233427.09b32d7e.ospite@studenti.unina.it>

On Fri, Feb 04, 2011 at 11:34:27PM +0100, Antonio Ospite wrote:
> Hi,
> 
> I have a question about udev events generated by a bluetooth joystick:
> when the bt joystick generates the joystick event, the ID_SERIAL
> property matches the one of the bt adapter not the one of the joystick.
> 
> For example (using "udevadm monitor --property"), when connecting the
> Sony Sixaxis via usb I get:
> ID_SERIAL=Sony_PLAYSTATION_R_3_Controller
> in the input and joystick events, but when I connect it via bt, I get:
> ID_SERIAL=Broadcom_Corp_ANYCOM_Blue_USB-200_250
> which matches my bluetooth adapter.
> 
> Is this expected/known, or is it a bug?
> I am using kernel 2.6.37, udev 164
> 
> For the records, I also get ID_BUS=usb when connecting via bt, but I can
> live with that since I can differenciate usb and bt operation using
> ID_USB_DRIVER=usbhid
> versus
> ID_USB_DRIVER=btusb
> 
> Some insight of what I am trying to achieve with udev:
>   1. Monitor new joystick devices.
>   2. If ID_SERIAL != Sony_PLAYSTATION_R_3_Controller, then STOP.
>   3. Get the associated hidraw device node navigating the event tree.
>   4. Set leds using the value from the ID_INPUT_JOYSTICK property.
>   5. If ID_USB_DRIVER=usbhid do the needed pairing.
> 
> And with the current behaviour for ID_SERIAL I cannot enforce 2.
> I could listen for the (hid) event and use HID_NAME which seems to be a
> little more consistent:
> usb -> HID_NAME=Sony PLAYSTATION(R)3 Controller
> bt  -> HID_NAME=PLAYSTATION(R)3 Controller
> and navigate the event hierarchy to get ID_INPUT_JOYSTICK, but that is
> slightly more complicated, and I am curious about the ID_SERIAL
> behavior anyways :)

This should be directed to udev list as composition of ID_SERIAL is
done exclusively by udev. It looks like it scans parent till it finds
first USB device (thus skipping all BT-specific data).

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [BUG] usb problems in .38-rc3+
From: Gadiyar, Anand @ 2011-02-08  6:46 UTC (permalink / raw)
  To: Ed Tomlinson; +Cc: Oliver Neukum, linux-kernel, linux-bluetooth, linux-usb
In-Reply-To: <201102072115.20858.edt@aei.ca>

On Tue, Feb 8, 2011 at 7:45 AM, Ed Tomlinson <edt@aei.ca> wrote:
> I tried bisecting without much luck.  It started with about 4000 commits to check.  It was still bad
> when it reached the first 1000 commits post .37.  Then all boots started crashing.  I think its possible
> to restrict a bisect to a directory - if so, what dir should I try?
>

Maybe drivers/ or drivers/usb would be enough for a first attempt?
I usually start there.

You could just do:

git bisect start -- [path]

to restrict bisection to commits that touch [path].

- Anand

^ permalink raw reply

* Re: [PATCH] linux-firmware: Remove ath3k-2.fw
From: Bala Shanmugam @ 2011-02-08  6:35 UTC (permalink / raw)
  To: Luis Rodriguez; +Cc: David Woodhouse, linux-bluetooth@vger.kernel.org
In-Reply-To: <20110203174622.GA1226@tux>

On 2/3/2011 11:16 PM, Luis Rodriguez wrote:
> On Thu, Feb 03, 2011 at 12:01:37AM -0800, Shanmugamkamatchi Balashanmugam wrote:
>> On 2/3/2011 1:13 PM, David Woodhouse wrote:
>>> On Fri, 2011-01-28 at 15:03 +0530, Bala Shanmugam wrote:
>>>> ath3k-2.fw is obsolete and not use by Atheros chipsets
>>>> anymore.
>>> Are you telling me that there is no extant hardware, and no old kernels,
>>> which would use this? It was added to the linux-firmware tree and
>>> *never* used?
>>>
>> Yes David, no older kernel uses this firmware.
>> We thought to have new firmware file for newer versions but
>> our driver patch was not accepted and we decided to
>> have single firmware for this chipset [ath3k-1.fw].
>>
> To be clear, the patch for upstream to use that firmware was submitted IIRC but
> never merged upstream... you merged the firmware first. By the time it came
> time to push it again, I had asked WTF was in it, and asked for the patch to
> get merged, but it was made clear by our team the APIs never changed so Marcel
> suggested we just replace the firmware in linux-firmware instead of adding a
> new firmware and patching the driver.
>
> Apologies for any trouble.
>
>    Luis
Hi David,

Please upstream this patch.
Let me know if I need to do anything from my side.

Regards,
Bala.

^ permalink raw reply

* pull request: bluetooth-2.6 2011-02-08
From: Gustavo F. Padovan @ 2011-02-08  4:07 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, linux-bluetooth

Hi John,

Two fixes for 2.6.38. Support for firmware download for the Atheros AR9285
device and a fix two prevent multiple connection responses to one connection
request.

Please pull, or tell me any problem. Thanks.

The following changes since commit fc7c976dc7a565213393ce700d4a6105f037bf20:

  mac80211: fix the skb cloned check in the tx path (2011-02-07 16:02:14 -0500)

are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth-2.6.git master

Bao Liang (1):
      Bluetooth: Set conn state to BT_DISCONN to avoid multiple responses

Cho, Yu-Chen (1):
      Bluetooth: add Atheros BT AR9285 fw supported

 drivers/bluetooth/ath3k.c |    2 ++
 drivers/bluetooth/btusb.c |    3 +++
 net/bluetooth/l2cap.c     |    1 +
 3 files changed, 6 insertions(+), 0 deletions(-)

-- 
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply

* Re: [BUG] usb problems in .38-rc3+
From: Ed Tomlinson @ 2011-02-08  2:15 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: linux-kernel, linux-bluetooth, linux-usb
In-Reply-To: <201102071920.22543.edt@aei.ca>

On Monday 07 February 2011 19:20:21 Ed Tomlinson wrote:
> On Monday 07 February 2011 04:09:51 Oliver Neukum wrote:
> > Am Samstag, 5. Februar 2011, 20:17:57 schrieb Ed Tomlinson:
> > > Hi,
> > > 
> > > My bluetooth usb dongle has stopped working in .38-rc3+
> > > 
> > > Bus 002 Device 008: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
> > > 
> > > and in dmesg
> > > 
> > > [108495.369056] usb 5-1: new full speed USB device using ohci_hcd and address 3
> > > [108495.573077] usb 5-1: New USB device found, idVendor=0a12, idProduct=0001
> > > [108495.580099] usb 5-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> > > [108652.971977] usb 5-1: USB disconnect, address 3
> > > [108652.972718] btusb_bulk_complete: hci0 urb ffff8800684e99c0 failed to resubmit (19)
> > > [108652.973725] btusb_bulk_complete: hci0 urb ffff8800684e9c00 failed to resubmit (19)
> > > [108652.974707] btusb_intr_complete: hci0 urb ffff8800684e9840 failed to resubmit (19)
> > > [108653.001690] btusb_send_frame: hci0 urb ffff8800bb42a240 submission failed
> > > [108657.007541] usb 2-4.7: new full speed USB device using ehci_hcd and address 8
> > > [108657.147736] usb 2-4.7: New USB device found, idVendor=0a12, idProduct=0001
> > > [108657.154954] usb 2-4.7: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> > > 
> > > Its been working for years here.
> > > 
> > > Any ideas on what to try or additional info to gather?
> > 
> > Please test what happens if you disable runtime power management.
> 
> After a pointer from Oliver I booted with usbcore.autosuspend=30000 and verified the device used
> the parm via /sys/bus...   Still did not work.  Bisect or are there some other things to try?

I tried bisecting without much luck.  It started with about 4000 commits to check.  It was still bad
when it reached the first 1000 commits post .37.  Then all boots started crashing.  I think its possible
to restrict a bisect to a directory - if so, what dir should I try?

TIA
Ed

^ permalink raw reply

* Re: Frequent SM test failure at UPF
From: Brian Gix @ 2011-02-08  1:22 UTC (permalink / raw)
  To: linux-bluetooth, vinicius.gomes
In-Reply-To: <4D508DC2.60003@codeaurora.org>

On 2/7/2011 4:26 PM, Brian Gix wrote:
>
> Testing of Shorter than 16 octet keys.
>
> In smp_cmd_pairing_random() when the STK is generated, it needs to be
> truncated to the MIN of conn->preq[4] and conn->pres[4].
>
> This Min value may need to be saved for later as well, because it needs
> to also limit the LTK key exchange.
>
> This failure showed up with the PTS tool, and at least one other device
> during the days testing. I have mocked up a fix, but have not had a
> chance to test it yet.
>
>

PTS also did not like that we request No Bonding, but request to 
exchange keys.  I am not sure who is at fault there. At first glance, 
exchanging keys insinuates a bonded relationship, so I don't know what 
it means to request key exchange but not bond.  I think both sides need 
to agree to bond (bit 0x01 in offset 3 (4th octet) of the req and res) 
to remember the exchanged keys, but exchanging keys should still be OK 
for the duration of that session at least.  They would then be discarded 
when the connection ended.

It also may not make sense to request Bonding, but not have keys to 
exchange, because I am not sure if you are really bonded if you have no 
keys exchanged with the remote device.  You could always just remember 
the remote device's BD Addr, I suppose and choose to accept or reject 
no-security connections based on that.

I am sorry, the above is mostly just me thinking out loud. I don't know 
for sure if any of that is actually correct.


-- 
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


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