maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   [ANNOUNCE] mbluetoothd (https://talk.maemo.org/showthread.php?t=26809)

svs57 2009-02-27 08:08

Re: [ANNOUNCE] mbluetoothd
 
I install package dbus-scripts-settings 1.1 and set when my BT headphone connected start /usr/bin/kagu. When I connect headphone kagu doesn't start. How can I debug why?

I know that it is possible to connect headphone using script.
Can anybody show me how.
Sorry for stupid questions.

Matan 2009-02-27 09:37

Re: [ANNOUNCE] mbluetoothd
 
What is the content of /etc/dbus-scripts.d/dbus-scripts-settings ?

The script runs as root, so if kagu needs to run as a user, you need to write some script that will use su or sudo to run kagu.

The way I debug is always use a script, instead of using the program directly, and I include a line such as:

date >> /tmp/my.log

so I can at least tell if the script ran when it was supposed to.

svs57 2009-02-27 13:22

Re: [ANNOUNCE] mbluetoothd
 
I write 2 scrips for start and stop kagu and test it from root.
It works. But when device connected kagu doesn't start.

cat /etc/dbus-scripts.d/dbus-scripts-settings
/usr/local/bin/start-kagu * * org.bluez.Adapter RemoteDeviceConnected 00:0D:3C:A6:CC:13
/usr/local/bin/stop-kagu * * org.bluez.Adapter RemoteDeviceConnected 00:0D:3C:A6:CC:13

dbus-scripts --debug --system
Parsing conf file /etc/dbus-scripts.d/....
Parsing conf file /etc/dbus-scripts.d/.....
Parsing conf file /etc/dbus-scripts.d/dbus-scripts-settings...
Parsing conf file /etc/dbus-scripts.d/dbus-scripts-example...
Script file /usr/local/bin/start-kagu: arg 1 = *, arg 2 = *, arg 3 = org.bluez.Adapter, arg 4 = RemoteDeviceConnected, arg 5 = 00:0D:3C:A6:CC:13,
Script file /usr/local/bin/stop-kagu: arg 1 = *, arg 2 = *, arg 3 = org.bluez.Adapter, arg 4 = RemoteDeviceConnected, arg 5 = 00:0D:3C:A6:CC:13,
=================================
Arg 1: org.freedesktop.DBus
Arg 2: :1.351
Arg 3: org.freedesktop.DBus
Arg 4: NameAcquired
Arg 5: :1.351
=================================
Arg 1: :1.49
Arg 2: null
Arg 3: org.kernel.kevent
Arg 4: add
=================================
Arg 1: :1.32
Arg 2: null
Arg 3: org.bluez.Adapter
Arg 4: RemoteDeviceConnected
Arg 5: 00:0D:3C:A6:CC:13
Script /usr/local/bin/start-kagu matches
Script /usr/local/bin/stop-kagu matches
=================================
Arg 1: :1.33
Arg 2: null
Arg 3: com.nokia.btcond.signal
Arg 4: connection_status
Arg 5: 00:0D:3C:A6:CC:13
Arg 6: connected
=================================
Arg 1: :1.32
Arg 2: null
Arg 3: org.bluez.Adapter
Arg 4: RemoteNameUpdated
Arg 5: 00:0D:3C:A6:CC:13
Arg 6: Nokia BH-501
=================================
Arg 1: :1.33
Arg 2: null
Arg 3: com.nokia.btcond.signal
Arg 4: link_key_ok
Arg 5: 00:0D:3C:A6:CC:13
=================================
Arg 1: :1.34
Arg 2: null
Arg 3: org.bluez.audio.Headset
Arg 4: Connected
=================================
Arg 1: :1.11
Arg 2: null
Arg 3: org.freedesktop.DBus.Properties
Arg 4: Notify
Arg 5: com.nokia.bluez_headset_proxy
Arg 6: State
Arg 7: Connected
=================================
Arg 1: :1.49
Arg 2: null
Arg 3: org.kernel.kevent
Arg 4: add
=================================
Arg 1: :1.34
Arg 2: null
Arg 3: org.bluez.audio.Headset
Arg 4: Playing
=================================
Arg 1: :1.11
Arg 2: null
Arg 3: org.freedesktop.DBus.Properties
Arg 4: Notify
Arg 5: com.nokia.bluez_headset_proxy
Arg 6: State
Arg 7: Playing
=================================
Arg 1: :1.34
Arg 2: null
Arg 3: org.bluez.audio.Control
Arg 4: Connected
=================================

svs57 2009-02-27 13:41

Re: [ANNOUNCE] mbluetoothd
 
I accidentlly kill dbus daemon. IT rebooted and know everything wokr :)

