* [PATCH] Allow disable park state in main.conf
@ 2010-02-26 13:32 Liang Bao
2010-02-26 14:38 ` Johan Hedberg
0 siblings, 1 reply; 4+ messages in thread
From: Liang Bao @ 2010-02-26 13:32 UTC (permalink / raw)
To: linux-bluetooth
[-- Attachment #1: Type: text/plain, Size: 5652 bytes --]
Currently BlueZ is reading a bunch of configuration from main.conf.
However it hard-codes the default link policy to enable role switch,
hold mode, park state and sniff mode. We've found that there're some
Bluetooth devices such as Motorola HF850 can't work well when park
state is enabled. Once the link is parked, the Motorola HF850 car-kit
will fail to unpark and lose connection. After that the car-kit will
keep re-connect and disconnect. Also, if it's the remote device who
initiates connection, the connection will be stable but once the link
is in park state, the SCO connection can't be setup. Feedback from
accessory team is that park state often causes some interoperability
problem so it's used rarely now.
Because these devices have been available on market, one option is to
turn off park state on the phone side. Instead of making a blacklist
to include devices who have problem with park state, adding a single
configuration item to disable park state will provide the flexibility
with limited change. Default value for this configuration item will be
false to keep current behavior unchanged.
Here's the log captured with the HF850 and a Droid phone. Note
entering park state at 14:58:40.534427 and the connection timeout at
2010-01-05 14:58:46.372714. The Droid will keep entering park state,
detect timeout and accept re-connection.
2010-01-05 14:58:34.456210 > HCI Event: Mode Change (0x14) plen 6
status 0x00 handle 1 mode 0x02 interval 2048
Mode: Sniff
2010-01-05 14:58:34.940677 > ACL data: handle 1 flags 0x02 dlen 19
L2CAP(d): cid 0x0041 len 15 [psm 3]
RFCOMM(d): UIH: cr 1 dlci 20 pf 1 ilen 10 fcs 0x2d credits 1
A T + N R E C = 0 .
2010-01-05 14:58:34.951480 < ACL data: handle 1 flags 0x02 dlen 14
L2CAP(d): cid 0x004d len 10 [psm 3]
RFCOMM(d): UIH: cr 0 dlci 20 pf 0 ilen 6 fcs 0xeb
. . O K . .
2010-01-05 14:58:36.217044 > HCI Event: Number of Completed Packets
(0x13) plen 5
handle 1 packets 1
2010-01-05 14:58:37.500095 > ACL data: handle 1 flags 0x02 dlen 19
L2CAP(d): cid 0x0041 len 15 [psm 3]
RFCOMM(d): UIH: cr 1 dlci 20 pf 1 ilen 10 fcs 0x2d credits 1
A T + C C W A = 1 .
2010-01-05 14:58:37.506900 < ACL data: handle 1 flags 0x02 dlen 14
L2CAP(d): cid 0x004d len 10 [psm 3]
RFCOMM(d): UIH: cr 0 dlci 20 pf 0 ilen 6 fcs 0xeb
. . O K . .
2010-01-05 14:58:38.777072 > HCI Event: Number of Completed Packets
(0x13) plen 5
handle 1 packets 1
2010-01-05 14:58:40.062412 > HCI Event: Mode Change (0x14) plen 6
status 0x00 handle 1 mode 0x00 interval 0
Mode: Active
2010-01-05 14:58:40.534427 > HCI Event: Mode Change (0x14) plen 6
status 0x00 handle 1 mode 0x03 interval 1152
Mode: Park
2010-01-05 14:58:46.372714 > HCI Event: Disconn Complete (0x05) plen 4
status 0x00 handle 1 reason 0x08
Reason: Connection Timeout
2010-01-05 14:58:47.689975 > HCI Event: Connect Request (0x04) plen 10
bdaddr 00:50:CD:20:BA:E6 class 0x200404 type ACL
2010-01-05 14:58:47.690097 < HCI Command: Accept Connection Request
(0x01|0x0009) plen 7
bdaddr 00:50:CD:20:BA:E6 role 0x00
Role: Master
2010-01-05 14:58:47.690616 > HCI Event: Command Status (0x0f) plen 4
Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1
2010-01-05 14:58:47.851596 > HCI Event: Role Change (0x12) plen 8
status 0x00 bdaddr 00:50:CD:20:BA:E6 role 0x00
Role: Master
2010-01-05 14:58:47.961978 > HCI Event: Link Key Request (0x17) plen 6
bdaddr 00:50:CD:20:BA:E6
2010-01-05 14:58:47.963748 < HCI Command: Link Key Request Reply
(0x01|0x000b) plen 22
bdaddr 00:50:CD:20:BA:E6 key 9752FA7985E81F9282DCDD80FB9C2B40
2010-01-05 14:58:47.964450 > HCI Event: Command Complete (0x0e) plen 10
Link Key Request Reply (0x01|0x000b) ncmd 1
status 0x00 bdaddr 00:50:CD:20:BA:E6
2010-01-05 14:58:48.076389 > HCI Event: Connect Complete (0x03) plen 11
status 0x00 handle 1 bdaddr 00:50:CD:20:BA:E6 type ACL encrypt 0x01
2010-01-05 14:58:48.076541 < HCI Command: Read Remote Supported
Features (0x01|0x001b) plen 2
handle 1
2010-01-05 14:58:48.076602 > HCI Event: Page Scan Repetition Mode
Change (0x20) plen 7
bdaddr 00:50:CD:20:BA:E6 mode 1
2010-01-05 14:58:48.077579 > HCI Event: Command Status (0x0f) plen 4
Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
2010-01-05 14:58:48.079257 > HCI Event: Max Slots Change (0x1b) plen 3
handle 1 slots 5
2010-01-05 14:58:48.079776 > ACL data: handle 1 flags 0x02 dlen 12
L2CAP(s): Connect req: psm 1 scid 0x004e
2010-01-05 14:58:48.079898 < ACL data: handle 1 flags 0x02 dlen 16
L2CAP(s): Connect rsp: dcid 0x0040 scid 0x004e result 1 status 0
Connection pending - No futher information available
2010-01-05 14:58:48.079959 < ACL data: handle 1 flags 0x02 dlen 10
L2CAP(s): Info req: type 2
2010-01-05 14:58:48.083896 > HCI Event: Number of Completed Packets
(0x13) plen 5
handle 1 packets 2
2010-01-05 14:58:48.092990 > HCI Event: Read Remote Supported Features
(0x0b) plen 11
status 0x00 handle 1
Features: 0xff 0xff 0x8f 0xf8 0x18 0x18 0x00 0x80
2010-01-05 14:58:48.098422 < HCI Command: Remote Name Request
(0x01|0x0019) plen 10
bdaddr 00:50:CD:20:BA:E6 mode 2 clkoffset 0x0000
2010-01-05 14:58:48.098941 > HCI Event: Command Status (0x0f) plen 4
Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
2010-01-05 14:58:48.101444 > ACL data: handle 1 flags 0x02 dlen 16
L2CAP(s): Info rsp: type 2 result 0
Extended feature mask 0x0000
2010-01-05 14:58:48.101596 < ACL data: handle 1 flags 0x02 dlen 16
L2CAP(s): Connect rsp: dcid 0x0040 scid 0x004e result 0 status 0
Connection successful
[-- Attachment #2: 0001-Allow-disable-park-state-in-main.conf.patch --]
[-- Type: text/x-diff, Size: 2182 bytes --]
From 331b120153c04694c73556c0287456a11874251f Mon Sep 17 00:00:00 2001
From: Tim Bao <tim.bao@gmail.com>
Date: Wed, 24 Feb 2010 20:48:29 +0800
Subject: [PATCH] Allow disable park state in main.conf
Currently BlueZ is hard-coding the default link policy to include
hold mode, role switch, sniff mode and park state. However, some
device will have problem to maintain the connection or setup SCO
if they are in park state. Making the park state configurable in
main.conf improves flexibility so it can be disabled when needed.
Signed-off-by: Tim Bao <tim.bao@gmail.com>
---
src/main.c | 13 +++++++++----
src/main.conf | 5 +++++
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/main.c b/src/main.c
index 014d8b6..977c87b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -201,10 +201,12 @@ static void parse_config(GKeyFile *config)
else
main_opts.name_resolv = boolean;
- main_opts.link_mode = HCI_LM_ACCEPT;
-
- main_opts.link_policy = HCI_LP_RSWITCH | HCI_LP_SNIFF |
- HCI_LP_HOLD | HCI_LP_PARK;
+ boolean = g_key_file_get_boolean(config, "General",
+ "DisableParkState", &err);
+ if (err)
+ g_clear_error(&err);
+ else if (boolean)
+ main_opts.link_policy &= (~HCI_LP_PARK);
}
/*
@@ -276,6 +278,9 @@ static void init_defaults(void)
main_opts.remember_powered = TRUE;
main_opts.reverse_sdp = TRUE;
main_opts.name_resolv = TRUE;
+ main_opts.link_mode = HCI_LM_ACCEPT;
+ main_opts.link_policy = HCI_LP_RSWITCH | HCI_LP_SNIFF |
+ HCI_LP_HOLD | HCI_LP_PARK;
if (gethostname(main_opts.host_name, sizeof(main_opts.host_name) - 1) < 0)
strcpy(main_opts.host_name, "noname");
diff --git a/src/main.conf b/src/main.conf
index b252a82..6f975fc 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -50,3 +50,8 @@ ReverseServiceDiscovery = true
# Enable name resolving after inquiry. Set it to 'false' if you don't need
# remote devices name and want shorter discovery cycle. Defaults to 'true'.
NameResolving = true
+
+# Disable park state in default link policy. Some devices have connection
+# stability issue or fail to setup SCO when the link is in park state. Defaults
+# to 'false'.
+DisableParkState = false
--
1.5.6.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow disable park state in main.conf
2010-02-26 13:32 [PATCH] Allow disable park state in main.conf Liang Bao
@ 2010-02-26 14:38 ` Johan Hedberg
0 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2010-02-26 14:38 UTC (permalink / raw)
To: Liang Bao, marcel; +Cc: linux-bluetooth
Hi,
On Fri, Feb 26, 2010, Liang Bao wrote:
> Currently BlueZ is hard-coding the default link policy to include
> hold mode, role switch, sniff mode and park state. However, some
> device will have problem to maintain the connection or setup SCO
> if they are in park state. Making the park state configurable in
> main.conf improves flexibility so it can be disabled when needed.
>
> Signed-off-by: Tim Bao <tim.bao@gmail.com>
> ---
> src/main.c | 13 +++++++++----
> src/main.conf | 5 +++++
> 2 files changed, 14 insertions(+), 4 deletions(-)
In principle the patch looks ok to me, however we might want to discuss
a little bit about the naming of the parameter in the config file and
its possible values. E.g. would it make sense to be able to define the
link policy more flexibly than just toggling park mode on and off.
Marcel, do you have any thoughts on this?
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow disable park state in main.conf
@ 2010-02-26 15:11 Bao Liang
2010-03-05 12:23 ` Liang Bao
0 siblings, 1 reply; 4+ messages in thread
From: Bao Liang @ 2010-02-26 15:11 UTC (permalink / raw)
To: Johan Hedberg, marcel; +Cc: linux-bluetooth
Thanks for your comment . The reason I do this is that only park mode makes=
trouble when used by certain models as far as I know . But I'm open to m=
ake this parameter an hex value if it make more sense .
----- =E5=8E=9F=E5=A7=8B=E9=82=AE=E4=BB=B6 -----
=E5=8F=91=E4=BB=B6=E4=BA=BA: Johan Hedberg <johan.hedberg@gmail.com>
=E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2010=E5=B9=B42=E6=9C=8826=E6=97=A5 22=
:38
=E6=94=B6=E4=BB=B6=E4=BA=BA: Liang Bao <tim.bao@gmail.com>; marcel@holtmann=
.org
=E6=8A=84=E9=80=81: linux-bluetooth@vger.kernel.org
=E4=B8=BB=E9=A2=98: Re: [PATCH] Allow disable park state in main.conf
Hi,
On Fri, Feb 26, 2010, Liang Bao wrote:
> Currently BlueZ is hard-coding the default link policy to include
> hold mode, role switch, sniff mode and park state. However, some
> device will have problem to maintain the connection or setup SCO
> if they are in park state. Making the park state configurable in
> main.conf improves flexibility so it can be disabled when needed.
>=20
> Signed-off-by: Tim Bao <tim.bao@gmail.com>
> ---
> src/main.c | 13 +++++++++----
> src/main.conf | 5 +++++
> 2 files changed, 14 insertions(+), 4 deletions(-)
In principle the patch looks ok to me, however we might want to discuss
a little bit about the naming of the parameter in the config file and
its possible values. E.g. would it make sense to be able to define the
link policy more flexibly than just toggling park mode on and off.
Marcel, do you have any thoughts on this?
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow disable park state in main.conf
2010-02-26 15:11 Bao Liang
@ 2010-03-05 12:23 ` Liang Bao
0 siblings, 0 replies; 4+ messages in thread
From: Liang Bao @ 2010-03-05 12:23 UTC (permalink / raw)
To: Johan Hedberg, marcel; +Cc: linux-bluetooth
We've changed to a hex value as "DefaultLinkPolicy" as following:
diff --git a/src/main.conf b/src/main.conf
index b03e169..196d703 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -50,3 +50,10 @@ ReverseServiceDiscovery = true
# Enable name resolving after inquiry. Set it to 'false' if you don't need
# remote devices name and want shorter discovery cycle. Defaults to 'true'.
NameResolving = true
+
+# The link policy for connections. By default it's set to 0x000f which is
+# a bitwise OR of role switch(0x0001), hold mode(0x0002), sniff mode(0x0004)
+# and park state(0x0008) are all enabled. However, some devices have
+# connection stability issue or fail to setup SCO when the link is in park
+# state, which requires park state bit cleared.
+DefaultLinkPolicy = 0x000f
Does this look better? If yes I can re-generate a patch and send in a
separate thread.
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-03-05 12:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-26 13:32 [PATCH] Allow disable park state in main.conf Liang Bao
2010-02-26 14:38 ` Johan Hedberg
-- strict thread matches above, loose matches on Subject: below --
2010-02-26 15:11 Bao Liang
2010-03-05 12:23 ` Liang Bao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox