Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [WORKAROUND BlueZ 1/3] gdbus: Add fallback to GetProperties
From: Marcel Holtmann @ 2012-10-08 13:43 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1349683884-22251-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

> This adds a fallback for GetProperties method when it is not
> implemented.
> ---
> This set of patches are workarounds to old properties interface to be able to
> test new code until other components are ported.

I am not sure I want this at all. This is a nasty hack.

Especially since interfaces that previously had neither or only some of
these methods get these methods. Bad idea. It might work inside BlueZ
where we always added these methods, but in other projects some of these
methods had been left out since the properties where send via signals
with the object path being announced.

Regards

Marcel



^ permalink raw reply

* Re: [PATCH] event: Remove not used btd_event_remote_class
From: Johan Hedberg @ 2012-10-08 13:39 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth, Szymon Janc
In-Reply-To: <1349698288-15112-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Mon, Oct 08, 2012, Szymon Janc wrote:
> This was used in hciops only. With mgmt interface remote CoD is
> received in EIR from Device Found/Connected events.
> 
> ---
>  src/event.c |   22 ----------------------
>  src/event.h |    1 -
>  2 files changed, 23 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* [PATCH v3] audio: Add check for vendor specific A2DP codec
From: chanyeol.park @ 2012-10-08 13:28 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1349688653-20335-1-git-send-email-chanyeol.park@samsung.com>

From: Chan-yeol Park <chanyeol.park@samsung.com>

This patch adds checks(vendor ID, vendor specific codec ID) to make sure of
vendor specific A2DP codec selection.
---
 audio/a2dp-codecs.h |    6 +++++
 audio/a2dp.c        |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/audio/a2dp-codecs.h b/audio/a2dp-codecs.h
index 51c796a..2afafa5 100644
--- a/audio/a2dp-codecs.h
+++ b/audio/a2dp-codecs.h
@@ -26,6 +26,7 @@
 #define A2DP_CODEC_MPEG12		0x01
 #define A2DP_CODEC_MPEG24		0x02
 #define A2DP_CODEC_ATRAC		0x03
+#define A2DP_CODEC_VENDOR		0xFF
 
 #define SBC_SAMPLING_FREQ_16000		(1 << 3)
 #define SBC_SAMPLING_FREQ_32000		(1 << 2)
@@ -114,3 +115,8 @@ typedef struct {
 #else
 #error "Unknown byte order"
 #endif
+
+typedef struct {
+	uint8_t vendor_id[4];
+	uint8_t codec_id[2];
+} __attribute__ ((packed)) a2dp_vendor_codec_t;
diff --git a/audio/a2dp.c b/audio/a2dp.c
index fd1c494..2c9251a 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
@@ -44,6 +44,7 @@
 #include "sink.h"
 #include "source.h"
 #include "a2dp.h"
+#include "a2dp-codecs.h"
 #include "sdpd.h"
 
 /* The duration that streams without users are allowed to stay in
@@ -1427,11 +1428,62 @@ done:
 	finalize_select(setup);
 }
 
+static gboolean vendor_codec_is_matched(uint8_t *remote_cap,
+				size_t remote_cap_len, struct a2dp_sep *sep)
+{
+	uint8_t *capabilities;
+	size_t	length;
+
+	a2dp_vendor_codec_t *local_codec;
+	a2dp_vendor_codec_t *remote_codec;
+
+	if (remote_cap_len < sizeof(a2dp_vendor_codec_t))
+		return FALSE;
+
+	remote_codec = (a2dp_vendor_codec_t *) remote_cap;
+
+	DBG("Remote vendor 0x%02x%02x%02x%02x codec 0x%02x%02x",
+			remote_codec->vendor_id[0], remote_codec->vendor_id[1],
+			remote_codec->vendor_id[2], remote_codec->vendor_id[3],
+			remote_codec->codec_id[0], remote_codec->codec_id[1]);
+
+	if (sep->endpoint == NULL)
+		return FALSE;
+
+	length = sep->endpoint->get_capabilities(sep,
+				&capabilities, sep->user_data);
+
+	if (length < sizeof(a2dp_vendor_codec_t))
+		return FALSE;
+
+	local_codec = (a2dp_vendor_codec_t *) capabilities;
+
+	DBG("Registered vendor 0x%02x%02x%02x%02x codec 0x%02x%02x",
+			local_codec->vendor_id[0], local_codec->vendor_id[1],
+			local_codec->vendor_id[2], local_codec->vendor_id[3],
+			local_codec->codec_id[0], local_codec->codec_id[1]);
+
+	if (memcmp(remote_codec->vendor_id, local_codec->vendor_id,
+					sizeof(local_codec->vendor_id)))
+		return FALSE;
+
+	if (memcmp(remote_codec->codec_id, local_codec->codec_id,
+					sizeof(local_codec->codec_id)))
+		return FALSE;
+
+	DBG("Vendor Codec info is matched");
+
+	return TRUE;
+}
+
 static struct a2dp_sep *a2dp_find_sep(struct avdtp *session, GSList *list,
 					const char *sender)
 {
 	for (; list; list = list->next) {
 		struct a2dp_sep *sep = list->data;
+		struct avdtp_remote_sep *rsep;
+		struct avdtp_media_codec_capability *rsep_codec;
+		struct avdtp_service_capability *service;
 
 		/* Use sender's endpoint if available */
 		if (sender) {
@@ -1445,7 +1497,17 @@ static struct a2dp_sep *a2dp_find_sep(struct avdtp *session, GSList *list,
 				continue;
 		}
 
-		if (avdtp_find_remote_sep(session, sep->lsep) == NULL)
+		rsep = avdtp_find_remote_sep(session, sep->lsep);
+		if (rsep == NULL)
+			continue;
+
+		service = avdtp_get_codec(rsep);
+		rsep_codec = (struct avdtp_media_codec_capability *)
+								service->data;
+
+		if (rsep_codec->media_codec_type == A2DP_CODEC_VENDOR &&
+			!vendor_codec_is_matched(rsep_codec->data,
+				service->length - sizeof(*rsep_codec), sep))
 			continue;
 
 		return sep;
-- 
1.7.9.5


^ permalink raw reply related

* Re: [PATCH obexd] client: Fix pbap_select using absolute path with known locations
From: Luiz Augusto von Dentz @ 2012-10-08 12:47 UTC (permalink / raw)
  To: Ludek Finstrle; +Cc: linux-bluetooth
In-Reply-To: <CABBYNZ+-a5csWYzZ4YdH1G9ZCrp1KUHB9ayNQYC5=8ks+SzEvQ@mail.gmail.com>

Hi Ludek,

On Fri, Aug 10, 2012 at 1:28 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Ludek,
>
> On Thu, Aug 9, 2012 at 7:07 PM, Ludek Finstrle <luf@pzkagis.cz> wrote:
>> pbap_select has to use absolute path with known location to support
>> repeatable pbap_select calls. In other way the second call fails.
>> ---
>>  client/pbap.c |    4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/client/pbap.c b/client/pbap.c
>> index 48dbac1..d8c39e5 100644
>> --- a/client/pbap.c
>> +++ b/client/pbap.c
>> @@ -232,14 +232,14 @@ static gchar *build_phonebook_path(const char *location, const char *item)
>>
>>         if (!g_ascii_strcasecmp(location, "INT") ||
>>                         !g_ascii_strcasecmp(location, "INTERNAL"))
>> -               path = g_strdup("telecom");
>> +               path = g_strdup("/telecom");
>>         else if (!g_ascii_strncasecmp(location, "SIM", 3)) {
>>                 if (strlen(location) == 3)
>>                         tmp = g_strdup("SIM1");
>>                 else
>>                         tmp = g_ascii_strup(location, 4);
>>
>> -               path = g_build_filename(tmp, "telecom", NULL);
>> +               path = g_build_filename("/", tmp, "telecom", NULL);
>>                 g_free(tmp);
>>         } else
>>                 return NULL;
>> --
>> 1.7.1
>>
>
> Applied, thanks.

This doesn't a regression with some phones e.g. iphone5, the problem
is not really the path as this is handled by obc_session_setpath, but
we should not use absolute in the name as in pull_phonebook.

-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH] Bluetooth: L2CAP: Fix using default Flush Timeout for EFS
From: Gustavo Padovan @ 2012-10-08 12:41 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1349684082-12928-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

* Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-10-08 11:14:41 +0300]:

> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> There are two Flush Timeouts: one is old Flush Timeot Option
> which is 2 octets and the second is Flush Timeout inside EFS
> which is 4 octets long.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  include/net/bluetooth/l2cap.h |    3 ++-
>  net/bluetooth/l2cap_core.c    |    6 +++---
>  2 files changed, 5 insertions(+), 4 deletions(-)

Applied, thanks.

	Gustavo

^ permalink raw reply

* Re: [PATCH v3] Cycling Speed and Cadence profile (CSCP) API
From: Andrzej Kaczmarek @ 2012-10-08 12:41 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <20121005174348.GA8074@x220>

Hi Johan,

On 10/05/2012 07:43 PM, Johan Hedberg wrote:
> Hi Andrzej,
>
> On Mon, Oct 01, 2012, Andrzej Kaczmarek wrote:
>> ---
>>   doc/cycling-api.txt | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 118 insertions(+)
>>   create mode 100644 doc/cycling-api.txt
>
> Applied. Thanks.
>
> Do you already have some corresponding code too?

I'm working on it. Will send patches once it's completed and tested.

BR,
Andrzej


^ permalink raw reply

* [PATCH] event: Remove not used btd_event_remote_class
From: Szymon Janc @ 2012-10-08 12:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

From: Szymon Janc <szymon@janc.net.pl>

This was used in hciops only. With mgmt interface remote CoD is
received in EIR from Device Found/Connected events.

---
 src/event.c |   22 ----------------------
 src/event.h |    1 -
 2 files changed, 23 deletions(-)

diff --git a/src/event.c b/src/event.c
index 84c7f88..0ebab19 100644
--- a/src/event.c
+++ b/src/event.c
@@ -280,28 +280,6 @@ void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer,
 		dev->legacy = legacy;
 }
 
-void btd_event_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class)
-{
-	struct btd_adapter *adapter;
-	struct btd_device *device;
-	uint32_t old_class = 0;
-
-	read_remote_class(local, peer, &old_class);
-
-	if (old_class == class)
-		return;
-
-	write_remote_class(local, peer, class);
-
-	if (!get_adapter_and_device(local, peer, &adapter, &device, FALSE))
-		return;
-
-	if (!device)
-		return;
-
-	device_set_class(device, class);
-}
-
 void btd_event_remote_name(bdaddr_t *local, bdaddr_t *peer, char *name)
 {
 	struct btd_adapter *adapter;
diff --git a/src/event.h b/src/event.h
index 6d001dd..6adf1f5 100644
--- a/src/event.h
+++ b/src/event.h
@@ -27,7 +27,6 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type
 					int8_t rssi, uint8_t confirm_name,
 					uint8_t *data, uint8_t data_len);
 void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer, gboolean legacy);
-void btd_event_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class);
 void btd_event_remote_name(bdaddr_t *local, bdaddr_t *peer, char *name);
 void btd_event_conn_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
 						char *name, uint32_t class);
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v2 2/2] audio: Remove redundant procedure when a2dp connect
From: chanyeol.park @ 2012-10-08  9:30 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1349688653-20335-1-git-send-email-chanyeol.park@samsung.com>

From: Chan-yeol Park <chanyeol.park@samsung.com>

This patch fixes the bug that when remote host is down a2dp connection failure
is handled like XCASE
---
 audio/avdtp.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/audio/avdtp.c b/audio/avdtp.c
index d905db3..ae1ab7b 100644
--- a/audio/avdtp.c
+++ b/audio/avdtp.c
@@ -2411,9 +2411,10 @@ static void avdtp_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 {
 	struct avdtp *session = user_data;
 	char address[18];
-	GError *gerr = NULL;
+	int err_no = EIO;
 
 	if (err) {
+		err_no = err->code;
 		error("%s", err->message);
 		goto failed;
 	}
@@ -2421,13 +2422,13 @@ static void avdtp_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	if (!session->io)
 		session->io = g_io_channel_ref(chan);
 
-	bt_io_get(chan, &gerr,
+	bt_io_get(chan, &err,
 			BT_IO_OPT_OMTU, &session->omtu,
 			BT_IO_OPT_IMTU, &session->imtu,
 			BT_IO_OPT_INVALID);
-	if (gerr) {
-		error("%s", gerr->message);
-		g_error_free(gerr);
+	if (err) {
+		err_no = err->code;
+		error("%s", err->message);
 		goto failed;
 	}
 
@@ -2481,7 +2482,7 @@ failed:
 			avdtp_sep_set_state(session, stream->lsep,
 						AVDTP_STATE_IDLE);
 	} else
-		connection_lost(session, EIO);
+		connection_lost(session, err_no);
 }
 
 static void auth_cb(DBusError *derr, void *user_data)
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v2 1/2] audio: Add check for vendor specific A2DP codec
From: chanyeol.park @ 2012-10-08  9:30 UTC (permalink / raw)
  To: linux-bluetooth

From: Chan-yeol Park <chanyeol.park@samsung.com>

This patch adds checks(vendor ID, vendor specific codec ID) to make sure of
vendor specific A2DP codec selection.
---
 audio/a2dp-codecs.h |    6 +++++
 audio/a2dp.c        |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/audio/a2dp-codecs.h b/audio/a2dp-codecs.h
