Linux bluetooth development
 help / color / mirror / Atom feed
* Re: LE Connection Update Disallowed
From: Anderson Lizardo @ 2014-02-05 15:23 UTC (permalink / raw)
  To: Sandy Chapman; +Cc: BlueZ development
In-Reply-To: <CAPm3yA2LJMPOSGGzscQe8XV+gu8+kf5WZurk8DsSWEBBCOJcew@mail.gmail.com>

HI Sandy,

On Wed, Feb 5, 2014 at 10:51 AM, Sandy Chapman <schapman@lixar.com> wrote:
>>> How do I initiate a Connection Update from the peripheral?
>>
>> I never tried this procedure myself, but my guess it that you are
>> using the incorrect mechanism on the slave role. Take a look at the
>> "Connection Parameters Update Request" on Vol 3, Part A, Section 4.20.
>> I believe this is the correct way to request from the slave (from what
>> I understand while reading the Linux kernel implementation of the
>> master side).
>>
>> Note that when Linux is the master, this command is issued
>> automatically by the kernel when requested by the slave.
>
> I've taken a look at that section and it appears that this is what is
> used to trigger the Connection Update. It states that the command
> shall only be issued from the slave to the master. I can confirm that
> my device is in the slave role using 'hcitool con'.

I think you didn't notice that the section I mentioned is about a
L2CAP signalling packet, not an HCI command (which in this case is to
be used on the master side). I suggest you read a bit more on the
L2CAP section to understand how these signalling packets work. Then
you can try building such packet with "hcitool cmd" (unless there is
some support for it on the current kernel, which I didn't check)

>> You may want to take a look at the "GAP Peripheral Preferred
>> Connection Parameters" characteristic (see Vol 3, Part C, Section
>> 12.3). If iPhones reads this characteristic and honours the
>> parameters, it may help.
>
> Unfortunately, it appears Apple explicitly ignores this parameter
> (section 3.6 in this document
> https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf).

This is unfortunate. It would be the easiest way to pass custom
connection parameters IMHO.

> I believe that 'hcitool lecup' is exactly supposed to initiate this
> process. I've also tried to use 'hcitool cmd' to issue direct commands
> to the controller (using Vol 3, Part A, Section 4.20 as a guide), but
> I am having no luck. It's stating that the command is disallowed (not
> that the parameters are invalid), so I'm guessing there's something
> else wrong. Since this is directly communicating with the controller,
> where would the problem be? In the kernel, itself? Could it be a
> problem with the Broadcom chipset in my MacBook?

"hcitool lecup" is just a helper, it uses the same mechanism that
"hcitool cmd" uses (and both are just "raw" interfaces to the
Bluetooth controller). If you are getting an "Invalid Parameters" on
any of them, is either because you built the packet incorrectly on
"hcitool cmd" or given invalid values as per the spec.

By the way, I suggest using "btmon" instead of "hcidump", as the
former has nicer output and is more up-to-date (although I'm not sure
it supports parsing "LE Connection Update" parameters).

Best Regards,
-- 
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil

^ permalink raw reply

* Re: LE Connection Update Disallowed
From: Sandy Chapman @ 2014-02-05 14:51 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: BlueZ development
In-Reply-To: <CAJdJm_OK5TW3ECqQgF_JnUzO3McPCW=inG3HOxm1c_K4ODkWEQ@mail.gmail.com>

Hi Anderson,

On Wed, Feb 5, 2014 at 9:12 AM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> Hi Sandy,
>
> On Wed, Feb 5, 2014 at 8:26 AM, Sandy Chapman <schapman@lixar.com> wrote:
>> I establish an LE connection between the devices. The central
>> successfully discovers the services and characteristics and can read
>> them. Once the connection is established, I run this command on the
>> Linux peripheral:
>>
>> $ sudo ./bin/hcitool lecup --handle 64 --min 24 --max 50 --latency 4
>> --timeout 550
>>>>> Could not change connection params: Input/output error(5)
>>
>> In my hcidump -X, I get this:
>>
>> < HCI Command: LE Connection Update (0x08|0x0013) plen 14
>>   0000: 40 00 18 00 32 00 04 00  26 02 01 00 01 00        @...2...&.....
>>> HCI Event: Command Status (0x0f) plen 4
>>     LE Connection Update (0x08|0x0013) status 0x0c ncmd 1
>>     Error: Command Disallowed
>
> This errors comes directly from the controller. The host is not at
> fault here, as hcitool issues HCI commands directly to the controller.
>
>> How do I initiate a Connection Update from the peripheral?
>
> I never tried this procedure myself, but my guess it that you are
> using the incorrect mechanism on the slave role. Take a look at the
> "Connection Parameters Update Request" on Vol 3, Part A, Section 4.20.
> I believe this is the correct way to request from the slave (from what
> I understand while reading the Linux kernel implementation of the
> master side).
>
> Note that when Linux is the master, this command is issued
> automatically by the kernel when requested by the slave.

I've taken a look at that section and it appears that this is what is
used to trigger the Connection Update. It states that the command
shall only be issued from the slave to the master. I can confirm that
my device is in the slave role using 'hcitool con'.

$ hcitool con
<<< Connections:
<<< Unknown 53:DC:05:A5:FA:7B handle 64 state 1 lm SLAVE

>
>> If this
>> isn't possible, how to I dictate the connection parameters (the
>> current connection is much too slow)?
>
> You may want to take a look at the "GAP Peripheral Preferred
> Connection Parameters" characteristic (see Vol 3, Part C, Section
> 12.3). If iPhones reads this characteristic and honours the
> parameters, it may help.

Unfortunately, it appears Apple explicitly ignores this parameter
(section 3.6 in this document
https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf).

>
> Best Regards,
> --
> Anderson Lizardo
> http://www.indt.org/?lang=en
> INdT - Manaus - Brazil

Now what I want to do is to issue a command to the controller to begin
the Connection Update. This would result in the linux slave issuing a
Connection Update packet to the iPhone master. This doesn't seem to be
happening and is being blocked.

I believe that 'hcitool lecup' is exactly supposed to initiate this
process. I've also tried to use 'hcitool cmd' to issue direct commands
to the controller (using Vol 3, Part A, Section 4.20 as a guide), but
I am having no luck. It's stating that the command is disallowed (not
that the parameters are invalid), so I'm guessing there's something
else wrong. Since this is directly communicating with the controller,
where would the problem be? In the kernel, itself? Could it be a
problem with the Broadcom chipset in my MacBook?

Thanks again,
Sandy

-- 


^ permalink raw reply

* [PATCH BlueZ 2/2] audio/AVCTP: Lookup key name from key_map table
From: Luiz Augusto von Dentz @ 2014-02-05 14:24 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391610272-12991-1-git-send-email-luiz.dentz@gmail.com>

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

The key_map table already contain the key name.
---
 android/avctp.c        | 36 ++++++++----------------------------
 profiles/audio/avctp.c | 38 +++++++++-----------------------------
 2 files changed, 17 insertions(+), 57 deletions(-)

diff --git a/android/avctp.c b/android/avctp.c
index f7544a2..1e414d1 100644
--- a/android/avctp.c
+++ b/android/avctp.c
@@ -1136,36 +1136,16 @@ int avctp_send_browsing_req(struct avctp *session,
 	return 0;
 }
 
