maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Design (https://talk.maemo.org/forumdisplay.php?f=46)
-   -   Python - Using Bluetooth/Wired Headset Answer Button (https://talk.maemo.org/showthread.php?t=84827)

biketool 2012-06-11 14:49

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

biketool 2012-06-11 15:15

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.

misiak 2012-06-11 15:42

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.

wook_sf 2012-06-11 17:47

Re: Python - Using Bluetooth/Wired Headset Answer Button
 
not quite sure, but maybe os.popen can help?

biketool 2012-06-12 08:36

Re: Python - Using Bluetooth/Wired Headset Answer Button
 
Quote:

Originally Posted by misiak (Post 1220544)
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... .

Thanks I think the scripts control will do it for the wired headset. I dont have my N900 right now as a replacement is in the mail but I am also trying to figure out how the HAL or d-bus handles an answer button from a BT headset when there is not an incoming call. I think if there was a way to mod headset-button-enabler to look for the bluetooth answer instead of from the wired headset it would do the job, my sub-script kiddie skills are really failing me now though.

biketool 2012-06-12 08:39

Re: Python - Using Bluetooth/Wired Headset Answer Button
 
Quote:

Originally Posted by wook_sf (Post 1220606)
not quite sure, but maybe os.popen can help?

Thanks, I am looking at that now, a great lead. The problem is I am waiting for my replacement N900 to arrive and cant experiment. Can you see a answer button press on you BT headset with os.popen without mucking with dbus?

wook_sf 2012-06-13 11:18

Re: Python - Using Bluetooth/Wired Headset Answer Button
 
Quote:

Originally Posted by biketool (Post 1220814)
Thanks, I am looking at that now, a great lead. The problem is I am waiting for my replacement N900 to arrive and cant experiment. Can you see a answer button press on you BT headset with os.popen without mucking with dbus?

unfortunately i don't have BT headset :S nor n900 :D but it should work since i tested some functions like this on n9 and it works.
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.

gionni88 2012-06-13 13:33

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.

misiak 2012-06-13 14:01

Re: Python - Using Bluetooth/Wired Headset Answer Button
 
Quote:

Originally Posted by gionni88 (Post 1221343)
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.

So it doesn't matter whether the headset is wired or wireless (bluetooth), the dbus signal will be the same? If yes, I can come up with minimalistic C and Python example for you taxizo, as I have wired headset (but I don't have any wireless, so I'm only able to test with wired one).

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 ;)

biketool 2012-06-14 14:52

Re: Python - Using Bluetooth/Wired Headset Answer Button
 
Quote:

Originally Posted by misiak (Post 1221356)
So it doesn't matter whether the headset is wired or wireless (bluetooth), the dbus signal will be the same? If yes, I can come up with minimalistic C and Python example for you taxizo, as I have wired headset (but I don't have any wireless, so I'm only able to test with wired one).

edit:I'm up for writing a simple example, give me few hours ;)

Great, plenty of us really appreciate the work!


All times are GMT. The time now is 10:00.

vBulletin® Version 3.8.8