maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Bluetooth ring event (https://talk.maemo.org/showthread.php?t=18132)

liquid217 2008-03-20 17:22

Bluetooth ring event
 
Is there such a thing as a event that is activated via bluetooth from a cell phone when it rings? I am writing a script that connects to my razr and waits for it to ring. Once it rings, it will look up the incoming phone number with either whitepages.com (free) or cnam.info (pay), and return the name and number of the incoming caller using the dbus messaging system. Effectively, this will turn the tablet into a CallerID with name unit for a cell phone. I already have something like this written on a windows platform, over a usb cable, but I would love to adapt this to the tablet. So far, just using command line options, I can CAT to the port, and am able to grab the phone number (after issueing the commands by ECHOing them to the port), but keeping a persistent connection to the phone via bluetooth will wear the battery down very quickly, so I almost need some type of event driven function.
Anyway, if anyone has any ideas, I would love to hear them.

Jaffa 2008-03-20 20:39

Re: Bluetooth ring event
 
I'm not aware of any standard BT functionality to get a phone to broadcast a Bluetooth event to any paired, but not connected, devices when it receives an incoming call.

It's possible there are phone specific features for it; but I suspect you'll have to maintain the connection.

m_stolle 2008-03-24 14:14

Re: Bluetooth ring event
 
How about simulating a headset or something like that? It might wreak havoc with trying to receive the call on the mobile (since it might try to pump audio to the headset), but that should be configurable on the phone side. Given the insane stand-by times headsets get with their tiny batteries, I am sure that it doesn't require a constant BT connection.

Martin

liquid217 2008-03-24 16:16

Re: Bluetooth ring event
 
As I understand it, that is part of the HSP protocol, which, if i am not mistaken, bluez doesn't support yet? At least the OS2008 port doesn't. I was reading a thread on the development of phonelink, and noticed that it has preliminary incoming call/sms support, so it might be interesting to watch that development. Anyway, I am not going to give up just yet. Thanks to all who have answered.

m_stolle 2008-03-24 18:39

Re: Bluetooth ring event
 
Why does bluez need to support it? I thought it gave access to sockets on all layers of the bluetooth stack - so you can just have your app implement HSP by using a low-level enough interface to bluez.

Benson 2008-03-24 18:53

Re: Bluetooth ring event
 
Quote:

Originally Posted by liquid217 (Post 159483)
As I understand it, that is part of the HSP protocol, which, if i am not mistaken, bluez doesn't support yet? At least the OS2008 port doesn't. I was reading a thread on the development of phonelink, and noticed that it has preliminary incoming call/sms support, so it might be interesting to watch that development. Anyway, I am not going to give up just yet. Thanks to all who have answered.

Link, please? That's very interesting, and I'd like to check it out.

liquid217 2008-03-24 19:09

Re: Bluetooth ring event
 
here is the link to the phonelink thread
http://www.internettablettalk.com/fo...ight=phonelink

In the script I am working on, I am using the shell script "dbus-bluez-rfcomm" from the kbdd project
http://fanoush.wz.cz/maemo/#kbdd

I changed the protocol on line 56, to say DUN instead of SPP. i then used it to bind to rfcomm0. I tried substituting DUN with HSP, and the script failed. Honestly, I am not too familiar with bluez, so i've pretty much gotten here by trial and error.

tz1 2008-03-26 14:05

Re: Bluetooth ring event
 
On a similar angle, is there a way to get the N810 to detect when I press my BT headset button (any?). I'd love to be able to have it "press the spacebar" to pause and resume playback.

Benson 2008-03-26 22:27

Re: Bluetooth ring event
 
Yes, there is. You'll need dbus-scripts installed; then you'll need to make an entry to handle the dbus messages from button-press and button-release. (Sorry I'm a bit vague here, I haven't done that yet, I just know that it does send dbus messages and that dbus-scripts is how to q+d respond to them.)

Then use xte to output the spacebar, or whatever.

fredoll 2008-04-02 16:10

Re: Bluetooth ring event
 
As sais in the phonelink thread, I could amit a DBus Message with the caller information ...

bsmithyman 2008-04-11 02:45

Re: Bluetooth ring event
 
I just got my n800 the other day, but I ran across the same thing that tz1 mentioned: I've got a button on my bluetooth headset (Moto H680) that doesn't do anything.

I coded up the idea mentioned here - bind the button_press event to a script that runs xte. The built-in media player needs a carriage return to play/pause, but you could modify this to do just about anything.

I posted the python code here along with an archive containing the latest sources for XAutomation with compiled binaries. Or, if you prefer, a second post with just the files executables.

Benson 2008-04-11 03:00

Re: Bluetooth ring event
 
Thanks for the xautomation build!

I tried something similar (using mpc to control mpd, no need for xte), except I used dbus-scripts. dbus-scripts is probably the cleaner approach, as that lets one daemon handle multiple event definitions installed separately, but I have trouble with dbus-scripts in session mode. It repeatedly segfaults. :(
So I found that there is an equivalent signal on the system dbus, and am using that. But Xautomation will be very handy for some other stuff.

bsmithyman 2008-04-11 20:50

Re: Bluetooth ring event
 
Quote:

Originally Posted by Benson (Post 168248)
Thanks for the xautomation build!

I tried something similar (using mpc to control mpd, no need for xte), except I used dbus-scripts. dbus-scripts is probably the cleaner approach, as that lets one daemon handle multiple event definitions installed separately, but I have trouble with dbus-scripts in session mode. It repeatedly segfaults. :(
So I found that there is an equivalent signal on the system dbus, and am using that. But Xautomation will be very handy for some other stuff.

Yeah, I found that I couldn't get the session dbus to work with dbus-scripts either, and I felt like learning how to do it with python-dbus. I'm still not sure how to get which button was pressed from the dbus "button_pressed" event, for headsets that support redial, voice, etc.

Actually, if python 2.3 will support the code, a quick fix would be to switch it from python 2.5, and save resources with pythonlauncher. In that case, I don't think there's really a difference between using dbus-scripts and my approach (except for the automatic init.d execution).

Either way :)

I may see if I can figure out how to package xautomation, but there's not debian control for it... perhaps I'll pull a version from something like Ubuntu Hardy and see what it officially requires.

Benson 2008-04-11 22:24

Re: Bluetooth ring event
 
Well, you might check the system dbus and see if you can tell by those signals. (There's really only one signal, rather than a press and release. So I think (from the way my headset works), that the one on the system bus is read by something, which sends the signals on the session bus. I only have a one-button headset (plus volume, which is handled separately), so I don't really know if there is any more there.

bsmithyman 2008-04-13 04:27

Re: Bluetooth ring event
 
Thanks Benson, I'll give that a try.

Mine's got a "multi-function" button and volume controls, but depending on how long you hold the button it sends either an answer/hang-up signal, or a redial command. It seems like this is handled onboard, rather than on the phone, as both the press and release messages on the tablet only appear after the button is released (using dbus-monitor).

System dbus also seems to work a bit better with dbus-scripts (i.e. at all), so that might be a sign.

I'm not completely sure where the api for "com.nokia.osso_hp_ls_controller.headset" is, but it seems reminiscent of the bluez api for HSP, so I'm going to pull down the C code for that and see where it gets me.

bsmithyman 2008-04-13 07:08

Re: Bluetooth ring event
 
As an update, it seems that the system DBus gets an AnswerRequested event from Bluez. I read through headset.c a bit, and the short version is that there's no support for multi-button headsets at the moment. A much more long-winded version is here if anyone is interested, but I didn't want to clutter up the forum.

On another note, switching python2.5 to python in my script does make it work with pythonlauncher... there's no real need for 2.5.


All times are GMT. The time now is 21:09.

vBulletin® Version 3.8.8