-static char *op2str(uint8_t op)
+static const char *op2str(uint8_t op)
 {
-	switch (op & 0x7f) {
-	case AVC_VOLUME_UP:
-		return "VOLUME UP";
-	case AVC_VOLUME_DOWN:
-		return "VOLUME DOWN";
-	case AVC_MUTE:
-		return "MUTE";
-	case AVC_PLAY:
-		return "PLAY";
-	case AVC_STOP:
-		return "STOP";
-	case AVC_PAUSE:
-		return "PAUSE";
-	case AVC_RECORD:
-		return "RECORD";
-	case AVC_REWIND:
-		return "REWIND";
-	case AVC_FAST_FORWARD:
-		return "FAST FORWARD";
-	case AVC_EJECT:
-		return "EJECT";
-	case AVC_FORWARD:
-		return "FORWARD";
-	case AVC_BACKWARD:
-		return "BACKWARD";
-	default:
-		return "UNKNOWN";
+	int i;
+
+	for (i = 0; key_map[i].name != NULL; i++) {
+		if ((op & 0x7F) == key_map[i].avc)
+			return key_map[i].name;
 	}
+
+	return "UNKNOWN";
 }
 
 static int avctp_passthrough_press(struct avctp *session, uint8_t op)
diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index ae142bd..28c7685 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -1610,36 +1610,16 @@ int avctp_send_browsing_req(struct avctp *session,
 	return 0;
 }
 
-static char *op2str(uint8_t op)
-{
-	switch (op & 0x7f) {
-	case AVC_VOLUME_UP:
-		return "VOLUME UP";
-	case AVC_VOLUME_DOWN:
-		return "VOLUME DOWN";
-	case AVC_MUTE:
-		return "MUTE";
-	case AVC_PLAY:
-		return "PLAY";
-	case AVC_STOP:
-		return "STOP";
-	case AVC_PAUSE:
-		return "PAUSE";
-	case AVC_RECORD:
-		return "RECORD";
-	case AVC_REWIND:
-		return "REWIND";
-	case AVC_FAST_FORWARD:
-		return "FAST FORWARD";
-	case AVC_EJECT:
-		return "EJECT";
-	case AVC_FORWARD:
-		return "FORWARD";
-	case AVC_BACKWARD:
-		return "BACKWARD";
-	default:
-		return "UNKNOWN";
+static const char *op2str(uint8_t op)
+{
+	int i;
+
+	for (i = 0; key_map[i].name != NULL; i++) {
+		if ((op & 0x7F) == key_map[i].avc)
+			return key_map[i].name;
 	}
+
+	return "UNKNOWN";
 }
 
 static int avctp_passthrough_press(struct avctp *session, uint8_t op)
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 1/2] audio/AVCTP: Add keys that can be mapped to uinput
From: Luiz Augusto von Dentz @ 2014-02-05 14:24 UTC (permalink / raw)
  To: linux-bluetooth

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

This adds the remaining AV/C keys that can be mapped to uinput.
---
 android/avctp.c        | 28 ++++++++++++++++++++++++++++
 android/avctp.h        | 29 +++++++++++++++++++++++++++++
 profiles/audio/avctp.c | 28 ++++++++++++++++++++++++++++
 profiles/audio/avctp.h | 29 +++++++++++++++++++++++++++++
 4 files changed, 114 insertions(+)

diff --git a/android/avctp.c b/android/avctp.c
index 8f35403..f7544a2 100644
--- a/android/avctp.c
+++ b/android/avctp.c
@@ -215,25 +215,53 @@ static struct {
 	{ "ROOT MENU",		AVC_ROOT_MENU,		KEY_MENU },
 	{ "CONTENTS MENU",	AVC_CONTENTS_MENU,	KEY_PROGRAM },
 	{ "FAVORITE MENU",	AVC_FAVORITE_MENU,	KEY_FAVORITES },
+	{ "EXIT",		AVC_EXIT,		KEY_EXIT },
+	{ "ON DEMAND MENU",	AVC_ON_DEMAND_MENU,	KEY_MENU },
+	{ "APPS MENU",		AVC_APPS_MENU,		KEY_MENU },
+	{ "0",			AVC_0,			KEY_0 },
+	{ "1",			AVC_1,			KEY_1 },
+	{ "2",			AVC_2,			KEY_2 },
+	{ "3",			AVC_3,			KEY_3 },
+	{ "4",			AVC_4,			KEY_4 },
+	{ "5",			AVC_5,			KEY_5 },
+	{ "6",			AVC_6,			KEY_6 },
+	{ "7",			AVC_7,			KEY_7 },
+	{ "8",			AVC_8,			KEY_8 },
+	{ "9",			AVC_9,			KEY_9 },
+	{ "DOT",		AVC_DOT,		KEY_DOT },
 	{ "ENTER",		AVC_ENTER,		KEY_ENTER },
 	{ "CHANNEL UP",		AVC_CHANNEL_UP,		KEY_CHANNELUP },
 	{ "CHANNEL DOWN",	AVC_CHANNEL_DOWN,	KEY_CHANNELDOWN },
+	{ "CHANNEL PREVIOUS",	AVC_CHANNEL_PREVIOUS,	KEY_LAST },
 	{ "INPUT SELECT",	AVC_INPUT_SELECT,	KEY_CONFIG },
+	{ "INFO",		AVC_INFO,		KEY_INFO },
 	{ "HELP",		AVC_HELP,		KEY_HELP },
 	{ "POWER",		AVC_POWER,		KEY_POWER2 },
 	{ "VOLUME UP",		AVC_VOLUME_UP,		KEY_VOLUMEUP },
 	{ "VOLUME DOWN",	AVC_VOLUME_DOWN,	KEY_VOLUMEDOWN },
+	{ "MUTE",		AVC_MUTE,		KEY_MUTE },
 	{ "PLAY",		AVC_PLAY,		KEY_PLAYCD },
 	{ "STOP",		AVC_STOP,		KEY_STOPCD },
 	{ "PAUSE",		AVC_PAUSE,		KEY_PAUSECD },
 	{ "FORWARD",		AVC_FORWARD,		KEY_NEXTSONG },
 	{ "BACKWARD",		AVC_BACKWARD,		KEY_PREVIOUSSONG },
+	{ "RECORD",		AVC_RECORD,		KEY_RECORD },
 	{ "REWIND",		AVC_REWIND,		KEY_REWIND },
 	{ "FAST FORWARD",	AVC_FAST_FORWARD,	KEY_FASTFORWARD },
+	{ "LIST",		AVC_LIST,		KEY_LIST },
 	{ "F1",			AVC_F1,			KEY_F1 },
 	{ "F2",			AVC_F2,			KEY_F2 },
 	{ "F3",			AVC_F3,			KEY_F3 },
 	{ "F4",			AVC_F4,			KEY_F4 },
+	{ "F5",			AVC_F5,			KEY_F5 },
+	{ "F6",			AVC_F6,			KEY_F6 },
+	{ "F7",			AVC_F7,			KEY_F7 },
+	{ "F8",			AVC_F8,			KEY_F8 },
+	{ "F9",			AVC_F9,			KEY_F9 },
+	{ "RED",		AVC_RED,		KEY_RED },
+	{ "GREEN",		AVC_GREEN,		KEY_GREEN },
+	{ "BLUE",		AVC_BLUE,		KEY_BLUE },
+	{ "YELLOW",		AVC_YELLOW,		KEY_YELLOW },
 	{ NULL }
 };
 
diff --git a/android/avctp.h b/android/avctp.h
index e7e0277..dfa0ca6 100644
--- a/android/avctp.h
+++ b/android/avctp.h
@@ -56,11 +56,30 @@
 #define AVC_ROOT_MENU			0x09
 #define AVC_CONTENTS_MENU		0x0b
 #define AVC_FAVORITE_MENU		0x0c
+#define AVC_EXIT			0x0d
+#define AVC_ON_DEMAND_MENU		0x0e
+#define AVC_APPS_MENU			0x0f
+#define AVC_0				0x20
+#define AVC_1				0x21
+#define AVC_2				0x22
+#define AVC_3				0x23
+#define AVC_4				0x24
+#define AVC_5				0x25
+#define AVC_6				0x26
+#define AVC_7				0x27
+#define AVC_8				0x28
+#define AVC_9				0x29
+#define AVC_DOT				0x2a
 #define AVC_ENTER			0x2b
 #define AVC_CHANNEL_UP			0x30
 #define AVC_CHANNEL_DOWN		0x31
+#define AVC_CHANNEL_PREVIOUS		0x32
 #define AVC_INPUT_SELECT		0x34
+#define AVC_INFO			0x35
 #define AVC_HELP			0x36
+#define AVC_PAGE_UP			0x37
+#define AVC_PAGE_DOWN			0x38
+#define AVC_LOCK			0x3a
 #define AVC_POWER			0x40
 #define AVC_VOLUME_UP			0x41
 #define AVC_VOLUME_DOWN			0x42
@@ -74,10 +93,20 @@
 #define AVC_EJECT			0x4a
 #define AVC_FORWARD			0x4b
 #define AVC_BACKWARD			0x4c
+#define AVC_LIST			0x4d
 #define AVC_F1				0x71
 #define AVC_F2				0x72
 #define AVC_F3				0x73
 #define AVC_F4				0x74
+#define AVC_F5				0x75
+#define AVC_F6				0x76
+#define AVC_F7				0x77
+#define AVC_F8				0x78
+#define AVC_F9				0x79
+#define AVC_RED				0x7a
+#define AVC_GREEN			0x7b
+#define AVC_BLUE			0x7c
+#define AVC_YELLOW			0x7c
 
 struct avctp;
 
diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 9f87859..ae142bd 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -238,25 +238,53 @@ static struct {
 	{ "ROOT MENU",		AVC_ROOT_MENU,		KEY_MENU },
 	{ "CONTENTS MENU",	AVC_CONTENTS_MENU,	KEY_PROGRAM },
 	{ "FAVORITE MENU",	AVC_FAVORITE_MENU,	KEY_FAVORITES },
+	{ "EXIT",		AVC_EXIT,		KEY_EXIT },
+	{ "ON DEMAND MENU",	AVC_ON_DEMAND_MENU,	KEY_MENU },
+	{ "APPS MENU",		AVC_APPS_MENU,		KEY_MENU },
+	{ "0",			AVC_0,			KEY_0 },
+	{ "1",			AVC_1,			KEY_1 },
+	{ "2",			AVC_2,			KEY_2 },
+	{ "3",			AVC_3,			KEY_3 },
+	{ "4",			AVC_4,			KEY_4 },
+	{ "5",			AVC_5,			KEY_5 },
+	{ "6",			AVC_6,			KEY_6 },
+	{ "7",			AVC_7,			KEY_7 },
+	{ "8",			AVC_8,			KEY_8 },
+	{ "9",			AVC_9,			KEY_9 },
+	{ "DOT",		AVC_DOT,		KEY_DOT },
 	{ "ENTER",		AVC_ENTER,		KEY_ENTER },
 	{ "CHANNEL UP",		AVC_CHANNEL_UP,		KEY_CHANNELUP },
 	{ "CHANNEL DOWN",	AVC_CHANNEL_DOWN,	KEY_CHANNELDOWN },
+	{ "CHANNEL PREVIOUS",	AVC_CHANNEL_PREVIOUS,	KEY_LAST },
 	{ "INPUT SELECT",	AVC_INPUT_SELECT,	KEY_CONFIG },
+	{ "INFO",		AVC_INFO,		KEY_INFO },
 	{ "HELP",		AVC_HELP,		KEY_HELP },
 	{ "POWER",		AVC_POWER,		KEY_POWER2 },
 	{ "VOLUME UP",		AVC_VOLUME_UP,		KEY_VOLUMEUP },
 	{ "VOLUME DOWN",	AVC_VOLUME_DOWN,	KEY_VOLUMEDOWN },
+	{ "MUTE",		AVC_MUTE,		KEY_MUTE },
 	{ "PLAY",		AVC_PLAY,		KEY_PLAYCD },
 	{ "STOP",		AVC_STOP,		KEY_STOPCD },
 	{ "PAUSE",		AVC_PAUSE,		KEY_PAUSECD },
 	{ "FORWARD",		AVC_FORWARD,		KEY_NEXTSONG },
 	{ "BACKWARD",		AVC_BACKWARD,		KEY_PREVIOUSSONG },
+	{ "RECORD",		AVC_RECORD,		KEY_RECORD },
 	{ "REWIND",		AVC_REWIND,		KEY_REWIND },
 	{ "FAST FORWARD",	AVC_FAST_FORWARD,	KEY_FASTFORWARD },
+	{ "LIST",		AVC_LIST,		KEY_LIST },
 	{ "F1",			AVC_F1,			KEY_F1 },
 	{ "F2",			AVC_F2,			KEY_F2 },
 	{ "F3",			AVC_F3,			KEY_F3 },
 	{ "F4",			AVC_F4,			KEY_F4 },
+	{ "F5",			AVC_F5,			KEY_F5 },
+	{ "F6",			AVC_F6,			KEY_F6 },
+	{ "F7",			AVC_F7,			KEY_F7 },
+	{ "F8",			AVC_F8,			KEY_F8 },
+	{ "F9",			AVC_F9,			KEY_F9 },
+	{ "RED",		AVC_RED,		KEY_RED },
+	{ "GREEN",		AVC_GREEN,		KEY_GREEN },
+	{ "BLUE",		AVC_BLUE,		KEY_BLUE },
+	{ "YELLOW",		AVC_YELLOW,		KEY_YELLOW },
 	{ NULL }
 };
 
diff --git a/profiles/audio/avctp.h b/profiles/audio/avctp.h
index f9c665e..05fceb4 100644
--- a/profiles/audio/avctp.h
+++ b/profiles/audio/avctp.h
@@ -57,11 +57,30 @@
 #define AVC_ROOT_MENU			0x09
 #define AVC_CONTENTS_MENU		0x0b
 #define AVC_FAVORITE_MENU		0x0c
+#define AVC_EXIT			0x0d
+#define AVC_ON_DEMAND_MENU		0x0e
+#define AVC_APPS_MENU			0x0f
+#define AVC_0				0x20
+#define AVC_1				0x21
+#define AVC_2				0x22
+#define AVC_3				0x23
+#define AVC_4				0x24
+#define AVC_5				0x25
+#define AVC_6				0x26
+#define AVC_7				0x27
+#define AVC_8				0x28
+#define AVC_9				0x29
+#define AVC_DOT				0x2a
 #define AVC_ENTER			0x2b
 #define AVC_CHANNEL_UP			0x30
 #define AVC_CHANNEL_DOWN		0x31
+#define AVC_CHANNEL_PREVIOUS		0x32
 #define AVC_INPUT_SELECT		0x34
+#define AVC_INFO			0x35
 #define AVC_HELP			0x36
+#define AVC_PAGE_UP			0x37
+#define AVC_PAGE_DOWN			0x38
+#define AVC_LOCK			0x3a
 #define AVC_POWER			0x40
 #define AVC_VOLUME_UP			0x41
 #define AVC_VOLUME_DOWN			0x42
@@ -75,10 +94,20 @@
 #define AVC_EJECT			0x4a
 #define AVC_FORWARD			0x4b
 #define AVC_BACKWARD			0x4c
+#define AVC_LIST			0x4d
 #define AVC_F1				0x71
 #define AVC_F2				0x72
 #define AVC_F3				0x73
 #define AVC_F4				0x74
+#define AVC_F5				0x75
+#define AVC_F6				0x76
+#define AVC_F7				0x77
+#define AVC_F8				0x78
+#define AVC_F9				0x79
+#define AVC_RED				0x7a
+#define AVC_GREEN			0x7b
+#define AVC_BLUE			0x7c
+#define AVC_YELLOW			0x7c
 
 struct avctp;
 
-- 
1.8.5.3


^ permalink raw reply related

* Re: [RFC 00/15] android/client: Add audio support
From: Szymon Janc @ 2014-02-05 14:13 UTC (permalink / raw)
  To: Jakub Tyszkowski; +Cc: linux-bluetooth
In-Reply-To: <1391081001-30723-1-git-send-email-jakub.tyszkowski@tieto.com>

Hi Jakub,

On Thursday 30 of January 2014 12:23:06 Jakub Tyszkowski wrote:
> This patch set adds audio support for haltest tool. It provides basic audio HAL
> functionality and adds ability to play PCM audio files.
> 
> I've also added sound generator when no file path is provided for "play"
> command. We can leave that be or push sample audio file to the tree, and/or
> hardcode the path. I think that leaving audio file selection to the user and
> providing fallback to sound generator is the right solution. Please let me know
> what is yours preference.
> 
> Regards.
> 
> Jakub Tyszkowski (15):
>   android/client-av: Fix checking for a2dp interface
>   android/client-audio: Add open/close output stream
>   android/client-audio: Add audio file playback
>   android/client-audio: Add playback suspend/resume
>   android/client-audio: Add get_latency for output
>   android/client-audio: Add get_buffer_size for output
>   android/client-audio: Add get_channels
>   android/client-audio: Add getting audio format
>   android/client-audio: Add getting sample rate
>   android/client-audio: Add get_parameters for output
>   android/client-audio: Add set_parameters
>   android/client-audio: Add setting sample rate
>   android/client-audio: Add init_check
>   android/client-audio: Add sine generator as fallback
>   android/client-audio: Fix getting audio module on Android
> 
>  android/Makefile.am       |   2 +-
>  android/client/if-audio.c | 477 +++++++++++++++++++++++++++++++++++++++++++++-
>  android/client/if-av.c    |   4 +-
>  3 files changed, 479 insertions(+), 4 deletions(-)

Despite it being RFC it looks good for me so I've applied patches 1-14.

For 15 I think haltest should not try to stop media server as this might
have unexpected side effects on Android. If one wants to use haltest for
audio testing on Android he can disable media server by hand.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* Re: [PATCH BlueZ 1/4] android/AVRCP: Add bt_avrcp_connect
From: Szymon Janc @ 2014-02-05 13:45 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1391596020-27679-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On Wednesday 05 of February 2014 12:26:57 Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This adds bt_avrcp_connect function which can be used to request AVRCP
> connections.
> ---
>  android/avrcp.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
>  android/avrcp.h |  2 ++
>  2 files changed, 57 insertions(+), 5 deletions(-)
> 
> diff --git a/android/avrcp.c b/android/avrcp.c
> index ef833df..8600d98 100644
> --- a/android/avrcp.c
> +++ b/android/avrcp.c
> @@ -54,6 +54,7 @@ static GIOChannel *server = NULL;
>  struct avrcp_device {
>  	bdaddr_t	dst;
>  	struct avctp	*session;
> +	GIOChannel	*io;
>  };
>  
>  static const struct ipc_handler cmd_handlers[] = {
> @@ -197,17 +198,20 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
>  	}
>  
>  	ba2str(&dst, address);
> -	DBG("Incoming connection from %s", address);
>  
>  	l = g_slist_find_custom(devices, &dst, device_cmp);
>  	if (l) {
> -		error("Unexpected connection");
> -		return;
> +		dev = l->data;
> +		if (dev->session) {
> +			error("Unexpected connection");
> +			return;
> +		}
> +	} else {
> +		DBG("Incoming connection from %s", address);
> +		dev = avrcp_device_new(&dst);
>  	}
>  
>  	fd = g_io_channel_unix_get_fd(chan);
> -
> -	dev = avrcp_device_new(&dst);
>  	dev->session = avctp_new(fd, imtu, omtu, 0x0100);
>  
>  	if (!dev->session) {
> @@ -222,6 +226,11 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
>  
>  	g_io_channel_set_close_on_unref(chan, FALSE);
>  
> +	if (dev->io) {
> +		g_io_channel_unref(dev->io);
> +		dev->io = NULL;
> +	}
> +
>  	DBG("%s connected", address);
>  }
>  
> @@ -288,3 +297,44 @@ void bt_avrcp_unregister(void)
>  		server = NULL;
>  	}
>  }
> +
> +static bool avrcp_device_connect(struct avrcp_device *dev, BtIOConnect cb)
> +{
> +	GError *err = NULL;
> +
> +	dev->io = bt_io_connect(cb, dev, NULL, &err,
> +					BT_IO_OPT_SOURCE_BDADDR, &adapter_addr,
> +					BT_IO_OPT_DEST_BDADDR, &dev->dst,
> +					BT_IO_OPT_PSM, L2CAP_PSM_AVCTP,
> +					BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
> +					BT_IO_OPT_INVALID);
> +	if (err) {
> +		error("%s", err->message);
> +		g_error_free(err);
> +		return false;
> +	}
> +
> +	return true;
> +}
> +
> +void bt_avrcp_connect(const bdaddr_t *dst)
> +{
> +	struct avrcp_device *dev;
> +	char addr[18];
> +	GSList *l;
> +
> +	DBG("");
> +
> +	l = g_slist_find_custom(devices, dst, device_cmp);
> +	if (l)
> +		return;
> +
> +	dev = avrcp_device_new(dst);
> +	if (!avrcp_device_connect(dev, connect_cb)) {
> +		avrcp_device_free(dev);
> +		return;
> +	}
> +
> +	ba2str(&dev->dst, addr);
> +	DBG("connecting to %s", addr);
> +}
> diff --git a/android/avrcp.h b/android/avrcp.h
> index 6fe7fbf..7b0a5ed 100644
> --- a/android/avrcp.h
> +++ b/android/avrcp.h
> @@ -23,3 +23,5 @@
>  
>  bool bt_avrcp_register(const bdaddr_t *addr);
>  void bt_avrcp_unregister(void);
> +
> +void bt_avrcp_connect(const bdaddr_t *dst);
> 