index 51c796a..42ae2e1 100644
--- a/audio/a2dp-codecs.h
+++ b/audio/a2dp-codecs.h
@@ -26,6 +26,7 @@
 #define A2DP_CODEC_MPEG12		0x01
 #define A2DP_CODEC_MPEG24		0x02
 #define A2DP_CODEC_ATRAC		0x03
+#define A2DP_CODEC_VENDOR		0xFF
 
 #define SBC_SAMPLING_FREQ_16000		(1 << 3)
 #define SBC_SAMPLING_FREQ_32000		(1 << 2)
@@ -114,3 +115,8 @@ typedef struct {
 #else
 #error "Unknown byte order"
 #endif
+
+typedef struct {
+	uint8_t vendor_id[4];
+	uint8_t codec_id[2];
+} __attribute__ ((packed)) non_a2dp_vendor_codec_t;
diff --git a/audio/a2dp.c b/audio/a2dp.c
index fd1c494..8b3c0f9 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
@@ -44,6 +44,7 @@
 #include "sink.h"
 #include "source.h"
 #include "a2dp.h"
+#include "a2dp-codecs.h"
 #include "sdpd.h"
 
 /* The duration that streams without users are allowed to stay in
@@ -1427,11 +1428,62 @@ done:
 	finalize_select(setup);
 }
 
+static gboolean vendor_codec_is_matched(uint8_t *remote_cap,
+				size_t remote_cap_len, struct a2dp_sep *sep)
+{
+	uint8_t *capabilities;
+	size_t	length;
+
+	non_a2dp_vendor_codec_t *local_codec;
+	non_a2dp_vendor_codec_t *remote_codec;
+
+	if (remote_cap_len < sizeof(non_a2dp_vendor_codec_t))
+		return FALSE;
+
+	remote_codec = (non_a2dp_vendor_codec_t *) remote_cap;
+
+	DBG("Remote vendor 0x%02x%02x%02x%02x codec 0x%02x%02x",
+			remote_codec->vendor_id[0], remote_codec->vendor_id[1],
+			remote_codec->vendor_id[2], remote_codec->vendor_id[3],
+			remote_codec->codec_id[0], remote_codec->codec_id[1]);
+
+	if (sep->endpoint == NULL)
+		return FALSE;
+
+	length = sep->endpoint->get_capabilities(sep,
+				&capabilities, sep->user_data);
+
+	if (length < sizeof(non_a2dp_vendor_codec_t))
+		return FALSE;
+
+	local_codec = (non_a2dp_vendor_codec_t *) capabilities;
+
+	DBG("Registered vendor 0x%02x%02x%02x%02x codec 0x%02x%02x",
+			local_codec->vendor_id[0], local_codec->vendor_id[1],
+			local_codec->vendor_id[2], local_codec->vendor_id[3],
+			local_codec->codec_id[0], local_codec->codec_id[1]);
+
+	if (memcmp(remote_codec->vendor_id, local_codec->vendor_id,
+					sizeof(local_codec->vendor_id)))
+		return FALSE;
+
+	if (memcmp(remote_codec->codec_id, local_codec->codec_id,
+					sizeof(local_codec->codec_id)))
+		return FALSE;
+
+	DBG("Vendor Codec info is matched");
+
+	return TRUE;
+}
+
 static struct a2dp_sep *a2dp_find_sep(struct avdtp *session, GSList *list,
 					const char *sender)
 {
 	for (; list; list = list->next) {
 		struct a2dp_sep *sep = list->data;
+		struct avdtp_remote_sep *rsep;
+		struct avdtp_media_codec_capability *rsep_codec;
+		struct avdtp_service_capability *service;
 
 		/* Use sender's endpoint if available */
 		if (sender) {
@@ -1445,7 +1497,17 @@ static struct a2dp_sep *a2dp_find_sep(struct avdtp *session, GSList *list,
 				continue;
 		}
 
-		if (avdtp_find_remote_sep(session, sep->lsep) == NULL)
+		rsep = avdtp_find_remote_sep(session, sep->lsep);
+		if (rsep == NULL)
+			continue;
+
+		service = avdtp_get_codec(rsep);
+		rsep_codec = (struct avdtp_media_codec_capability *)
+								service->data;
+
+		if (rsep_codec->media_codec_type == A2DP_CODEC_VENDOR &&
+			!vendor_codec_is_matched(rsep_codec->data,
+				service->length - sizeof(*rsep_codec), sep))
 			continue;
 
 		return sep;
-- 
1.7.9.5


^ permalink raw reply related

* Re: Unreliable communication with multiple bluetooth devices and some delay
From: Andrei Emeltchenko @ 2012-10-08  9:15 UTC (permalink / raw)
  To: Sietse Achterop; +Cc: linux-bluetooth
In-Reply-To: <507298AA.2020704@rug.nl>

On Mon, Oct 08, 2012 at 11:11:06AM +0200, Sietse Achterop wrote:
> On 02-10-12 15:37, Sietse Achterop wrote:
> 
> > I have 7 bluetooth devices (epucks, educational robots:  http://www.e-puck.org/).
> > They use the lmx9838 device for bluetooth and are seen as rfcomm-devices on linux.
> > The lmx-device is used in transparent mode.
> > This is on various linuxes, with kernels 2.6.32, 3.0.0 and 3.2, e.g. as in the latest ubuntu 12.04.1.
> > 
> > The test program is a simple loop that continuously sends each epuck a small message,
> > a string of say 6 characters.
> > I use stdio's fprintf to send chars to the /dev/rfcomm devices.
> > In pseudo code:
> >   open_devices();
> >   while true do
> >     for i = 1 to 7 do
> >        fprintf(fp[i], "l,1,2\n");
> >     od
> >     delay( 0.5 seconds);
> >   od
> > 
> > This works perfectly if the delay statement is REMOVED.
> > Then each 2 milliseconds a message is send to the next epuck.
> > But if the delay is ADDED again it gets very UNRELIABLE.
> > After 1 to 30 seconds a communication is failing and after a
> > 20 second delay the connection of a epuck is dropped.
> > After a longer time all connections are dropped.
> 
>    Dear list,
> 
> to react on my on question, I just installed kernel 3.6.1, but the problem does
> not go away:(.
> It is random which of the epuck fails.
> I would be grateful with some pointer. Could it be hardware in one of the BT devices?
> I used a number of different dongles on the linux site. If it is a hardware problem,
> it must be a structural problem in the hardware.
> If it is no hardware problem, it has to be software on the linux site, because the lmx9838 is
> used in transparent mode and the software is not much more than an echo and is software that
> has been working for more than a year.
> Am I using bluetooth in an unusual way?

Get capture with hcidump like "hcidump -tX -i hciX". It will tell you why
connection is closed. Also dmesg might give some warnings.

Best regards 
Andrei Emeltchenko 


^ permalink raw reply

* Re: L2CAP Flush_Timeout  Error
From: Andrei Emeltchenko @ 2012-10-08  9:11 UTC (permalink / raw)
  To: Ajay; +Cc: linux-bluetooth
In-Reply-To: <506B3010.6060606@globaledgesoft.com>

On Tue, Oct 02, 2012 at 11:48:56PM +0530, Ajay wrote:
> Hi,
>     Im currently working in an A2DP stuff, where i noticed an error.
> Here i wanted to monitor the flushed packets due to timeout.
> 
>  I used the  l2test code for my testing purpose
> 
>               On client side   "l2test  -R  -S <bdadddr> "
>               and i set the flush timeout as 100 (opts.flush_to = 100)
> 
>        But  later  when i print the getsockopt value of flush_to, it
> was showing some default value (65532)  harcoded at kernel side.

Try the patch in this thread.

Best regards 
Andrei Emeltchenko 


^ permalink raw reply

* Re: Unreliable communication with multiple bluetooth devices and some delay
From: Sietse Achterop @ 2012-10-08  9:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <506AEDFC.9060300@rug.nl>

On 02-10-12 15:37, Sietse Achterop wrote:

> I have 7 bluetooth devices (epucks, educational robots:  http://www.e-puck.org/).
> They use the lmx9838 device for bluetooth and are seen as rfcomm-devices on linux.
> The lmx-device is used in transparent mode.
> This is on various linuxes, with kernels 2.6.32, 3.0.0 and 3.2, e.g. as in the latest ubuntu 12.04.1.
> 
> The test program is a simple loop that continuously sends each epuck a small message,
> a string of say 6 characters.
> I use stdio's fprintf to send chars to the /dev/rfcomm devices.
> In pseudo code:
>   open_devices();
>   while true do
>     for i = 1 to 7 do
>        fprintf(fp[i], "l,1,2\n");
>     od
>     delay( 0.5 seconds);
>   od
> 
> This works perfectly if the delay statement is REMOVED.
> Then each 2 milliseconds a message is send to the next epuck.
> But if the delay is ADDED again it gets very UNRELIABLE.
> After 1 to 30 seconds a communication is failing and after a
> 20 second delay the connection of a epuck is dropped.
> After a longer time all connections are dropped.

   Dear list,

to react on my on question, I just installed kernel 3.6.1, but the problem does
not go away:(.
It is random which of the epuck fails.
I would be grateful with some pointer. Could it be hardware in one of the BT devices?
I used a number of different dongles on the linux site. If it is a hardware problem,
it must be a structural problem in the hardware.
If it is no hardware problem, it has to be software on the linux site, because the lmx9838 is
used in transparent mode and the software is not much more than an echo and is software that
has been working for more than a year.
Am I using bluetooth in an unusual way?

  Regards,
    Sietse


^ permalink raw reply

* [PATCH] Bluetooth: Allow to set flush timeout
From: Andrei Emeltchenko @ 2012-10-08  9:09 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <506B3010.6060606@globaledgesoft.com>

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


Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/l2cap_sock.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 0c05d7d..70578d8 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -536,6 +536,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
 		chan->fcs  = opts.fcs;
 		chan->max_tx = opts.max_tx;
 		chan->tx_win = opts.txwin_size;
+		chan->flush_to = opts.flush_to;
 		break;
 
 	case L2CAP_LM:
-- 
1.7.9.5


^ permalink raw reply related

* Re: Bluetooth3.0: No HS Speed
From: Andrei Emeltchenko @ 2012-10-08  8:41 UTC (permalink / raw)
  To: Steffen Becker; +Cc: linux-bluetooth
In-Reply-To: <d38b6bd21b40254327824c73f662a4fd@localhost>

Hi Steffen,

On Mon, Oct 08, 2012 at 10:22:11AM +0200, Steffen Becker wrote:
> Hello,
> When I send datafiles (.mp3, .wav or .avi ; size >10 MB) then it is
> transfered only with Bluetooth-speed (~2MBit/s), and not with
> "Highspeed". I have two Bluetooth 3.0+HS Dongles and also the
> integrated wlan-chip is recognized: "ifconfig displays a
> wlan-adapter; and I don't have any wlan-card or -dongle in my PC, so
> I think this displayed wlan-adapter is the one from the
> Bluetooth-dongle.
> 
> I have a Windows PC with two virtual machines in it: Two Ubuntu12.04
> systems. I inserted the two Bluetooth 3.0+HS dongles in my Windows
> PC and created an USB-filter for each dongle to one Ubuntu system.
> So as I said before, datatransfer via Bluetooth between these two
> virtual Ubuntu systems works fine and also the wlan-adapter is
> displayed under ifconfig - but I only have bluetooth-speed =(

First you need High Speed support in the dongle. When you insert dongle
you should see 2 HCI devices: BREDR and HCI_AMP - which is High Speed
controller. Second you have to wait till we merge our patches upstream and
add High Speed support maybe later this year...

Best regards 
Andrei Emeltchenko 


^ permalink raw reply

* Bluetooth3.0: No HS Speed
From: Steffen Becker @ 2012-10-08  8:22 UTC (permalink / raw)
  To: linux-bluetooth

Hello,
When I send datafiles (.mp3, .wav or .avi ; size >10 MB) then it is 
transfered only with Bluetooth-speed (~2MBit/s), and not with 
"Highspeed". I have two Bluetooth 3.0+HS Dongles and also the 
integrated wlan-chip is recognized: "ifconfig displays a wlan-adapter; 
and I don't have any wlan-card or -dongle in my PC, so I think this 
displayed wlan-adapter is the one from the Bluetooth-dongle.

I have a Windows PC with two virtual machines in it: Two Ubuntu12.04 
systems. I inserted the two Bluetooth 3.0+HS dongles in my Windows PC 
and created an USB-filter for each dongle to one Ubuntu system. So as I 
said before, datatransfer via Bluetooth between these two virtual 
Ubuntu systems works fine and also the wlan-adapter is displayed under 
ifconfig - but I only have bluetooth-speed =(

What's the problem?

Regards,
Steffen


^ permalink raw reply

* [PATCH] Bluetooth: L2CAP: Fix using default Flush Timeout for EFS
From: Andrei Emeltchenko @ 2012-10-08  8:14 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <20121007214800.GB13325@joana>

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

There are two Flush Timeouts: one is old Flush Timeot Option
which is 2 octets and the second is Flush Timeout inside EFS
which is 4 octets long.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 include/net/bluetooth/l2cap.h |    3 ++-
 net/bluetooth/l2cap_core.c    |    6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 7002f0d..caab98c 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -32,7 +32,8 @@
 /* L2CAP defaults */
 #define L2CAP_DEFAULT_MTU		672
 #define L2CAP_DEFAULT_MIN_MTU		48
-#define L2CAP_DEFAULT_FLUSH_TO		0xffff
+#define L2CAP_DEFAULT_FLUSH_TO		0xFFFF
+#define L2CAP_EFS_DEFAULT_FLUSH_TO	0xFFFFFFFF
 #define L2CAP_DEFAULT_TX_WINDOW		63
 #define L2CAP_DEFAULT_EXT_WINDOW	0x3FFF
 #define L2CAP_DEFAULT_MAX_TX		3
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d605bbf..d42cdb1 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -504,7 +504,7 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
 	chan->local_msdu	= L2CAP_DEFAULT_MAX_SDU_SIZE;
 	chan->local_sdu_itime	= L2CAP_DEFAULT_SDU_ITIME;
 	chan->local_acc_lat	= L2CAP_DEFAULT_ACC_LAT;
-	chan->local_flush_to	= L2CAP_DEFAULT_FLUSH_TO;
+	chan->local_flush_to	= L2CAP_EFS_DEFAULT_FLUSH_TO;
 
 	l2cap_chan_hold(chan);
 
@@ -2727,7 +2727,7 @@ static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan)
 		efs.msdu	= cpu_to_le16(chan->local_msdu);
 		efs.sdu_itime	= cpu_to_le32(chan->local_sdu_itime);
 		efs.acc_lat	= __constant_cpu_to_le32(L2CAP_DEFAULT_ACC_LAT);
-		efs.flush_to	= __constant_cpu_to_le32(L2CAP_DEFAULT_FLUSH_TO);
+		efs.flush_to	= __constant_cpu_to_le32(L2CAP_EFS_DEFAULT_FLUSH_TO);
 		break;
 
 	case L2CAP_MODE_STREAMING:
@@ -2744,7 +2744,7 @@ static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan)
 	}
 
 	l2cap_add_conf_opt(ptr, L2CAP_CONF_EFS, sizeof(efs),
-							(unsigned long) &efs);
+			   (unsigned long) &efs);
 }
 
 static void l2cap_ack_timeout(struct work_struct *work)
-- 
1.7.9.5


^ permalink raw reply related

* [WORKAROUND BlueZ 3/3] gdbus: Add fallback to PropertyChanged
From: Luiz Augusto von Dentz @ 2012-10-08  8:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1349683884-22251-1-git-send-email-luiz.dentz@gmail.com>

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

This adds a fallback for PropertyChanged signal when it is not implemented.
---
 gdbus/object.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/gdbus/object.c b/gdbus/object.c
index 8f6cbed..609378c 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1587,6 +1587,41 @@ gboolean g_dbus_emit_signal_valist(DBusConnection *connection,
 							name, type, args);
 }
 
+static void fallback_property_changed(struct generic_data *data,
+						struct interface_data *iface,
+						GDBusPropertyTable *p)
+{
+	DBusMessage *signal;
+	DBusMessageIter iter, value;
+	const GDBusSignalTable *s;
+
+	for (s = iface->signals; s && s->name; s++) {
+		/* Skip if PropertyChanged is present in the signals */
+		if (g_str_equal(s->name, "PropertyChanged") == 0)
+			return;
+	}
+
+	signal = dbus_message_new_signal(data->path, iface->name,
+							"PropertyChanged");
+	if (signal == NULL) {
+		error("Unable to allocate new %s.PropertyChanged signal",
+								iface->name);
+		return;
+	}
+
+	dbus_message_iter_init_append(signal, &iter);
+
+	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &p->name);
+	dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, p->type,
+								&value);
+
+	p->get(p, &value, iface->user_data);
+
+	dbus_message_iter_close_container(&iter, &value);
+
+	g_dbus_send_message(data->conn, signal);
+}
+
 static void process_properties_from_interface(struct generic_data *data,
 						struct interface_data *iface)
 {
@@ -1624,6 +1659,8 @@ static void process_properties_from_interface(struct generic_data *data,
 			continue;
 
 		append_property(iface, p, &dict);
+
+		fallback_property_changed(data, iface, p);
 	}
 
 	dbus_message_iter_close_container(&iter, &dict);
-- 
1.7.11.4


^ permalink raw reply related

* [WORKAROUND BlueZ 2/3] gdbus: Add fallback to SetProperty
From: Luiz Augusto von Dentz @ 2012-10-08  8:11 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1349683884-22251-1-git-send-email-luiz.dentz@gmail.com>

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

This adds a fallback for SetProperty method when it is not implemented.
---
 gdbus/object.c | 94 +++++++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 67 insertions(+), 27 deletions(-)

diff --git a/gdbus/object.c b/gdbus/object.c
index e7a4cc3..8f6cbed 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -827,15 +827,47 @@ static DBusMessage *properties_get_all(DBusConnection *connection,
 	return reply;
 }
 
+static DBusMessage *property_set(struct interface_data *iface,
+				DBusMessage *message, const char *name,
+				DBusMessageIter *iter)
+{
+	const GDBusPropertyTable *property;
+	struct property_data *propdata;
+
+	property = find_property(iface->properties, name);
+	if (property == NULL)
+		return g_dbus_create_error(message,
+						DBUS_ERROR_UNKNOWN_PROPERTY,
+						"No such property '%s'", name);
+
+	if (property->set == NULL)
+		return g_dbus_create_error(message,
+					DBUS_ERROR_PROPERTY_READ_ONLY,
+					"Property '%s' is not writable", name);
+
+	if (property->exists != NULL &&
+			!property->exists(property, iface->user_data))
+		return g_dbus_create_error(message,
+						DBUS_ERROR_UNKNOWN_PROPERTY,
+						"No such property '%s'", name);
+
+	propdata = g_new(struct property_data, 1);
+	propdata->id = next_pending_property++;
+	propdata->message = dbus_message_ref(message);
+	pending_property_set = g_slist_prepend(pending_property_set, propdata);
+
+	property->set(property, iter, propdata->id, iface->user_data);
+
+	return NULL;
+}
+
 static DBusMessage *properties_set(DBusConnection *connection,
 					DBusMessage *message, void *user_data)
 {
 	struct generic_data *data = user_data;
 	DBusMessageIter iter, sub;
 	struct interface_data *iface;
-	const GDBusPropertyTable *property;
 	const char *name, *interface;
-	struct property_data *propdata;
 
 	if (!dbus_message_iter_init(message, &iter))
 		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
@@ -869,31 +901,7 @@ static DBusMessage *properties_set(DBusConnection *connection,
 		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
 					"No such interface '%s'", interface);
 
-	property = find_property(iface->properties, name);
-	if (property == NULL)
-		return g_dbus_create_error(message,
-						DBUS_ERROR_UNKNOWN_PROPERTY,
-						"No such property '%s'", name);
-
-	if (property->set == NULL)
-		return g_dbus_create_error(message,
-					DBUS_ERROR_PROPERTY_READ_ONLY,
-					"Property '%s' is not writable", name);
-
-	if (property->exists != NULL &&
-			!property->exists(property, iface->user_data))
-		return g_dbus_create_error(message,
-						DBUS_ERROR_UNKNOWN_PROPERTY,
-						"No such property '%s'", name);
-
-	propdata = g_new(struct property_data, 1);
-	propdata->id = next_pending_property++;
-	propdata->message = dbus_message_ref(message);
-	pending_property_set = g_slist_prepend(pending_property_set, propdata);
-
-	property->set(property, &sub, propdata->id, iface->user_data);
-
-	return NULL;
+	return property_set(iface, message, name, &sub);
 }
 
 static const GDBusMethodTable properties_methods[] = {
@@ -1022,10 +1030,42 @@ static DBusMessage *get_properties(DBusConnection *connection,
 	return reply;
 }
 
+static DBusMessage *set_property(DBusConnection *connection,
+					DBusMessage *message, void *user_data)
+{
+	struct interface_data *iface = user_data;
+	DBusMessageIter iter, sub;
+	const char *name;
+
+	if (!dbus_message_iter_init(message, &iter))
+		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
+							"No arguments given");
+
+	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
+					"Invalid argument type: '%c'",
+					dbus_message_iter_get_arg_type(&iter));
+
+	dbus_message_iter_get_basic(&iter, &name);
+	dbus_message_iter_next(&iter);
+
+	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
+		return g_dbus_create_error(message, DBUS_ERROR_INVALID_ARGS,
+					"Invalid argument type: '%c'",
+					dbus_message_iter_get_arg_type(&iter));
+
+	dbus_message_iter_recurse(&iter, &sub);
+
+	return property_set(iface, message, name, &sub);
+}
+
 static const GDBusMethodTable fallback_methods[] = {
 	{ GDBUS_METHOD("GetProperties",
 			NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
 			get_properties) },
+	{ GDBUS_ASYNC_METHOD("SetProperty",
+			GDBUS_ARGS({ "name", "s" }, { "value", "v" }), NULL,
+			set_property) },
 	{ }
 };
 
