Python - Using Bluetooth/Wired Headset Answer Button
There is a new app named Saera being developed to provide a voice controlled experience similar to Siri for the Iphone.
For this app to be fully useful to people who need hands free voice interaction with their device the answer button needs to work outside of answering/ending phone calls with both the wired headset and more importantly the Bluetooth headsets much as it does on phones with voice dialing. Most of the work appears to have been done for wired headsets with these packages: *Headset Button Enabler - enables wired headset to be used outside calls *Headset Control - uses wired headset to control Media Player These apps are designed for pausing and starting the media player but need to be accessable to Python which Saera is written in, and more importantly also need to include the more common bluetooth headsets which does not appaer to be the case. Saera is one of the killer apps car drivers, cyclists, and motorcycle drivers have waited for on Maemo/Meego. the Saera thread is here http://talk.maemo.org/showthread.php?t=84753 |
Re: Python - Using Bluetooth/Wired Headset Answer Button
Checked http://wiki.maemo.org/Phone_control
doesnt seem to currently be any way to get information related to headsets beyond pairing and other standard bluez stuff. |
Re: Python - Using Bluetooth/Wired Headset Answer Button
According to headset-button-enabler description, when it is installed and a headset button is pressed, "ButtonPressed" signal is emitted by HAL... it should be possible to catch that signal in Python somehow... I cannot help with Python, as my Python skills are weak, but have a look at headset-control package sources, especially at two files: headset-controld.c and headset-control-obj.c. If you understand C language, you will notice this isn't rocket science, and it requires only Python glib, dbus and hal bindings (maybe even one of these is not needed, I skimmed through the code now very quickly while I'm on the train), which, afaik, are all available for Python on Maemo. So, in my oppinion, package headset-control could be used as a reference implementation, if someone has more time, (s)he can write a wiki page basing on this code.
|
Re: Python - Using Bluetooth/Wired Headset Answer Button
not quite sure, but maybe os.popen can help?
|
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
|
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
|
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
last night i found struct of input events and library written in python, well...there's not much of ported py libs for harmattan but i am sure python-dev and this scripts can be ported to python easily. however, you can take needed classes from event.py and input.py and put them into your script. |
Re: Python - Using Bluetooth/Wired Headset Answer Button
When wired or bluetooth button is pressed a system dbus signal is emitted. On n900 if I don't remember wrong the wired button is disabled but you may enable it just with an amixer command. You don't need anything else, just to enable the wired button and listen to dbus events.
|
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
edit: This would get more responses if it was posted in "Development" section, not "Design"... Anyway, I'm up for writing a simple example, give me few hours ;) |
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
|
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
|
Re: Python - Using Bluetooth/Wired Headset Answer Button
Will this example will only work for the wired headset, or do you also know the output from a bluetooth headset answer button?
|
Re: Python - Using Bluetooth/Wired Headset Answer Button
I have C code which detects wired headset button presses. I need to:
1. Clean it up a bit (it's modified headset-control source) 2. Translate it to Python 3. Find someone to test it with bluetooth headsets. Do you have bluetooth headset? If you do, you may try to install headset-button-enabler and headset-control from extras-devel and chceck if it works (it should start/stop music in stock media player when button is pressed - try long press, with my cheap wired headset I need to hold the button for 1-2 seconds before it's noticed by the phone) |
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
|
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
Code:
sudo gainroot |
Re: Python - Using Bluetooth/Wired Headset Answer Button
Misiak,
Still waiting for my replacement N900 :) If I remember right headset-button-enabler headset-control did NOT control mediaplayer with the bluetooth even a one button in-ear unit, definately not with a BH-214. I have to assume it is a very similar thing and the discovery or use would probably enable patching Skype to answer via BT aswell |
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
|
Re: Python - Using Bluetooth/Wired Headset Answer Button
steped up on this thread...
Ok. Firts of all I have Nokia BH-111 BT headset. all buttons work fine and control the device (media player - play/pause /next / prev) and phone (accept call & redial) Doing some tests with dbus-monitor up: Nokia-N900:~# dbus-monitor --system signal sender=org.freedesktop.DBus -> dest=:1.529 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired string ":1.529" signal sender=:1.12 -> dest=(null destination) serial=3995 path=/org/freedesktop/Hal/devices/computer_logicaldev_input_1; interface=org.freedesktop.Hal.Device; member=Condition string "ButtonPressed" string "play-cd" signal sender=:1.48 -> dest=(null destination) serial=751 path=/com/nokia/tklock/signal; interface=com.nokia.tklock.signal; member=mm_key_press uint32 208 uint32 269025044 signal sender=:1.12 -> dest=(null destination) serial=4032 path=/org/freedesktop/Hal/devices/computer_logicaldev_input_1; interface=org.freedesktop.Hal.Device; member=Condition string "ButtonPressed" string "next-song" signal sender=:1.48 -> dest=(null destination) serial=760 path=/com/nokia/tklock/signal; interface=com.nokia.tklock.signal; member=mm_key_press uint32 171 uint32 269025047 signal sender=:1.12 -> dest=(null destination) serial=4033 path=/org/freedesktop/Hal/devices/computer_logicaldev_input_1; interface=org.freedesktop.Hal.Device; member=Condition string "ButtonPressed" string "previous-song" signal sender=:1.48 -> dest=(null destination) serial=761 path=/com/nokia/tklock/signal; interface=com.nokia.tklock.signal; member=mm_key_press uint32 173 uint32 269025046 signal sender=:1.18 -> dest=(null destination) serial=6451 path=/com/nokia/csd/call; interface=com.nokia.csd.Call; member=CreateRequested string "xxxTELNUMBER010" uint32 0 signal sender=:1.18 -> dest=(null destination) serial=6452 path=/com/nokia/csd/call; interface=com.nokia.csd.Call; member=ServerStatus boolean true boolean false signal sender=:1.18 -> dest=(null destination) serial=6453 path=/com/nokia/csd/call; interface=com.nokia.csd.Call; member=Created object path "/com/nokia/csd/call/1" string "xxxTELNUMBER010" As you can see, dbus catches button press for headset play button, next and prev buttons. Unfortunantly, it seems that it's not catching the "redial" or "answer/reject" button or they just dont generate dbus events... |
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
Code:
signal sender=:1.12 -> dest=(null destination) serial=3995 path=/org/freedesktop/Hal/devices/computer_logicaldev_input_1; interface=org.freedesktop.Hal.Device; member=Condition Edit: if no "ButtonPressed" signal is emited then, could you try installing "headset-button-enabler", reboot device and check if it is emitted then? |
Re: Python - Using Bluetooth/Wired Headset Answer Button
Nokia-N900:~# dpkg -l | grep -i headset
ii headset-button-enabler 0.5 Enable wired headset button to be used outside of phone calls ii headset-control 0.4 Daemon allowing control of Media Player with the wired headset button ii maemo-statusmenu-headset 0.18+0m5 Headset status menu plugin In my previous post:... Unfortunantly, it seems that it's not catching the "redial" or "answer/reject" button or they just dont generate dbus events... In this case the "phone" button Yet, it works. if I press twice the "phone" button, n900 redials the last number. Yet no dbus-event is generated.... |
Re: Python - Using Bluetooth/Wired Headset Answer Button
Have a look at the MediaButtonsHandler here:
https://github.com/gpodder/gpodder/b...mlui/helper.py You can even remove all the Qt stuff around it, and just use the "dbus" module (be sure to use a GLib or Qt main loop though, as you are connecting to signals). HTH :) |
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
import dbus system_bus = dbus.SystemBus() system_bus.add_signal_receiver(self.handle_button, 'Condition', 'org.freedesktop.Hal.Device', None, headset_path) if gpodder.ui.harmattan: system_bus.add_signal_receiver(self.handle_button, 'Condition', 'org.freedesktop.Hal.Device', None, headset_path2) def handle_button(self, signal, button): if signal == 'ButtonPressed': if button in ('play-cd', 'phone'): self.playPressed.emit() elif button == 'pause-cd': self.pausePressed.emit() elif button == 'previous-song': self.previousPressed.emit() elif button == 'next-song': self.nextPressed.emit() playPressed = QtCore.Signal() pausePressed = QtCore.Signal() previousPressed = QtCore.Signal() nextPressed = QtCore.Signal() I think the "Phone" it is talking about though is phone in use not the headset button? |
Re: Python - Using Bluetooth/Wired Headset Answer Button
Misiak
I started this thread in Maemo5 dev http://talk.maemo.org/showthread.php?p=1226840 Hoping it leads to a headset control enabler package similar to the wired headset control but for Bluetooth. If you had this would it just be left to testing for bugs? What else do you need? thanks again! |
Re: Python - Using Bluetooth/Wired Headset Answer Button
Question,
Where does Headset Button Enabler package grab the wired headset signal so it can be sent to dbus? I imagine the bluetooth answer button sends to the same process. This for the N810 seems obsolete for the N900/Maemo5 but I could be wrong. http://talk.maemo.org/archive/index.php/t-21182.html Still waiting for my N900 so I cant check. signal sender=:1.0 -> dest=(null destination) path=/com/nokia/osso_hp_ls_controller; interface=com.nokia.osso_hp_ls_controller.headset; member=button_pressed signal sender=:1.0 -> dest=(null destination) path=/com/nokia/osso_hp_ls_controller; interface=com.nokia.osso_hp_ls_controller.headset; member=button_released |
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
Thanks for your help :) And sorry for delays, I'm a busy man lately... |
Re: Python - Using Bluetooth/Wired Headset Answer Button
No worries, we appreciate the work you are doing when you can!
I hope the input and research helps. |
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
Code:
//To connect to wired headset button: |
Re: Python - Using Bluetooth/Wired Headset Answer Button
So it seems that the information is gathered here to build a bluetooth version of HeadsetButtonEnabler for general purpose control of ausio in addition to applications in Saera. Now someone needs to change a few lines of code and rename the package to reflect bluetooth rather than wired headset and compile it to get the bluetooth headset presses to show up in dbus for apps to see?
|
Re: Python - Using Bluetooth/Wired Headset Answer Button
okay,thank you
|
Re: Python - Using Bluetooth/Wired Headset Answer Button
Quote:
|
All times are GMT. The time now is 21:24. |
vBulletin® Version 3.8.8