All four patches applied, thanks.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* Re: [PATCH] android/handsfree: Fix memory leak
From: Szymon Janc @ 2014-02-05 13:45 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1391597459-3791-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Wednesday 05 of February 2014 12:50:59 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> Free classes if sdp_get_access_protos fails.
> ---
>  android/handsfree.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/android/handsfree.c b/android/handsfree.c
> index edf3d27..9482b2e 100644
> --- a/android/handsfree.c
> +++ b/android/handsfree.c
> @@ -229,6 +229,7 @@ static void sdp_search_cb(sdp_list_t *recs, int err, gpointer data)
>  
>  	if (sdp_get_access_protos(recs->data, &protos) < 0) {
>  		error("handsfree: unable to get access protocols from record");
> +		sdp_list_free(classes, free);
>  		goto fail;
>  	}
>  

Applied, thanks.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* Re: LE Connection Update Disallowed
From: Anderson Lizardo @ 2014-02-05 13:12 UTC (permalink / raw)
  To: Sandy Chapman; +Cc: BlueZ development
In-Reply-To: <CAPm3yA3cOM0auyzqPLdKj5FFFva-REk3TnsrZcD9siV6kba+eA@mail.gmail.com>

Hi Sandy,

On Wed, Feb 5, 2014 at 8:26 AM, Sandy Chapman <schapman@lixar.com> wrote:
> I establish an LE connection between the devices. The central
> successfully discovers the services and characteristics and can read
> them. Once the connection is established, I run this command on the
> Linux peripheral:
>
> $ sudo ./bin/hcitool lecup --handle 64 --min 24 --max 50 --latency 4
> --timeout 550
>>>> Could not change connection params: Input/output error(5)
>
> In my hcidump -X, I get this:
>
> < HCI Command: LE Connection Update (0x08|0x0013) plen 14
>   0000: 40 00 18 00 32 00 04 00  26 02 01 00 01 00        @...2...&.....
>> HCI Event: Command Status (0x0f) plen 4
>     LE Connection Update (0x08|0x0013) status 0x0c ncmd 1
>     Error: Command Disallowed

This errors comes directly from the controller. The host is not at
fault here, as hcitool issues HCI commands directly to the controller.

> How do I initiate a Connection Update from the peripheral?

I never tried this procedure myself, but my guess it that you are
using the incorrect mechanism on the slave role. Take a look at the
"Connection Parameters Update Request" on Vol 3, Part A, Section 4.20.
I believe this is the correct way to request from the slave (from what
I understand while reading the Linux kernel implementation of the
master side).

Note that when Linux is the master, this command is issued
automatically by the kernel when requested by the slave.

> If this
> isn't possible, how to I dictate the connection parameters (the
> current connection is much too slow)?

You may want to take a look at the "GAP Peripheral Preferred
Connection Parameters" characteristic (see Vol 3, Part C, Section
12.3). If iPhones reads this characteristic and honours the
parameters, it may help.

Best Regards,
-- 
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil

^ permalink raw reply

* LE Connection Update Disallowed
From: Sandy Chapman @ 2014-02-05 12:26 UTC (permalink / raw)
  To: BlueZ development

Hi All,

I've got a problem with issuing an LE Connection Update via the
hcitool's lecup command and I'm not sure why. Based on what I've read
online, this should be working.

Central: iPhone 5
Peripheral: Linux Mint 15 running kernel 3.11.0-12-generic (running in
a VM on a Mac Book)
I'm using a built from source Bluez off tag 5.14.

I establish an LE connection between the devices. The central
successfully discovers the services and characteristics and can read
them. Once the connection is established, I run this command on the
Linux peripheral:

$ sudo ./bin/hcitool lecup --handle 64 --min 24 --max 50 --latency 4
--timeout 550
>>> Could not change connection params: Input/output error(5)

In my hcidump -X, I get this:

< HCI Command: LE Connection Update (0x08|0x0013) plen 14
  0000: 40 00 18 00 32 00 04 00  26 02 01 00 01 00        @...2...&.....
> HCI Event: Command Status (0x0f) plen 4
    LE Connection Update (0x08|0x0013) status 0x0c ncmd 1
    Error: Command Disallowed

In my limited understanding, it looks like the command isn't being
issued. It doesn't appear that it's the iPhone rejecting the command,
but something local to the Linux install. Running hciconfig lestates
shows that all states are permitted ("YES" beside every entry).

The Bluetooth Spec (Volume 2, Part E, section 7.8.18) states that this
command shall only be used when the local device's role is master.
However, Volume 3, Part A, 4.20 and 4.21 state that the request must
be initiated on the Slave side and the response must be initiated on
the Master (the 0x0013 hints that lecup is sending a response, but I
may be mistaken). I may be getting confused with terms, so I'll just
ask:

How do I initiate a Connection Update from the peripheral? If this
isn't possible, how to I dictate the connection parameters (the
current connection is much too slow)?

Thanks,
Sandy

-- 


^ permalink raw reply

* Re: [PATCHv2] android/avrcp: Decouple AVRCP logic from btio
From: Andrei Emeltchenko @ 2014-02-05 11:45 UTC (permalink / raw)
  To: Luiz Augusto von Dentz, linux-bluetooth@vger.kernel.org