-- 
1.7.11.4


^ permalink raw reply related

* [WORKAROUND BlueZ 1/3] gdbus: Add fallback to GetProperties
From: Luiz Augusto von Dentz @ 2012-10-08  8:11 UTC (permalink / raw)
  To: linux-bluetooth

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

This adds a fallback for GetProperties method when it is not
implemented.
---
This set of patches are workarounds to old properties interface to be able to
test new code until other components are ported.

 gdbus/object.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/gdbus/object.c b/gdbus/object.c
index 66431de..e7a4cc3 100644
--- a/gdbus/object.c
+++ b/gdbus/object.c
@@ -1004,6 +1004,31 @@ static void generic_unregister(DBusConnection *connection, void *user_data)
 	g_free(data);
 }
 
+static DBusMessage *get_properties(DBusConnection *connection,
+					DBusMessage *message, void *user_data)
+{
+	struct interface_data *iface = user_data;
+	DBusMessageIter iter;
+	DBusMessage *reply;
+
+	reply = dbus_message_new_method_return(message);
+	if (reply == NULL)
+		return NULL;
+
+	dbus_message_iter_init_append(reply, &iter);
+
+	append_properties(iface, &iter);
+
+	return reply;
+}
+
+static const GDBusMethodTable fallback_methods[] = {
+	{ GDBUS_METHOD("GetProperties",
+			NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
+			get_properties) },
+	{ }
+};
+
 static DBusHandlerResult generic_message(DBusConnection *connection,
 					DBusMessage *message, void *user_data)
 {
@@ -1036,6 +1061,23 @@ static DBusHandlerResult generic_message(DBusConnection *connection,
 							iface->user_data);
 	}
 
