maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Command to force connect to a bluetooth device (https://talk.maemo.org/showthread.php?t=50077)

phedders 2010-04-15 08:19

Command to force connect to a bluetooth device
 
My Sony/Ford car stereo does bluetooth. But it's a pain.

Up until two days ago, it would always connect fine when turned on. And HFP worked just fine for calls - very well actually.

A2DP was a different story. First try worked brilliantly. Worked great for a day. Then would only work occasionally - sometimes if I flicked from phone to stream on the stereo it would work. Mostly the phone would be sending data and it would just be silent, or the stereo would silently drop the link.

Two days ago I got Fraud to update the firmware (why can I not do that? It's MY car you theives.)

Now A2DP works more often - normally after flicking from phone mode and back. But it fails to auto connect - or rather it does try to auto connect, but then drops the link (it does now say "link dropped") so I have to dive through menus on the phone to reconnect... it will often fail once more, then work fine.

So I want to write a script that can be called from a DCE button to initiate a connection (and I'll write a dbus-scripts script to do it on failure too!) but how?

Can I send a dbus-command?

dbus-monitor reveals this chain of stuff happenning when I hit connect:

signal sender=:1.37 -> dest=(null destination) serial=1336 path=/org/bluez/1052/hci0/dev_00_1E_A4_FF_D8_BE; interface=org.bluez.Device; member=PropertyChanged
string "Connected"
variant boolean true
signal sender=:1.91 -> dest=(null destination) serial=190 path=/org/kernel/class/bluetooth/hci0/hci0_11; interface=org.kernel.kevent; member=add
signal sender=:1.37 -> dest=(null destination) serial=1337 path=/org/bluez/1052/hci0/dev_00_1E_A4_FF_D8_BE; interface=org.bluez.AudioSink; member=PropertyChanged
string "State"
variant string "connecting"
signal sender=:1.37 -> dest=(null destination) serial=1338 path=/org/bluez/1052/hci0/dev_00_1E_A4_FF_D8_BE; interface=org.bluez.Audio; member=PropertyChanged
string "State"
variant string "connecting"
signal sender=:1.91 -> dest=(null destination) serial=191 path=/org/kernel/class/input/input11; interface=org.kernel.kevent; member=add
signal sender=:1.91 -> dest=(null destination) serial=192 path=/org/kernel/class/input/input11/event4; interface=org.kernel.kevent; member=add
signal sender=:1.37 -> dest=(null destination) serial=1342 path=/org/bluez/1052/hci0/dev_00_1E_A4_FF_D8_BE; interface=org.bluez.Control; member=Connected
signal sender=:1.37 -> dest=(null destination) serial=1343 path=/org/bluez/1052/hci0/dev_00_1E_A4_FF_D8_BE; interface=org.bluez.Control; member=PropertyChanged

Can I use any of that?

Just found and checking: http://maemo.org/api_refs/5.0/5.0-fi...ontrol-api.txt - may help me...

EDIT

Seems like the command I need is:

Code:

dbus-send --system --print-reply --type=method_call --dest=org.bluez /org/bluez/1069/hci0/dev_00_1E_A4_FF_D8_BE.Connect
This page is really helpful: http://wiki.bluez.org/wiki/HOWTO/AudioDevices...

A more full script could be written using:

Code:

devmac=00:1E:A4:FF:D8:BE

adapter=$(dbus-send --print-reply --system --dest=org.bluez / org.bluez.Manager.DefaultAdapter| sed -ne "s/^.*object path //p"|sed -e 's/"//g')
device=$(dbus-send --print-reply --system --dest=org.bluez ${adapter} org.bluez.Adapter.FindDevice string:${devmac}|sed -ne "s/^.*object path //p"|sed -e 's/"//g')
dbus-send --system --print-reply --type=method_call --dest=org.bluez ${device} org.bluez.AudioSink.Connect

(Change the AudoSink to whatever service you want, and the devmac to the mac of your bluetooth headset,stereo,computer,teddybear...)

No!No!No!Yes! 2010-04-23 13:39

Re: Command to force connect to a bluetooth device
 
Quote:

Originally Posted by phedders (Post 611453)
My Sony/Ford car stereo does bluetooth. But it's a pain.

Up until two days ago, it would always connect fine when turned on. And HFP worked just fine for calls - very well actually.

A2DP was a different story. First try worked brilliantly. Worked great for a day. Then would only work occasionally - sometimes if I flicked from phone to stream on the stereo it would work. Mostly the phone would be sending data and it would just be silent, or the stereo would silently drop the link.

Two days ago I got Fraud to update the firmware (why can I not do that? It's MY car you theives.)

Now A2DP works more often - normally after flicking from phone mode and back. But it fails to auto connect - or rather it does try to auto connect, but then drops the link (it does now say "link dropped") so I have to dive through menus on the phone to reconnect... it will often fail once more, then work fine.

So I want to write a script that can be called from a DCE button to initiate a connection (and I'll write a dbus-scripts script to do it on failure too!) but how?

Can I send a dbus-command?

dbus-monitor reveals this chain of stuff happenning when I hit connect:

signal sender=:1.37 -> dest=(null destination) serial=1336 path=/org/bluez/1052/hci0/dev_00_1E_A4_FF_D8_BE; interface=org.bluez.Device; member=PropertyChanged
string "Connected"
variant boolean true
signal sender=:1.91 -> dest=(null destination) serial=190 path=/org/kernel/class/bluetooth/hci0/hci0_11; interface=org.kernel.kevent; member=add
signal sender=:1.37 -> dest=(null destination) serial=1337 path=/org/bluez/1052/hci0/dev_00_1E_A4_FF_D8_BE; interface=org.bluez.AudioSink; member=PropertyChanged
string "State"
variant string "connecting"
signal sender=:1.37 -> dest=(null destination) serial=1338 path=/org/bluez/1052/hci0/dev_00_1E_A4_FF_D8_BE; interface=org.bluez.Audio; member=PropertyChanged
string "State"
variant string "connecting"
signal sender=:1.91 -> dest=(null destination) serial=191 path=/org/kernel/class/input/input11; interface=org.kernel.kevent; member=add
signal sender=:1.91 -> dest=(null destination) serial=192 path=/org/kernel/class/input/input11/event4; interface=org.kernel.kevent; member=add
signal sender=:1.37 -> dest=(null destination) serial=1342 path=/org/bluez/1052/hci0/dev_00_1E_A4_FF_D8_BE; interface=org.bluez.Control; member=Connected
signal sender=:1.37 -> dest=(null destination) serial=1343 path=/org/bluez/1052/hci0/dev_00_1E_A4_FF_D8_BE; interface=org.bluez.Control; member=PropertyChanged

Can I use any of that?

Just found and checking: http://maemo.org/api_refs/5.0/5.0-fi...ontrol-api.txt - may help me...

EDIT

Seems like the command I need is:

Code:

dbus-send --system --print-reply --type=method_call --dest=org.bluez /org/bluez/1069/hci0/dev_00_1E_A4_FF_D8_BE.Connect
This page is really helpful: http://wiki.bluez.org/wiki/HOWTO/AudioDevices...

A more full script could be written using:

Code:

devmac=00:1E:A4:FF:D8:BE

adapter=$(dbus-send --print-reply --system --dest=org.bluez / org.bluez.Manager.DefaultAdapter| sed -ne "s/^.*object path //p"|sed -e 's/"//g')
device=$(dbus-send --print-reply --system --dest=org.bluez ${adapter} org.bluez.Adapter.FindDevice string:${devmac}|sed -ne "s/^.*object path //p"|sed -e 's/"//g')
dbus-send --system --print-reply --type=method_call --dest=org.bluez ${device} org.bluez.AudioSink.Connect

(Change the AudoSink to whatever service you want, and the devmac to the mac of your bluetooth headset,stereo,computer,teddybear...)

Hi, may I ask you what ford/sony system you have?
I too have random connection issues between n900 and both Audio BT Aux and Bluetooth Phone.
Mine is Sony System on Ford Galaxy Cosmo 2K9
Where did you get new firmware?

coupas 2010-07-09 22:17

Re: Command to force connect to a bluetooth device
 
I am very interested in a script or whatever where I can force a connect to my mw600 SE headset.


I have to pair them manually each time. And also, after being in a call, audio is no longer sent to headset, need to re-pair them again.

If I could get that automatic somehow... or a quickbutton would suffice actually.

Recapping:

Force BT connect to existing headset.
Disconnect/reconnect fast.


Anyone able to do this, or lead me in the right way?

Thanks for reading.

karimko 2010-07-09 22:32

Re: Command to force connect to a bluetooth device
 
Try this in xterm:

rfcomm connect 0 <MAC_ADDRESS>

don't forget to have your bluetooth enabled and just replace <MAC_ADDRESS> with your car's stereo.

I have the same problem like you guys, except with a Kenwood :)

[EDIT]: You can use Desktop Command Execution widget with this command to have a shortcut on ur desktop :cool:

coupas 2010-07-09 22:44

Re: Command to force connect to a bluetooth device
 
Will that command reconnect if it's already connected by any chance?

And thanks! Will try it out.

christoph 2010-07-29 12:12

Re: Command to force connect to a bluetooth device
 
This script forces a disconnect and a reconnect:
http://talk.maemo.org/showpost.php?p...3&postcount=27

rajeshgklm 2013-11-08 00:49

Re: Command to force connect to a bluetooth device
 
Hello Phedders

The below script worked for me for connecting to my sennhieser MM100 bluetooth headset when i executed one by one in x-terminal.

devmac=00:1E:A4:FF:D8:BE

adapter=$(dbus-send --print-reply --system --dest=org.bluez / org.bluez.Manager.DefaultAdapter| sed -ne "s/^.*object path //p"|sed -e 's/"//g')
device=$(dbus-send --print-reply --system --dest=org.bluez ${adapter} org.bluez.Adapter.FindDevice

Please let me know how can i achieve this with Desktop Execution Command Widget

Thanks & Regards
Rajesh

nodevel 2013-11-08 01:29

Re: Command to force connect to a bluetooth device
 
Quote:

Originally Posted by rajeshgklm (Post 1385037)
Hello Phedders

Please let me know how can i achieve this with Desktop Execution Command Widget

Thanks & Regards
Rajesh

You can just connect commands by replacing the line breaks with '&&' - that way you can run multiple commands consequently on line line.

You could also try the Queen Beacon Widget as it allows multi line scripts.

rajeshgklm 2013-11-08 02:54

Re: Command to force connect to a bluetooth device
 
hello novdel,

Thanks for your great support.

It's not working for me. could you please ellaborate?

Regards
Rajesh R.

nodevel 2013-11-08 16:07

Re: Command to force connect to a bluetooth device
 
Hey Rajesh!

No problem, I'll describe it in detail.
The command you mentioned did not work for me with my Sennheiser MM400, so I'll use a command above that does work.

Instead of
Code:

devmac=FF:11:EE:22:DD:33

adapter=$(dbus-send --print-reply --system --dest=org.bluez / org.bluez.Manager.DefaultAdapter| sed -ne "s/^.*object path //p"|sed -e 's/"//g')
device=$(dbus-send --print-reply --system --dest=org.bluez ${adapter} org.bluez.Adapter.FindDevice string:${devmac}|sed -ne "s/^.*object path //p"|sed -e 's/"//g')
dbus-send --system --print-reply --type=method_call --dest=org.bluez ${device} org.bluez.AudioSink.Connect

...you can put this in the widget instead
Code:

devmac=FF:11:EE:22:DD:33 && adapter=$(dbus-send --print-reply --system --dest=org.bluez / org.bluez.Manager.DefaultAdapter| sed -ne "s/^.*object path //p"|sed -e 's/"//g') && device=$(dbus-send --print-reply --system --dest=org.bluez ${adapter} org.bluez.Adapter.FindDevice string:${devmac}|sed -ne "s/^.*object path //p"|sed -e 's/"//g') && dbus-send --system --print-reply --type=method_call --dest=org.bluez ${device} org.bluez.AudioSink.Connect
that fits the one line in the widget.

Alternatively you can install Queen Beacon Widget (QBW) - it works similarly to the Command Execution Widget, but is much more customizable - you can go advanced and put the multiline version of the command in. I'd recommend QBW for its flexibility. See the wiki page for more details.


All times are GMT. The time now is 05:01.

vBulletin® Version 3.8.8