In-Reply-To: <20140204130331.GO2930@aemeltch-MOBL1>

Hi Luiz,

On Tue, Feb 04, 2014 at 03:03:33PM +0200, Andrei Emeltchenko wrote:
> Hi Luiz,
> 
> On Tue, Feb 04, 2014 at 02:50:11PM +0200, Luiz Augusto von Dentz wrote:
> > Hi Andrei,
> > 
> > On Tue, Feb 4, 2014 at 1:56 PM, Andrei Emeltchenko
> > <Andrei.Emeltchenko.news@gmail.com> wrote:
> > > On Mon, Feb 03, 2014 at 11:16:17AM +0200, Andrei Emeltchenko wrote:
> > >> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > >>
> > >> The patch makes AVRCP to be channel-agnostic so that it might be used in
> > >> unit tests. The idea is that all AVRCP logic would come to avrcp-lib and
> > >> channel stuff got to avrcp.
> > 
> > I think we discussed this offline and decided not to have a separate
> > file for now.
> 
> So is the idea is to have unit-avrcp to be compiled with btio, etc? 
> I will then just to link everything what android/avrcp needs.

It looks like together with btio it also needs android/bluetooth.c for
bt_adapter_add_record() and we have source almost all files in android
subfolder. I believe that this is not the desired behaviour and we would
be better with separating AVRCP packet processing logic from the other code.

So what is wrong with the proposed approach? Maybe rename avctp-lib?

Best regards 
Andrei Emeltchenko 

^ permalink raw reply

* Re: [PATCH] unit/avctp: Add TP/NFR/BV-04-C test
From: Luiz Augusto von Dentz @ 2014-02-05 11:40 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1391521658-28893-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Tue, Feb 4, 2014 at 3:47 PM, Andrei Emeltchenko
<Andrei.Emeltchenko.news@gmail.com> wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Add test TP/NFR/BV-04-C for AVCTP.
> ---
>  unit/test-avctp.c | 40 +++++++++++++++++++++++++++++++---------
>  1 file changed, 31 insertions(+), 9 deletions(-)
>
> diff --git a/unit/test-avctp.c b/unit/test-avctp.c
> index 6d7e34a..581f88c 100644
> --- a/unit/test-avctp.c
> +++ b/unit/test-avctp.c
> @@ -240,15 +240,6 @@ static void execute_context(struct context *context)
>         destroy_context(context);
>  }
>
> -static void test_client(gconstpointer data)
> -{
> -       struct context *context = create_context(0x0100, data);
> -
> -       avctp_send_vendordep_req(context->session, 0, 0, NULL, 0, NULL, NULL);
> -
> -       execute_context(context);
> -}
> -
>  static size_t handler(struct avctp *session,
>                                         uint8_t transaction, uint8_t *code,
>                                         uint8_t *subunit, uint8_t *operands,
> @@ -265,6 +256,33 @@ static size_t handler(struct avctp *session,
>         return operand_count;
>  }
>
> +static gboolean handler_response(struct avctp *session,
> +                                       uint8_t code, uint8_t subunit,
> +                                       uint8_t *operands, size_t operand_count,
> +                                       void *user_data)
> +{
> +       struct context *context = user_data;
> +
> +       DBG("code 0x%02x subunit %d operand_count %zu", code, subunit,
> +                                                               operand_count);
> +
> +       g_assert_cmpint(code, ==, 0x0a);
> +       g_assert_cmpint(subunit, ==, 0);
> +       g_assert_cmpint(operand_count, ==, 0);
> +
> +       return context_quit(context);
> +}
> +
> +static void test_client(gconstpointer data)
> +{
> +       struct context *context = create_context(0x0100, data);
> +
> +       avctp_send_vendordep_req(context->session, 0, 0, NULL, 0,
> +                                               handler_response, context);
> +
> +       execute_context(context);
> +}
> +
>  static void test_server(gconstpointer data)
>  {
>         struct context *context = create_context(0x0100, data);
> @@ -322,6 +340,10 @@ int main(int argc, char *argv[])
>                                 raw_pdu(0x00, 0x11, 0x0e, 0x00, 0x00, 0x00),
>                                 raw_pdu(0x02, 0x11, 0x0e, 0x00, 0x00, 0x00));
>
> +       define_test("/TP/NFR/BV-04-C", test_client,
> +                               raw_pdu(0x00, 0x11, 0x0e, 0x00, 0x00, 0x00),
> +                               raw_pdu(0x02, 0x11, 0x0e, 0x0a, 0x00, 0x00));
> +
>         define_test("/TP/NFR/BI-01-C", test_server,
>                                 raw_pdu(0x00, 0xff, 0xff, 0x00, 0x00, 0x00),
>                                 raw_pdu(0x03, 0xff, 0xff));
> --
> 1.8.3.2

Applied, thanks.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH] pbap: Fix PhonebookSize endianness
From: Luiz Augusto von Dentz @ 2014-02-05 11:39 UTC (permalink / raw)
  To: Hannu Mallat; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1391413669-10534-1-git-send-email-hannu.mallat@jollamobile.com>

Hi Hannu,

On Mon, Feb 3, 2014 at 9:47 AM, Hannu Mallat
<hannu.mallat@jollamobile.com> wrote:
> As g_obex_apparam_set_uint16() converts data to big-endian format
> internally, do not call htons() prior to it.
> ---
>  obexd/plugins/pbap.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c
> index 4740188..acac3aa 100644
> --- a/obexd/plugins/pbap.c
> +++ b/obexd/plugins/pbap.c
> @@ -188,7 +188,7 @@ static void phonebook_size_result(const char *buffer, size_t bufsize,
>
>         DBG("vcards %d", vcards);
>
> -       phonebooksize = htons(vcards);
> +       phonebooksize = vcards;
>
>         pbap->obj->apparam = g_obex_apparam_set_uint16(NULL, PHONEBOOKSIZE_TAG,
>                                                                 phonebooksize);
> @@ -365,7 +365,7 @@ static int generate_response(void *user_data)
>
>         if (max == 0) {
>                 /* Ignore all other parameter and return PhoneBookSize */
> -               uint16_t size = htons(g_slist_length(pbap->cache.entries));
> +               uint16_t size = g_slist_length(pbap->cache.entries);
>
>                 pbap->obj->apparam = g_obex_apparam_set_uint16(
>                                                         pbap->obj->apparam,
> --
> 1.8.5.3

Applied, thanks.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* [PATCH] android/handsfree: Fix memory leak
From: Andrei Emeltchenko @ 2014-02-05 10:50 UTC (permalink / raw)
  To: linux-bluetooth

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

Free classes if sdp_get_access_protos fails.
---
 android/handsfree.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/android/handsfree.c b/android/handsfree.c
index edf3d27..9482b2e 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -229,6 +229,7 @@ static void sdp_search_cb(sdp_list_t *recs, int err, gpointer data)
 
 	if (sdp_get_access_protos(recs->data, &protos) < 0) {
 		error("handsfree: unable to get access protocols from record");
+		sdp_list_free(classes, free);
 		goto fail;
 	}
 
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH BlueZ 4/4] android: Disconnect AVRCP once A2DP is disconnected
From: Luiz Augusto von Dentz @ 2014-02-05 10:27 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391596020-27679-1-git-send-email-luiz.dentz@gmail.com>

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

If A2DP is disconnected also disconnect AVRCP.
---
 android/a2dp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index 962e7f5..731fa16 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -227,6 +227,8 @@ static void bt_a2dp_notify_state(struct a2dp_device *dev, uint8_t state)
 	if (state != HAL_A2DP_STATE_DISCONNECTED)
 		return;
 
+	bt_avrcp_disconnect(&dev->dst);
+
 	a2dp_device_free(dev);
 }
 
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 3/4] android: Connect AVRCP once A2DP is connected
From: Luiz Augusto von Dentz @ 2014-02-05 10:26 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391596020-27679-1-git-send-email-luiz.dentz@gmail.com>

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

In case of being the initiator of the A2DP connection also attempt to
connect AVRCP.
---
 android/a2dp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/android/a2dp.c b/android/a2dp.c
index a215ce2..962e7f5 100644
--- a/android/a2dp.c
+++ b/android/a2dp.c
@@ -45,6 +45,7 @@
 #include "utils.h"
 #include "bluetooth.h"
 #include "avdtp.h"
+#include "avrcp.h"
 #include "audio-msg.h"
 #include "audio-ipc.h"
 
@@ -544,6 +545,7 @@ static void signaling_connect_cb(GIOChannel *chan, GError *err,
 			error("avdtp_discover: %s", strerror(-perr));
 			goto failed;
 		}