+	for (method = fallback_methods; method &&
+			method->name && method->function; method++) {
+		if (dbus_message_is_method_call(message, iface->name,
+							method->name) == FALSE)
+			continue;
+
+		if (g_dbus_args_have_signature(method->in_args,
+							message) == FALSE)
+			continue;
+
+		if (check_privilege(connection, message, method,
+							iface) == TRUE)
+			return DBUS_HANDLER_RESULT_HANDLED;
+
+		return process_message(connection, message, method, iface);
+	}
+
 	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
-- 
1.7.11.4


^ permalink raw reply related

* Re: [PATCH 4/8] Bluetooth: Add chan->ops->defer()
From: Andrei Emeltchenko @ 2012-10-08  7:56 UTC (permalink / raw)
  To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
In-Reply-To: <1349651981-6251-4-git-send-email-gustavo@padovan.org>

Hi Gustavo,

On Mon, Oct 08, 2012 at 07:19:37AM +0800, Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> 
> When DEFER_SETUP is set defer() will trigger an authorization
> request to the userspace.
> 
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
>  include/net/bluetooth/l2cap.h |  1 +
>  net/bluetooth/l2cap_core.c    | 10 +++-------
>  net/bluetooth/l2cap_sock.c    | 13 +++++++++++++
>  3 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> index 7002f0d..eef7146 100644
> --- a/include/net/bluetooth/l2cap.h
> +++ b/include/net/bluetooth/l2cap.h
> @@ -540,6 +540,7 @@ struct l2cap_ops {
>  	void			(*state_change) (struct l2cap_chan *chan,
>  						 int state);
>  	void			(*ready) (struct l2cap_chan *chan);
> +	void			(*defer) (struct l2cap_chan *chan);
>  	struct sk_buff		*(*alloc_skb) (struct l2cap_chan *chan,
>  					       unsigned long len, int nb);
>  };
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 9e166ce..02a66fb 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -1123,11 +1123,9 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
>  				lock_sock(sk);
>  				if (test_bit(BT_SK_DEFER_SETUP,
>  					     &bt_sk(sk)->flags)) {
> -					struct sock *parent = bt_sk(sk)->parent;
>  					rsp.result = __constant_cpu_to_le16(L2CAP_CR_PEND);
>  					rsp.status = __constant_cpu_to_le16(L2CAP_CS_AUTHOR_PEND);
> -					if (parent)
> -						parent->sk_data_ready(parent, 0);
> +					chan->ops->defer(chan);
>  
>  				} else {
>  					__l2cap_state_change(chan, BT_CONFIG);
> @@ -3459,7 +3457,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn,
>  				__l2cap_state_change(chan, BT_CONNECT2);
>  				result = L2CAP_CR_PEND;
>  				status = L2CAP_CS_AUTHOR_PEND;
> -				parent->sk_data_ready(parent, 0);
> +				chan->ops->defer(chan);
>  			} else {
>  				__l2cap_state_change(chan, BT_CONFIG);
>  				result = L2CAP_CR_SUCCESS;
> @@ -5520,11 +5518,9 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
>  			if (!status) {
>  				if (test_bit(BT_SK_DEFER_SETUP,
>  					     &bt_sk(sk)->flags)) {
> -					struct sock *parent = bt_sk(sk)->parent;
>  					res = L2CAP_CR_PEND;
>  					stat = L2CAP_CS_AUTHOR_PEND;
> -					if (parent)
> -						parent->sk_data_ready(parent, 0);
> +					chan->ops->defer(chan);
>  				} else {
>  					__l2cap_state_change(chan, BT_CONFIG);
>  					res = L2CAP_CR_SUCCESS;
> diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
> index 0feb8f8..f0e4410 100644
> --- a/net/bluetooth/l2cap_sock.c
> +++ b/net/bluetooth/l2cap_sock.c
> @@ -955,6 +955,7 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)
>  
>  	bt_accept_enqueue(parent, sk);
>  
> +
>  	release_sock(parent);
>  
>  	return l2cap_pi(sk)->chan;
> @@ -1087,6 +1088,17 @@ static void l2cap_sock_ready_cb(struct l2cap_chan *chan)
>  	release_sock(sk);
>  }
>  
> +static void l2cap_sock_defer_cb(struct l2cap_chan *chan)
> +{
> +	struct sock *sk = chan->data;
> +	struct sock *parent;
> +
> +	parent = bt_sk(sk)->parent;
> +
> +	if (parent)
> +		parent->sk_data_ready(parent, 0);
> +}
> +
>  static struct l2cap_ops l2cap_chan_ops = {
>  	.name		= "L2CAP Socket Interface",
>  	.new_connection	= l2cap_sock_new_connection_cb,
> @@ -1095,6 +1107,7 @@ static struct l2cap_ops l2cap_chan_ops = {
>  	.teardown	= l2cap_sock_teardown_cb,
>  	.state_change	= l2cap_sock_state_change_cb,
>  	.ready		= l2cap_sock_ready_cb,
> +	.defer		= l2cap_sock_defer_cb,
>  	.alloc_skb	= l2cap_sock_alloc_skb_cb,
>  };

I think we might add just in case no_defer in  a2mp_chan_ops

Best regards 
Andrei Emeltchenko 


^ permalink raw reply

* [PATCH -v4 2/2] rctest: add option to save received data to file
From: Gustavo Padovan @ 2012-10-08  3:50 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1349668203-10782-1-git-send-email-gustavo@padovan.org>

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

works only for automated test option for now
---
 test/rctest.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 53 insertions(+), 3 deletions(-)

diff --git a/test/rctest.c b/test/rctest.c
index d19e096..ac341b0 100644
--- a/test/rctest.c
+++ b/test/rctest.c
@@ -78,6 +78,8 @@ static uint16_t uuid = 0x0000;
 static uint8_t channel = 10;
 
 static char *filename = NULL;
+static char *savefile = NULL;
+static int save_fd = -1;
 
 static int master = 0;
 static int auth = 0;
@@ -448,6 +450,25 @@ static void dump_mode(int sk)
 		syslog(LOG_INFO, "Received %d bytes", len);
 }
 
+static void save_mode(int sk)
+{
+	int len, ret;
+	char *b;
+
+	b = malloc(data_size);
+	if (!b) {
+		syslog(LOG_ERR, "Failed to open file to save recv data");
+		return;
+	}
+
+	syslog(LOG_INFO, "Receiving ...");
+	while ((len = read(sk, b, data_size)) > 0) {
+		ret = write(save_fd, b, len);
+		if (ret < 0)
+			return;
+	}
+}
+
 static void recv_mode(int sk)
 {
 	struct timeval tv_beg, tv_end, tv_diff;
@@ -604,7 +625,19 @@ static void automated_send_recv()
 	char device[18];
 
 	if (fork()) {
-		do_listen(recv_mode);
+		if (!savefile) {
+			do_listen(recv_mode);
+			return;
+		}
+
+		save_fd = open(savefile, O_CREAT | O_WRONLY,
+						S_IRUSR | S_IWUSR);
+		if (save_fd < 0)
+			syslog(LOG_ERR, "Failed to open file to save data");
+
+		do_listen(save_mode);
+
+		close(save_fd);
 	} else {
 		ba2str(&bdaddr, device);
 
@@ -615,6 +648,15 @@ static void automated_send_recv()
 	}
 }
 
+static void sig_child_exit(int code)
+{
+	if (save_fd >= 0)
+		close(save_fd);
+
+	syslog(LOG_INFO, "Exit");
+	exit(0);
+}
+
 static void usage(void)
 {
 	printf("rctest - RFCOMM testing\n"
@@ -636,6 +678,7 @@ static void usage(void)
 		"\t[-L seconds] enabled SO_LINGER option\n"
 		"\t[-W seconds] enable deferred setup\n"
 		"\t[-B filename] use data packets from file\n"
+		"\t[-O filename] save received data to file\n"
 		"\t[-N num] number of frames to send\n"
 		"\t[-C num] send num frames before delay (default = 1)\n"
 		"\t[-D milliseconds] delay after sending num frames (default = 0)\n"
@@ -655,7 +698,7 @@ int main(int argc, char *argv[])
 	bacpy(&bdaddr, BDADDR_ANY);
 	bacpy(&auto_bdaddr, BDADDR_ANY);
 
-	while ((opt=getopt(argc,argv,"rdscuwmna:b:i:P:U:B:N:MAESL:W:C:D:Y:T")) != EOF) {
+	while ((opt=getopt(argc,argv,"rdscuwmna:b:i:P:U:B:O:N:MAESL:W:C:D:Y:T")) != EOF) {
 		switch (opt) {
 		case 'r':
 			mode = RECV;
@@ -755,6 +798,10 @@ int main(int argc, char *argv[])
 			filename = strdup(optarg);
 			break;
 
+		case 'O':
+			savefile = strdup(optarg);
+			break;
+
 		case 'N':
 			num_frames = atoi(optarg);
 			break;
@@ -792,7 +839,10 @@ int main(int argc, char *argv[])
 	}
 
 	memset(&sa, 0, sizeof(sa));
-	sa.sa_handler = SIG_IGN;
+	if (mode == AUTO)
+		sa.sa_handler = sig_child_exit;
+	else
+		sa.sa_handler = SIG_IGN;
 	sa.sa_flags   = SA_NOCLDSTOP;
 	sigaction(SIGCHLD, &sa, NULL);
 
-- 
1.7.11.4


^ permalink raw reply related

* [PATCH -v4 1/2] rctest: add automated test
From: Gustavo Padovan @ 2012-10-08  3:50 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1346446228-11105-1-git-send-email-gustavo@padovan.org>

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

adds -a option to enable automated tests. We use the -i option to define
the receiving side and the -a define the sending side:

./rctest -i hci0 -a hci1
---
 test/rctest.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/test/rctest.c b/test/rctest.c
index 2dd54de..d19e096 100644
--- a/test/rctest.c
+++ b/test/rctest.c
@@ -55,7 +55,8 @@ enum {
 	DUMP,
 	CONNECT,
 	CRECV,
-	LSEND
+	LSEND,
+	AUTO,
 };
 
 static unsigned char *buf;
@@ -72,6 +73,7 @@ static unsigned long delay = 0;
 
 /* Default addr and channel */
 static bdaddr_t bdaddr;
+static bdaddr_t auto_bdaddr;
 static uint16_t uuid = 0x0000;
 static uint8_t channel = 10;
 
@@ -162,7 +164,11 @@ static int do_connect(const char *svr)
 	/* Bind to local address */
 	memset(&addr, 0, sizeof(addr));
 	addr.rc_family = AF_BLUETOOTH;
-	bacpy(&addr.rc_bdaddr, &bdaddr);
+
+	if (bacmp(&auto_bdaddr, BDADDR_ANY))
+		bacpy(&addr.rc_bdaddr, &auto_bdaddr);
+	else
+		bacpy(&addr.rc_bdaddr, &bdaddr);
 
 	if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 		syslog(LOG_ERR, "Can't bind socket: %s (%d)",
@@ -592,6 +598,23 @@ static void multi_connect_mode(int argc, char *argv[])
 	}
 }
 
+static void automated_send_recv()
+{
+	int sk;
+	char device[18];
+
+	if (fork()) {
+		do_listen(recv_mode);
+	} else {
+		ba2str(&bdaddr, device);
+
+		sk = do_connect(device);
+		if (sk < 0)
+			exit(1);
+		send_mode(sk);
+	}
+}
+
 static void usage(void)
 {
 	printf("rctest - RFCOMM testing\n"
@@ -605,7 +628,8 @@ static void usage(void)
 		"\t-u connect and receive\n"
 		"\t-n connect and be silent\n"
 		"\t-c connect, disconnect, connect, ...\n"
-		"\t-m multiple connects\n");
+		"\t-m multiple connects\n"
+		"\t-a automated test (receive hcix as parameter)\n");
 
 	printf("Options:\n"
 		"\t[-b bytes] [-i device] [-P channel] [-U uuid]\n"
@@ -629,8 +653,9 @@ int main(int argc, char *argv[])
 	int opt, sk, mode = RECV, need_addr = 0;
 
 	bacpy(&bdaddr, BDADDR_ANY);
+	bacpy(&auto_bdaddr, BDADDR_ANY);
 
-	while ((opt=getopt(argc,argv,"rdscuwmnb:i:P:U:B:N:MAESL:W:C:D:Y:T")) != EOF) {
+	while ((opt=getopt(argc,argv,"rdscuwmna:b:i:P:U:B:N:MAESL:W:C:D:Y:T")) != EOF) {
 		switch (opt) {
 		case 'r':
 			mode = RECV;
@@ -669,6 +694,15 @@ int main(int argc, char *argv[])
 			need_addr = 1;
 			break;
 
+		case 'a':
+			mode = AUTO;
+
+			if (!strncasecmp(optarg, "hci", 3))
+				hci_devba(atoi(optarg + 3), &auto_bdaddr);
+			else
+				str2ba(optarg, &auto_bdaddr);
+			break;
+
 		case 'b':
 			data_size = atoi(optarg);
 			break;
@@ -805,6 +839,10 @@ int main(int argc, char *argv[])
 				exit(1);
 			dump_mode(sk);
 			break;
+
+		case AUTO:
+			automated_send_recv();
+			break;
 	}
 
 	syslog(LOG_INFO, "Exit");
-- 
1.7.11.4


^ permalink raw reply related

* [PATCH 8/8] Bluetooth: Call ops->teardown() without checking for NULL
From: Gustavo Padovan @ 2012-10-07 23:19 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1349651981-6251-1-git-send-email-gustavo@padovan.org>

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Users that don't implement teardown() should use l2cap_chan_no_teardown()

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 net/bluetooth/l2cap_core.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 8882f2e..90051d2 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -542,8 +542,7 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err)
 			hci_conn_put(conn->hcon);
 	}
 
-	if (chan->ops->teardown)
-		chan->ops->teardown(chan, err);
+	chan->ops->teardown(chan, err);
 
 	if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))
 		return;
@@ -582,8 +581,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
 
 	switch (chan->state) {
 	case BT_LISTEN:
-		if (chan->ops->teardown)
-			chan->ops->teardown(chan, 0);
+		chan->ops->teardown(chan, 0);
 		break;
 
 	case BT_CONNECTED:
@@ -625,8 +623,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
 		break;
 
 	default:
-		if (chan->ops->teardown)
-			chan->ops->teardown(chan, 0);
+		chan->ops->teardown(chan, 0);
 		break;
 	}
 }
-- 
1.7.11.4


^ permalink raw reply related

* [PATCH 7/8] Bluetooth: Use locked l2cap_state_change()
From: Gustavo Padovan @ 2012-10-07 23:19 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1349651981-6251-1-git-send-email-gustavo@padovan.org>

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

No one was protecting the state set in l2cap_send_disconn_req()

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 net/bluetooth/l2cap_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 94b0e75..8882f2e 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1062,7 +1062,7 @@ static void l2cap_send_disconn_req(struct l2cap_conn *conn,
 	}
 
 	if (chan->chan_type == L2CAP_CHAN_CONN_FIX_A2MP) {
-		__l2cap_state_change(chan, BT_DISCONN);
+		l2cap_state_change(chan, BT_DISCONN);
 		return;
 	}
 
-- 
1.7.11.4


^ permalink raw reply related

* [PATCH 6/8] Bluetooth: use l2cap_chan_set_err()
From: Gustavo Padovan @ 2012-10-07 23:19 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Gustavo Padovan
In-Reply-To: <1349651981-6251-1-git-send-email-gustavo@padovan.org>

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

l2cap_conn_unreliable() doesn't take the sk lock, so we need to take it
using l2cap_chan_set_err().

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 net/bluetooth/l2cap_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 7914641..94b0e75 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1293,7 +1293,7 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err)
 
 	list_for_each_entry(chan, &conn->chan_l, list) {
 		if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags))
-			__l2cap_chan_set_err(chan, err);
+			l2cap_chan_set_err(chan, err);
 	}
 
 	mutex_unlock(&conn->chan_lock);
-- 
1.7.11.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