Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ] core: retry connect_dbus() several times
@ 2014-02-28  7:09 Adam Lee
  2014-02-28  7:15 ` Marcel Holtmann
  0 siblings, 1 reply; 7+ messages in thread
From: Adam Lee @ 2014-02-28  7:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Marcel Holtmann

Sometimes the hardware, especially which needs firmware patching, is not
yet ready when connect_dbus().

Signed-off-by: Adam Lee <adam8157@gmail.com>
---
 src/main.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/main.c b/src/main.c
index b3136fc..cf1f8fa 100644
--- a/src/main.c
+++ b/src/main.c
@@ -491,6 +491,7 @@ int main(int argc, char *argv[])
 	GKeyFile *config;
 	guint signal, watchdog;
 	const char *watchdog_usec;
+	uint8_t reconnect_times = 3;
 
 	init_defaults();
 
@@ -527,9 +528,17 @@ int main(int argc, char *argv[])
 
 	parse_config(config);
 
-	if (connect_dbus() < 0) {
-		error("Unable to get on D-Bus");
-		exit(1);
+	/* Reconnect several times in case the hardware is not ready */
+	while (reconnect_times--) {
+		if (connect_dbus() == 0)
+			break;
+
+		if (reconnect_times != 1) {
+			usleep(500 * 1000);
+		} else {
+			error("Unable to get on D-Bus");
+			exit(1);
+		}
 	}
 
 	if (option_experimental)
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH BlueZ] core: retry connect_dbus() several times
  2014-02-28  7:09 [PATCH BlueZ] core: retry connect_dbus() several times Adam Lee
@ 2014-02-28  7:15 ` Marcel Holtmann
  2014-02-28  7:31   ` Adam Lee
  0 siblings, 1 reply; 7+ messages in thread
From: Marcel Holtmann @ 2014-02-28  7:15 UTC (permalink / raw)
  To: Adam Lee; +Cc: linux-bluetooth

Hi Adadm,

> Sometimes the hardware, especially which needs firmware patching, is not
> yet ready when connect_dbus().

this makes no sense. Connecting to D-Bus has nothing to do with firmware patching. What are you exactly fixing here?

Regards

Marcel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH BlueZ] core: retry connect_dbus() several times
  2014-02-28  7:15 ` Marcel Holtmann
@ 2014-02-28  7:31   ` Adam Lee
  2014-02-28  7:40     ` Marcel Holtmann
  2014-02-28 12:22     ` Anderson Lizardo
  0 siblings, 2 replies; 7+ messages in thread
From: Adam Lee @ 2014-02-28  7:31 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

On Thu, Feb 27, 2014 at 11:15:01PM -0800, Marcel Holtmann wrote:
> Hi Adadm,
> 
> > Sometimes the hardware, especially which needs firmware patching, is not
> > yet ready when connect_dbus().
> 
> this makes no sense. Connecting to D-Bus has nothing to do with
> firmware patching. What are you exactly fixing here?

connect_dbus() fails sometimes with Intel 7260 bluetooth, sleeping 0.5s
before executing bluetoothd workarounds it. I assume the firmware
patching slows down hardware initialization then fails to connect.

Any other possibility? I'm not a D-Bus guru :)

-- 
Adam Lee
http://adam8157.info

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH BlueZ] core: retry connect_dbus() several times
  2014-02-28  7:31   ` Adam Lee
@ 2014-02-28  7:40     ` Marcel Holtmann
  2014-02-28 12:22     ` Anderson Lizardo
  1 sibling, 0 replies; 7+ messages in thread
From: Marcel Holtmann @ 2014-02-28  7:40 UTC (permalink / raw)
  To: Adam Lee; +Cc: linux-bluetooth

Hi Adam,

>>> Sometimes the hardware, especially which needs firmware patching, is not
>>> yet ready when connect_dbus().
>> 
>> this makes no sense. Connecting to D-Bus has nothing to do with
>> firmware patching. What are you exactly fixing here?
> 
> connect_dbus() fails sometimes with Intel 7260 bluetooth, sleeping 0.5s
> before executing bluetoothd workarounds it. I assume the firmware
> patching slows down hardware initialization then fails to connect.
> 
> Any other possibility? I'm not a D-Bus guru :)

it has nothing to do with D-Bus. You need to find the root cause.

Regards

Marcel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH BlueZ] core: retry connect_dbus() several times
  2014-02-28  7:31   ` Adam Lee
  2014-02-28  7:40     ` Marcel Holtmann
