Active Topics

 



Notices


Reply
Thread Tools
5spdvl's Avatar
Posts: 220 | Thanked: 66 times | Joined on Aug 2010 @ Melbourne, Australia
#391
I have the script I want to use, but I can't seem to get it to work with DCEW:

-trying to connect to a specific BT MAC address (Nokia BH-503 headphones)

I have tried this from karimko:
Originally Posted by karimko
Try this in xterm:

Code:
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
(http://talk.maemo.org/showpost.php?p=746631&postcount=4)

However, this only works once BT is on, and doesn't "genuinely connect" (status bar BT icon turns blue, but device does not respond/receive commands).

I have tried this:
Code:
adapter=$(dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdapter | awk -F'"' '/at/ {print $2}')
device=$(dbus-send --system --print-reply --dest=org.bluez ${adapter} org.bluez.Adapter.FindDevice string:${devmac} | awk -F'"' '/at/ {print $2}')
dbus-send --system --type=method_call --print-reply --dest=org.bluez ${device} org.bluez.${service}.Connect
...inside a script I called "headphones.sh", which I call inside DCEW via:

Code:
run-standalone.sh <directory>/headphones.sh
which does not work. My understanding of shell scripting is probably at fault - I created a notepad file in windows with the script code, saved it as headphones.sh(.txt), then transferred to my N900 and renamed it just headphones.sh.

Can anyone point me in the right direction? Nokia revised the programming for their BH-503 (board revision 3), and now I can't connect to my latest pair automatically (must access via the BT menu, despite being "trusted").
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#392
Originally Posted by 5spdvl View Post
which does not work. My understanding of shell scripting is probably at fault - I created a notepad file in windows with the script code, saved it as headphones.sh(.txt), then transferred to my N900 and renamed it just headphones.sh.
Maybe wrong line endings dos/unix ?
Run the script from the commandline and post the error messages.
 

The Following User Says Thank You to nicolai For This Useful Post:
5spdvl's Avatar
Posts: 220 | Thanked: 66 times | Joined on Aug 2010 @ Melbourne, Australia
#393
Code:
~ $ sh /home/user/MyDocs/headphones.sh
: not foundMyDocs/headphones.sh: line 2: /home/user/MyDocs/headphones.sh: line 4: syntax error: Bad substitution
I've attached my headphones.sh script. My shell scripting knowledge is pretty limited, but unlike others that just ask how at least I come prepared with some effort!

Edit: I know it says .sh.txt, but it's been renamed via FileBox on my N900 .sh.

2nd edit: if someone can recommend a program (Win7 or Maemo) that I can use for writing shell scripts that will save with the correct file extension, I'm all for it.
Attached Files
File Type: txt headphones.sh.txt (393 Bytes, 87 views)

Last edited by 5spdvl; 2011-10-27 at 08:55.
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#394
Try this one.
I removed the DOS lineendings and removed the ${..} around
your mac address (this was the "bad substitution" error)
Attached Files
File Type: txt headphones2.sh.txt (391 Bytes, 103 views)
 

The Following User Says Thank You to nicolai For This Useful Post:
5spdvl's Avatar
Posts: 220 | Thanked: 66 times | Joined on Aug 2010 @ Melbourne, Australia
#395
Thanks a lot nicolai, I really appreciate it.

Code:
~ $ sh /home/user/MyDocs/headphones2.sh
process 27316: arguments to dbus_message_new_method_call() were incorrect, assertion "interface == NULL || _dbus_check_is_valid_interface (interface)" failed in file dbus-message.c line 1080.
This is normally a bug in some application using the D-Bus library.
process 27316: arguments to dbus_message_set_auto_start() were incorrect, assertion "message != NULL" failed in file dbus message.c line 2492.
This is normalle a bug in some application using the D-Bus library.
Couldn't allocate D-Bus message
~ $
So what I gather from that is my method of calling the script via xterm is now correct (thanks to you, nicolai), however the code of the script appears to be erroneous.
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#396
I found a similiar script at the phone control wiki entry.
http://wiki.maemo.org/Phone_control#...pecific_device
There are two variables are defined, one for the MAC
and one for the service.

In your script you missed the "service" variable, too.
I changed your code and put the "AudioSink" value in the
dbus call.
Attached Files
File Type: txt headphones3.sh.txt (390 Bytes, 93 views)
 

The Following User Says Thank You to nicolai For This Useful Post:
5spdvl's Avatar
Posts: 220 | Thanked: 66 times | Joined on Aug 2010 @ Melbourne, Australia
#397
Ah! I had "AutoSink" in there (I know you can put any service in that string, but I wasn't sure what the available options are, or which one I needed).

Code:
~ $ sh /home/user/MyDocs/headphones3.sh
Error org.bluez.Error.Failed: Failed to create a stream
Same again, but this time with BT already on:

Code:
~ $ sh /home/user/MyDocs/headphones3.sh
Error org.bluez.Error.Failed: Stream setup failed
Same again, but this time with BT already on, and headphones awaiting pairing:

Code:
~ $ sh /home/user/MyDocs/headphones3.sh
method return sender=:1.32 -> dest=:1.639 reply_serial=2
Success! Connects as per normal, streams audio under AD2P profile. Only issue is now having to turn BT on first. Again, thanks for you help nicolai!

In DCEW, using

Code:
sh /home/user/MyDocs/headphones3.sh
successfully pairs with the headphones when both the N900/BH-503 are awaiting connection.

Any ideas on having the script also turn BT on (N900) before it attempts connection?

I write a script with the content

Code:
dbus-send --system --type=method_call --dest=org.bluez /org/bluez/906/hci0 org.bluez.Adaptor.SetProperty string:Powered variant:boolean:true
and tried it via xterm

Code:
sh /home/user/MyDocs/Bton.sh
which executes fine, but doesn't turn BT on or leave any comments in xterm.

Last edited by 5spdvl; 2011-10-27 at 10:33.
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#398
Again :-)
Phone control wiki:
http://wiki.maemo.org/Phone_control#Enable

I added the "enable" dbus-call command to your script.

Nicolai
Attached Files
File Type: txt headphones4.sh.txt (522 Bytes, 103 views)
 

The Following User Says Thank You to nicolai For This Useful Post:
5spdvl's Avatar
Posts: 220 | Thanked: 66 times | Joined on Aug 2010 @ Melbourne, Australia
#399
Excellent. Perfect Nicolai.

I had some trouble opening the phone Control wiki page for a few minutes there, but found the enable code right when you posted. But as above my little script didn't enable it. Guess it's the way you've inserted the enable command within the rest of the script.

So, problem solved. now to make a fancy button.
 
5spdvl's Avatar
Posts: 220 | Thanked: 66 times | Joined on Aug 2010 @ Melbourne, Australia
#400
Actually, it seems to keep turning BT on now. Which is odd, because it's only when the DCEW is placed on the desktop, yet without pushing on it. Like it's running the script without being called?

Edit: unchecked "Update when switched to the desktop", now it behaves normally (turns BT on only when called).

Edit: does not connect to defined MAC address after being called. Buuuuuuuut it helps when I put the right MAC in. D'oh!

Last edited by 5spdvl; 2011-10-27 at 10:59.
 
Reply


 
Forum Jump


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