+		bt_avrcp_connect(&dev->dst);
 	} else /* Init idle timeout to discover */
 		dev->idle_id = g_timeout_add_seconds(IDLE_TIMEOUT, idle_timeout,
 									dev);
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 2/4] android/AVRCP: Add bt_avrcp_disconnect
From: Luiz Augusto von Dentz @ 2014-02-05 10:26 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391596020-27679-1-git-send-email-luiz.dentz@gmail.com>

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

This adds bt_avrcp_disconnect function which can be used to disconnect
AVRCP sessions.
---
 android/avrcp.c | 26 ++++++++++++++++++++++++++
 android/avrcp.h |  1 +
 2 files changed, 27 insertions(+)

diff --git a/android/avrcp.c b/android/avrcp.c
index 8600d98..f61ed34 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -135,6 +135,11 @@ static void avrcp_device_free(void *data)
 	if (dev->session)
 		avctp_shutdown(dev->session);
 
+	if (dev->io) {
+		g_io_channel_shutdown(dev->io, FALSE, NULL);
+		g_io_channel_unref(dev->io);
+	}
+
 	devices = g_slist_remove(devices, dev);
 	g_free(dev);
 }
@@ -338,3 +343,24 @@ void bt_avrcp_connect(const bdaddr_t *dst)
 	ba2str(&dev->dst, addr);
 	DBG("connecting to %s", addr);
 }
+
+void bt_avrcp_disconnect(const bdaddr_t *dst)
+{
+	struct avrcp_device *dev;
+	GSList *l;
+
+	DBG("");
+
+	l = g_slist_find_custom(devices, dst, device_cmp);
+	if (!l)
+		return;
+
+	dev = l->data;
+
+	if (dev->session) {
+		avctp_shutdown(dev->session);
+		return;
+	}
+
+	avrcp_device_free(dev);
+}
diff --git a/android/avrcp.h b/android/avrcp.h
index 7b0a5ed..4ad49e6 100644
--- a/android/avrcp.h
+++ b/android/avrcp.h
@@ -25,3 +25,4 @@ bool bt_avrcp_register(const bdaddr_t *addr);
 void bt_avrcp_unregister(void);
 
 void bt_avrcp_connect(const bdaddr_t *dst);
+void bt_avrcp_disconnect(const bdaddr_t *dst);
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH BlueZ 1/4] android/AVRCP: Add bt_avrcp_connect
From: Luiz Augusto von Dentz @ 2014-02-05 10:26 UTC (permalink / raw)
  To: linux-bluetooth

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

This adds bt_avrcp_connect function which can be used to request AVRCP
connections.
---
 android/avrcp.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 android/avrcp.h |  2 ++
 2 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/android/avrcp.c b/android/avrcp.c
index ef833df..8600d98 100644
--- a/android/avrcp.c
+++ b/android/avrcp.c
@@ -54,6 +54,7 @@ static GIOChannel *server = NULL;
 struct avrcp_device {
 	bdaddr_t	dst;
 	struct avctp	*session;
+	GIOChannel	*io;
 };
 
 static const struct ipc_handler cmd_handlers[] = {
@@ -197,17 +198,20 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	}
 
 	ba2str(&dst, address);
-	DBG("Incoming connection from %s", address);
 
 	l = g_slist_find_custom(devices, &dst, device_cmp);
 	if (l) {
-		error("Unexpected connection");
-		return;
+		dev = l->data;
+		if (dev->session) {
+			error("Unexpected connection");
+			return;
+		}
+	} else {
+		DBG("Incoming connection from %s", address);
+		dev = avrcp_device_new(&dst);
 	}
 
 	fd = g_io_channel_unix_get_fd(chan);
-
-	dev = avrcp_device_new(&dst);
 	dev->session = avctp_new(fd, imtu, omtu, 0x0100);
 
 	if (!dev->session) {
@@ -222,6 +226,11 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 
 	g_io_channel_set_close_on_unref(chan, FALSE);
 
+	if (dev->io) {
+		g_io_channel_unref(dev->io);
+		dev->io = NULL;
+	}
+
 	DBG("%s connected", address);
 }
 
@@ -288,3 +297,44 @@ void bt_avrcp_unregister(void)
 		server = NULL;
 	}
 }
+
+static bool avrcp_device_connect(struct avrcp_device *dev, BtIOConnect cb)
+{
+	GError *err = NULL;
+
+	dev->io = bt_io_connect(cb, dev, NULL, &err,
+					BT_IO_OPT_SOURCE_BDADDR, &adapter_addr,
+					BT_IO_OPT_DEST_BDADDR, &dev->dst,
+					BT_IO_OPT_PSM, L2CAP_PSM_AVCTP,
+					BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
+					BT_IO_OPT_INVALID);
+	if (err) {
+		error("%s", err->message);
+		g_error_free(err);
+		return false;
+	}
+
+	return true;
+}
+
+void bt_avrcp_connect(const bdaddr_t *dst)
+{
+	struct avrcp_device *dev;
+	char addr[18];
+	GSList *l;
+
+	DBG("");
+
+	l = g_slist_find_custom(devices, dst, device_cmp);
+	if (l)
+		return;
+
+	dev = avrcp_device_new(dst);
+	if (!avrcp_device_connect(dev, connect_cb)) {
+		avrcp_device_free(dev);
+		return;
+	}
+
+	ba2str(&dev->dst, addr);
+	DBG("connecting to %s", addr);
+}
diff --git a/android/avrcp.h b/android/avrcp.h
index 6fe7fbf..7b0a5ed 100644
--- a/android/avrcp.h
+++ b/android/avrcp.h
@@ -23,3 +23,5 @@
 
 bool bt_avrcp_register(const bdaddr_t *addr);
 void bt_avrcp_unregister(void);
+
+void bt_avrcp_connect(const bdaddr_t *dst);
-- 
1.8.5.3


^ permalink raw reply related

* Re: [PATCH] android/pts: Update PICS and PTS for AVCTP
From: Szymon Janc @ 2014-02-05  9:55 UTC (permalink / raw)
  To: Sebastian Chlad; +Cc: linux-bluetooth
In-Reply-To: <1391505632-5306-1-git-send-email-sebastianx.chlad@intel.com>

Hi Sebastian,

On Tuesday 04 of February 2014 11:20:32 Sebastian Chlad wrote:
> Since we do not support AVCTP fragmentation for now we shell set PICS
> settings for AVCTP accordingly as well as set respective PTS test cases
> as N/A
> ---
>  android/pics-avctp.txt | 2 +-
>  android/pts-avctp.txt  | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/android/pics-avctp.txt b/android/pics-avctp.txt
> index 939ffdb..269bf08 100644
> --- a/android/pics-avctp.txt
> +++ b/android/pics-avctp.txt
> @@ -58,7 +58,7 @@ TSPC_AVCTP_2_14	False		Support for multiple AVCTP channel establishment
>  -------------------------------------------------------------------------------
>  Parameter Name	Selected	Description
>  -------------------------------------------------------------------------------
> -TSPC_AVCTP_3_1	True (*)	Message fragmentation (O)
> +TSPC_AVCTP_3_1	False		Message fragmentation (O)
>  TSPC_AVCTP_3_2	True		Transaction label management (M)
>  TSPC_AVCTP_3_3	True		Packet type field management (M)
>  TSPC_AVCTP_3_4	True		Message type field management (M)
> diff --git a/android/pts-avctp.txt b/android/pts-avctp.txt
> index 4090ec0..72a6373 100644
> --- a/android/pts-avctp.txt
> +++ b/android/pts-avctp.txt
> @@ -37,6 +37,6 @@ TC_TG_CCM_BV_04_C	PASS	avtest --device hci0 --avctp --send x <bdaddr>
>  TC_TG_NFR_BV_02_C	PASS	avtest --device hci0 --avctp --send x <bdaddr>
>  TC_TG_NFR_BV_03_C	PASS	avtest --device hci0 --avctp --send x <bdaddr>
>  TC_TG_NFR_BI_01_C	PASS
> -TC_TG_FRA_BV_02_C	FAIL
> -TC_TG_FRA_BV_03_C	INC
> +TC_TG_FRA_BV_02_C	N/A	Fragmentation not supported
> +TC_TG_FRA_BV_03_C	N/A	Fragmentation not supported
>  -------------------------------------------------------------------------------
> 

Pushed, thanks.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* Re: [PATCH BlueZ] audio/AVRCP: Fix checking for handler pointer instead of pdu_id
From: Luiz Augusto von Dentz @ 2014-02-05  9:37 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org
In-Reply-To: <1391420434-17873-1-git-send-email-luiz.dentz@gmail.com>