@ 2014-02-28 12:22     ` Anderson Lizardo
  2014-02-28 14:10       ` Luiz Augusto von Dentz
  1 sibling, 1 reply; 7+ messages in thread
From: Anderson Lizardo @ 2014-02-28 12:22 UTC (permalink / raw)
  To: Adam Lee; +Cc: Marcel Holtmann, BlueZ development

Hi Adam,

On Fri, Feb 28, 2014 at 3:31 AM, Adam Lee <adam8157@gmail.com> wrote:
> connect_dbus() fails sometimes with Intel 7260 bluetooth, sleeping 0.5s
> before executing bluetoothd workarounds it. I assume the firmware
> patching slows down hardware initialization then fails to connect.
>
> Any other possibility? I'm not a D-Bus guru :)

Please provide more details, e.g. the bluetoothd logs showing the
problems, btmon output and which steps you are using to reproduce it.
If you are using bluetoothctl, tell us which commands you are using.

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH BlueZ] core: retry connect_dbus() several times
  2014-02-28 12:22     ` Anderson Lizardo
@ 2014-02-28 14:10       ` Luiz Augusto von Dentz
  2014-03-03  7:15         ` Adam Lee
  0 siblings, 1 reply; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2014-02-28 14:10 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: Adam Lee, Marcel Holtmann, BlueZ development

Hi Adam,

On Fri, Feb 28, 2014 at 1:22 PM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> Hi Adam,
>
> On Fri, Feb 28, 2014 at 3:31 AM, Adam Lee <adam8157@gmail.com> wrote:
>> connect_dbus() fails sometimes with Intel 7260 bluetooth, sleeping 0.5s
>> before executing bluetoothd workarounds it. I assume the firmware
>> patching slows down hardware initialization then fails to connect.
>>
>> Any other possibility? I'm not a D-Bus guru :)
>
> Please provide more details, e.g. the bluetoothd logs showing the
> problems, btmon output and which steps you are using to reproduce it.
> If you are using bluetoothctl, tell us which commands you are using.

My guess is that either your driver is not using .setup hook to do the
firmware patching or it is returning before it has fully initialize
the hardware, so please also add more information what is happening on
the driver side.


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH BlueZ] core: retry connect_dbus() several times
  2014-02-28 14:10       ` Luiz Augusto von Dentz
@ 2014-03-03  7:15         ` Adam Lee
  0 siblings, 0 replies; 7+ messages in thread
From: Adam Lee @ 2014-03-03  7:15 UTC (permalink / raw)
  To: Luiz Augusto von Dentz
  Cc: Anderson Lizardo, Marcel Holtmann, BlueZ development

On Fri, Feb 28, 2014 at 03:10:41PM +0100, Luiz Augusto von Dentz wrote:
> Hi Adam,
> 
> On Fri, Feb 28, 2014 at 1:22 PM, Anderson Lizardo
> <anderson.lizardo@openbossa.org> wrote:
> > Hi Adam,
> >
> > On Fri, Feb 28, 2014 at 3:31 AM, Adam Lee <adam8157@gmail.com> wrote:
> >> connect_dbus() fails sometimes with Intel 7260 bluetooth, sleeping 0.5s
> >> before executing bluetoothd workarounds it. I assume the firmware
> >> patching slows down hardware initialization then fails to connect.
> >>
> >> Any other possibility? I'm not a D-Bus guru :)
> >
> > Please provide more details, e.g. the bluetoothd logs showing the
> > problems, btmon output and which steps you are using to reproduce it.
> > If you are using bluetoothctl, tell us which commands you are using.
> 
> My guess is that either your driver is not using .setup hook to do the
> firmware patching or it is returning before it has fully initialize
> the hardware, so please also add more information what is happening on
> the driver side.

Hi, all

Please check https://bugs.launchpad.net/bugs/1221618

It's already fixed in btusb. However, if it's related to initialization
as Luiz and I guessed, maybe other hardwares have this issue too, that's
the reason I submitted that harmless retry "workaround" into BlueZ.
(have no objection to NAK)

-- 
Adam Lee
http://adam8157.info

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-03-03  7:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-28  7:09 [PATCH BlueZ] core: retry connect_dbus() several times Adam Lee
2014-02-28  7:15 ` Marcel Holtmann
2014-02-28  7:31   ` Adam Lee
2014-02-28  7:40     ` Marcel Holtmann
2014-02-28 12:22     ` Anderson Lizardo
2014-02-28 14:10       ` Luiz Augusto von Dentz
2014-03-03  7:15         ` Adam Lee

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