One more question.
Is it possible to execute script via dbus-script on headphone button press?

Now I use python script to pause kagu when button press.
I have to start it from xterm each time when I start kagu.
Will be nice if need only start BT on IT and nothing more :)

#!/usr/bin/env python2.5

from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default=True)

import dbus
import gobject
import os

dbus_loop = gobject.MainLoop()
bus = dbus.SessionBus()

def on_button_pressed (sender=None):
os.system('echo pause > /home/user/.kagu/fifo')


headset = bus.get_object('com.nokia.osso_hp_ls_controller', '/com/nokia/osso_hp_ls_controller')
headset_iface = dbus.Interface(headset, dbus_interface='com.nokia.osso_hp_ls_controller.he adset')
headset_iface.connect_to_signal('button_pressed', on_button_pressed, sender_keyword='sender')

dbus_loop.run()

svs57 2009-02-27 13:48

Re: [ANNOUNCE] mbluetoothd
 
I mean something like this in /etc/dbus-scripts.d/dbus-scripts-settings
...
/usr/local/bin/pause-kagu * * com.nokia.osso_hp_ls_controller.headset button_pressed 00:0D:3C:A6:CC:13
or
/usr/local/bin/pause-kagu * * org.bluez.audio.Headset AnswerRequested 00:0D:3C:A6:CC:13

bongo 2009-02-27 14:39

Re: [ANNOUNCE] mbluetoothd
 
I tried to find a way to find out if the headphones are connected. The dbus signal is always the same for connect/disconnect :(

Matan 2009-02-27 16:44

Re: [ANNOUNCE] mbluetoothd
 
You seem to have both scripts running on connect. The on_disconnect (kagu_stop) should have RemoteDeviceDisconnect, not RemoteDeviceConnect.

As far as I can tell this is not a dbus-scripts-setting bug. Are you sure you selected disconnect for the second line?

About getting the same dbus signal for connect/disconnect - there are other such events, such as keyboard slide (same signal when openned and closed) USB device connect/disconnect. In such cases you need to have the script running on both events, and the script should use some other method for finding out which event actually happened (and be really careful of race conditions).

bongo 2009-02-27 16:59

Re: [ANNOUNCE] mbluetoothd
 
Quote:

Originally Posted by Matan (Post 267601)

About getting the same dbus signal for connect/disconnect - there are other such events, such as keyboard slide (same signal when openned and closed) USB device connect/disconnect. In such cases you need to have the script running on both events, and the script should use some other method for finding out which event actually happened (and be really careful of race conditions).

I know that, but how can I find out if the headphone is connected?

Matan 2009-02-27 19:41

Re: [ANNOUNCE] mbluetoothd
 
There is a file /sys/devices/platform/retu-headset/hookdet which apprently gives the value of retu adc 5. Values of less than 80 appear to indicate headset connected, while values of more, appear to indicate not connected.

svs57 2009-02-27 20:22

Re: [ANNOUNCE] mbluetoothd
 
It was mistake. I changed second line to disconnect.
I think the should be way to extend the program and add headphone button monitor.
Now I have one script to monitor connect/disconnect BT and one for monitor BT button.


All times are GMT. The time now is 12:31.

vBulletin® Version 3.8.8