Hi,

On Mon, Feb 3, 2014 at 11:40 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> The code may not find a valid handler for the pdu_id, in that case the
> handler would not be NULL because the handlers table is not NULL
> terminated, instead the code should check if pdu_id really matches.
> ---
>  profiles/audio/avrcp.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
> index 12f7faa..4532d85 100644
> --- a/profiles/audio/avrcp.c
> +++ b/profiles/audio/avrcp.c
> @@ -1673,7 +1673,7 @@ static size_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction,
>                         break;
>         }
>
> -       if (!handler || handler->code != *code) {
> +       if (handler->pdu_id != pdu->pdu_id || handler->code != *code) {
>                 pdu->params[0] = AVRCP_STATUS_INVALID_COMMAND;
>                 goto err_metadata;
>         }
> @@ -1734,12 +1734,12 @@ static size_t handle_browsing_pdu(struct avctp *conn,
>
>         for (handler = browsing_handlers; handler->pdu_id; handler++) {
>                 if (handler->pdu_id == pdu->pdu_id)
> -                       break;
> +                       goto done;
>         }
>
> -       if (handler == NULL || handler->func == NULL)
> -               return avrcp_browsing_general_reject(operands);
> +       return avrcp_browsing_general_reject(operands);
>
> +done:
>         session->transaction = transaction;
>         handler->func(session, pdu, transaction);
>         return AVRCP_BROWSING_HEADER_LENGTH + ntohs(pdu->param_len);
> --
> 1.8.4.2

Pushed.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* [PATCH v2] android: Add support for Valgrind in debug variants
From: Andrzej Kaczmarek @ 2014-02-05  9:14 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek
In-Reply-To: <1391591653-17254-1-git-send-email-andrzej.kaczmarek@tieto.com>

This patch allows bluetoothd to be run with Valgrind easily in debug
variants.

For userdebug and eng variants bluetoothd is renamed to bluetoothd-main
and bluetoothd acts a wrapper to launch it either with or without
Valgrind (this is decided by value of persist.sys.bluetooth.valgrind
property).
---
 android/Android.mk           | 42 +++++++++++++++++++++++++++++
 android/bluetoothd-wrapper.c | 63 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 105 insertions(+)
 create mode 100644 android/bluetoothd-wrapper.c

diff --git a/android/Android.mk b/android/Android.mk
index 20105e6..52745fe 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -82,7 +82,15 @@ $(shell mkdir -p $(LOCAL_PATH)/bluez/lib/bluetooth)
 $(foreach file,$(lib_headers), $(shell ln -sf ../$(file) $(LOCAL_PATH)/bluez/lib/bluetooth/$(file)))
 
 LOCAL_MODULE_TAGS := optional
+
+# for userdebug/eng this module is bluetoothd-main since bluetoothd is used as
+# wrapper to launch bluetooth with Valgrind
+ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+LOCAL_MODULE := bluetoothd-main
+LOCAL_STRIP_MODULE := false
+else
 LOCAL_MODULE := bluetoothd
+endif
 
 include $(BUILD_EXECUTABLE)
 
@@ -406,3 +414,37 @@ LOCAL_CFLAGS:= \
 LOCAL_MODULE := libsbc
 
 include $(BUILD_SHARED_LIBRARY)
+
+ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
+
+#
+# bluetoothd (debug)
+# this is just a wrapper used in userdebug/eng to launch bluetoothd-main
+# with/without Valgrind
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	bluez/android/bluetoothd-wrapper.c
+
+LOCAL_CFLAGS := $(BLUEZ_COMMON_CFLAGS)
+
+LOCAL_SHARED_LIBRARIES := \
+	libcutils \
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := bluetoothd
+
+LOCAL_REQUIRED_MODULES := \
+	bluetoothd-main \
+	valgrind \
+	memcheck-$(TARGET_ARCH)-linux \
+	vgpreload_core-$(TARGET_ARCH)-linux \
+	vgpreload_memcheck-$(TARGET_ARCH)-linux \
+	default.supp
+
+include $(BUILD_EXECUTABLE)
+
+endif
\ No newline at end of file
diff --git a/android/bluetoothd-wrapper.c b/android/bluetoothd-wrapper.c
new file mode 100644
index 0000000..eb59822
--- /dev/null
+++ b/android/bluetoothd-wrapper.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <cutils/properties.h>
+
+#define PROPERTY_NAME "persist.sys.bluetooth.valgrind"
+
+#define VALGRIND_BIN "/system/bin/valgrind"
+
+#define BLUETOOTHD_BIN "/system/bin/bluetoothd-main"
+
+int main(int argc, char *argv[])
+{
+	char value[PROPERTY_VALUE_MAX];
+	char *prg_argv[4];
+	char *prg_envp[3];
+
+	if (property_get(PROPERTY_NAME, value, "") <= 0)
+		goto run_bluetoothd;
+
+	if (strcasecmp(value, "true") && atoi(value) == 0)
+		goto run_bluetoothd;
+
+	prg_argv[0] = VALGRIND_BIN;
+	prg_argv[1] = "--leak-check=full";
+	prg_argv[2] = BLUETOOTHD_BIN;
+	prg_argv[3] = NULL;
+
+	prg_envp[0] = "G_SLICE=always-malloc";
+	prg_envp[1] = "G_DEBUG=gc-friendly";
+	prg_envp[2] = NULL;
+
+	execve(prg_argv[0], prg_argv, prg_envp);
+
+run_bluetoothd:
+	prg_argv[0] = BLUETOOTHD_BIN;
+	prg_argv[1] = NULL;
+
+	prg_envp[0] = NULL;
+
+	execve(prg_argv[0], prg_argv, prg_envp);
+
+	return 0;
+}
-- 
1.8.5.3


^ permalink raw reply related

* [PATCH v2] Valgrind on Android
From: Andrzej Kaczmarek @ 2014-02-05  9:14 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrzej Kaczmarek

v1 -> v2
Valgrind can be enabled using property (persist.sys.bluetooth.valgrind)

In userdebug/eng variants bluetoothd is renamed to bluetoothd-main and
bluetoothd is simple wrapper to check property value and execute either
bluetoothd-main or valgrind. This way using Valgrind is transparent from
system point of view (we do not need to change init.bluetooth.rc, no
special build flags and logcat still shows bluetoothd as tagname).

Andrzej Kaczmarek (1):
  android: Add support for Valgrind in debug variants

 android/Android.mk           | 42 +++++++++++++++++++++++++++++
 android/bluetoothd-wrapper.c | 63 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 105 insertions(+)
 create mode 100644 android/bluetoothd-wrapper.c

-- 
1.8.5.3


^ permalink raw reply

* Re: [PATCH 06/13] android/handsfree: Add SDP record for AG
From: Szymon Janc @ 2014-02-05  9:10 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <20140203075616.GB2930@aemeltch-MOBL1>

Hi Andrei,

On Monday 03 of February 2014 09:56:18 Andrei Emeltchenko wrote:
> Hi Szymon,
> 
> On Sun, Feb 02, 2014 at 10:09:17PM +0100, Szymon Janc wrote:
> > Service Name: Hands-Free Audio GatewayService RecHandle: 0x10001
> > Service Class ID List:
> >   "Handsfree Audio Gateway" (0x111f)
> >   "Generic Audio" (0x1203)
> > Protocol Descriptor List:
> >   "L2CAP" (0x0100)
> >   "RFCOMM" (0x0003)
> >     Channel: 13
> > Profile Descriptor List:
> >   "Handsfree" (0x111e)
> >     Version: 0x0106
> > ---
> >  android/handsfree.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 97 insertions(+)
> > 
> > diff --git a/android/handsfree.c b/android/handsfree.c
> > index 3c0d52b..d2dc543 100644
> > --- a/android/handsfree.c
> > +++ b/android/handsfree.c
> > @@ -29,12 +29,19 @@
> >  #include <glib.h>
> >  
> >  #include "lib/bluetooth.h"
> > +#include "lib/sdp.h"
> > +#include "lib/sdp_lib.h"
> >  #include "handsfree.h"
> > +#include "bluetooth.h"
> >  #include "src/log.h"
> >  #include "hal-msg.h"
> >  #include "ipc.h"
> >  
> > +#define HFP_AG_CHANNEL 13
> > +#define HFP_AG_FEATURES 0
> > +
> >  static bdaddr_t adapter_addr;
> > +static uint32_t record_id = 0;
> >  
> >  static void handle_connect(const void *buf, uint16_t len)
> >  {
> > @@ -189,12 +196,99 @@ static const struct ipc_handler cmd_handlers[] = {
> >  			sizeof(struct hal_cmd_handsfree_phone_state_change)},
> >  };
> >  
> > +static sdp_record_t *handsfree_ag_record(void)
> > +{
> > +	sdp_list_t *svclass_id, *pfseq, *apseq, *root;
> > +	uuid_t root_uuid, svclass_uuid, ga_svclass_uuid;
> > +	uuid_t l2cap_uuid, rfcomm_uuid;
> > +	sdp_profile_desc_t profile;
> > +	sdp_list_t *aproto, *proto[2];
> > +	sdp_record_t *record;
> > +	sdp_data_t *channel, *features;
> > +	uint8_t netid = 0x01;
> > +	uint16_t sdpfeat;
> > +	sdp_data_t *network;
> > +	uint8_t ch = HFP_AG_CHANNEL;
> > +
> > +	record = sdp_record_alloc();
> > +	if (!record)
> > +		return NULL;
> > +
> > +	network = sdp_data_alloc(SDP_UINT8, &netid);
> > +	if (!network) {
> > +		sdp_record_free(record);
> > +		return NULL;
> > +	}
> > +
> > +	sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
> > +	root = sdp_list_append(0, &root_uuid);
> > +	sdp_set_browse_groups(record, root);
> > +
> > +	sdp_uuid16_create(&svclass_uuid, HANDSFREE_AGW_SVCLASS_ID);
> > +	svclass_id = sdp_list_append(0, &svclass_uuid);
> > +	sdp_uuid16_create(&ga_svclass_uuid, GENERIC_AUDIO_SVCLASS_ID);
> > +	svclass_id = sdp_list_append(svclass_id, &ga_svclass_uuid);
> > +	sdp_set_service_classes(record, svclass_id);
> > +
> > +	sdp_uuid16_create(&profile.uuid, HANDSFREE_PROFILE_ID);
> > +	profile.version = 0x0106;
> > +	pfseq = sdp_list_append(0, &profile);
> > +	sdp_set_profile_descs(record, pfseq);
> > +
> > +	sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
> > +	proto[0] = sdp_list_append(0, &l2cap_uuid);
> > +	apseq = sdp_list_append(0, proto[0]);
> > +
> > +	sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
> > +	proto[1] = sdp_list_append(0, &rfcomm_uuid);
> > +	channel = sdp_data_alloc(SDP_UINT8, &ch);
> > +	proto[1] = sdp_list_append(proto[1], channel);
> > +	apseq = sdp_list_append(apseq, proto[1]);
> > +
> > +	sdpfeat = HFP_AG_FEATURES;
> > +	features = sdp_data_alloc(SDP_UINT16, &sdpfeat);
> > +	sdp_attr_add(record, SDP_ATTR_SUPPORTED_FEATURES, features);
> > +
> > +	aproto = sdp_list_append(0, apseq);
> > +	sdp_set_access_protos(record, aproto);
> > +
> > +	sdp_set_info_attr(record, "Hands-Free Audio Gateway", 0, 0);
> > +
> > +	sdp_attr_add(record, SDP_ATTR_EXTERNAL_NETWORK, network);
> > +
> > +	sdp_data_free(channel);
> > +	sdp_list_free(proto[0], 0);
> 
> We have agreed to use NULL for zero pointers.

I've miss that comment, but this is now fixed by follow-up patch. 

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* Re: [PATCH 00/13] Initial code for handsfree support
From: Szymon Janc @ 2014-02-05  9:10 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391375364-27106-1-git-send-email-szymon.janc@tieto.com>

On Sunday 02 of February 2014 22:09:11 Szymon Janc wrote:
> Hi,
> 
> This adds initial support for HFP. HAL library is complete, for daemon
> only support for RFCOMM connection handling.
> 
> There is also minimal set of AT handling needed for SLC establishment
> (proper AT parsing code is still missing).
> 
> Comments are welcome.
> 
> BR
> Szymon Janc
> 
> Szymon Janc (13):
>   android/handsfree: Add initial files
>   android/handsfree: Add commands and events definition to IPC header
>   android/handsfree: Add stubs for commands handlers
>   android/hal-handsfree: Implement notifications handling
>   android/hal-handsfree: Implement sending commands
>   android/handsfree: Add SDP record for AG
>   android/handsfree: Add support for RFCOMM connection handling
>   android/handsfree: Add initial code for AT commands processing
>   android/handsfree: Add connect command handling
>   android/handsfree: Add disconnect command handling
>   android/handsfree: Add AT+BRSF command support
>   android/handsfree: Add support for AT+CIND command
>   android/handsfree: Add support for AT+CMER command
> 
>  android/Android.mk      |   2 +
>  android/Makefile.am     |   4 +
>  android/hal-bluetooth.c |   3 +
>  android/hal-handsfree.c | 598 +++++++++++++++++++++++++++++++++++++
>  android/hal-msg.h       | 208 +++++++++++++
>  android/hal.h           |   2 +
>  android/handsfree.c     | 763 ++++++++++++++++++++++++++++++++++++++++++++++++
>  android/handsfree.h     |  25 ++
>  android/main.c          |  14 +
>  9 files changed, 1619 insertions(+)
>  create mode 100644 android/hal-handsfree.c
>  create mode 100644 android/handsfree.c
>  create mode 100644 android/handsfree.h
> 
> 

Patches 1-10 are now pushed.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* Re: [PATCH v2 1/3] android/bluetooth: Add threshold to RSSI change
From: Szymon Janc @ 2014-02-05  8:48 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1391531663-13143-1-git-send-email-szymon.janc@tieto.com>

On Tuesday 04 of February 2014 17:34:21 Szymon Janc wrote:
> There is no need to report very small RSSI changes.
> ---
> v2: Fix name and use abs()
> 
>  android/bluetooth.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index d74d792..5aed4af 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -1045,6 +1045,12 @@ static uint8_t bdaddr_type2android(uint8_t type)
>  	return HAL_TYPE_LE;
>  }
>  
> +static bool rssi_above_threshold(int old, int new)
> +{
> +	/* only 8 dBm or more */
> +	return abs(old - new) >= 8;
> +}
> +
>  static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
>  					int8_t rssi, bool confirm,
>  					const uint8_t *data, uint8_t data_len)
> @@ -1113,7 +1119,7 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
>  		(*num_prop)++;
>  	}
>  
> -	if (rssi) {
> +	if (rssi && rssi_above_threshold(dev->rssi, rssi)) {
>  		dev->rssi = rssi;
>  
>  		size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_RSSI,
> 

Pushed.

-- 
Best regards, 
Szymon Janc

^ permalink raw reply

* Re: possible bug in blueZ 5.8 gatt tool or library
From: Anderson Lizardo @ 2014-02-04 23:05 UTC (permalink / raw)
  To: Caleb Reinhold; +Cc: BlueZ development
In-Reply-To: <000201cf21ed$d18f02d0$74ad0870$@lampreynetworks.com>

Hi Caleb,

On Tue, Feb 4, 2014 at 5:12 PM, Caleb Reinhold
<creinhold@lampreynetworks.com> wrote:
> We are working with the 5.8 version of the library, kernel version 3.12.9,
> bluetoothctl, and gatttool when we encountered a possible error.
> We expected on the reconnection of two bonded devices, one of which had
> stored measurements, that data would transfer. When running gatt tool in
> medium security the first measurement to be indicated was lost.

First of all, gatttool is a developer tool, and it is far from being a
compliant GATT endpoint (e.g. it does not report to requests, which is
mandatory by the spec). With moderate effort though, the missing
features can be added.

> However upon attempting to reconnect to the simulated agent device with
> medium security two unexpected behaviors occurred. First, and more
> immediately apparent was that the simulated agent did not receive a
> confirmation of the indication. A slightly closer look using the hcidump,
> trying to find what had happened, showed that the indication had arrived at
> the hci layer but was not received at events_handler.

Are you using gatttool in interactive mode (i.e. the -I option) ? If
yes, try first connecting to the device with "connect" followed by
setting the security level to medium with "sec-level medium". This
will imitate the behavior of the BlueZ daemon when connecting to LE
devices. Also be sure to use the "--listen" option so the confirmation
is sent by gatttool.

Let us know if it works :)

> While the indication
> is sent very swiftly upon the reconnection of the devices we understand this
> to be the manner in which low energy devices are supposed to behave given
> stored measurements and a bonded device.

You are correct that this is the expected behavior. But gatttool is
far from perfect. Did you try implementing a BlueZ plugin?

Best Regards,
-- 
Anderson Lizardo
http://www.indt.org/?lang=en
INdT - Manaus - Brazil

^ 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