Hooking cell phones up to your (IP) PBX

I recently got overly annoyed with both the office phone and my cell phone going off on me at the same time. Then I bumped into chan_mobile. Now I have some nasty ideas. Why not use bluetooth to automatically hook your cellphone up to the PBX whenever you walk into the office? Sounds hard? Well, as a matter of fact, it’s not.

I haven’t implemented the full idea yet, but got most of the pieces for doing it set up. So how hard is it? Well, I’ve done it in about 30 minutes start to proof of concept working, with zero knowledge regarding bluetooth on Linux, and not even knowing what the chipset of my built-in bluetooth dongle was in my laptop!

As it turns out, it’s a matter of loading the appropriate kernel module (bcm203x in my case), installing bluez-libs and bluez-utils and starting the bluetooth service (which starts hcid, sdpd and rfcomm – not sure what each of these does, but there you have it). Once this is done your hci devices should be up (I edited my device name in /etc/bluetooth/hcid.conf to “%h”).

Then it’s time to scan the bluetooth range, which is simple enough with “hcitool scan”, now you have the hw address for connecting to. So time to pair up with it with a simple “rfcomm connect 0 ${hwaddr}”, this will pop up a PIN prompt on your phone, enter anything (eg 1234), then on your laptop a prompt should also pop up, enter the same PIN. Now, on your phone, you had better set your laptop to authorized (makes life less problematic later on). For the moment, leave the association on.

Now we need to move on to asterisk, so make sure you have asterisk-addons installed (I use asterisk-1.6.0 on Gentoo, thus I simply merged asterisk-addons with the mobile USE flag set). Now you need to edit /etc/asterisk/mobile.conf, but before you need that you’re going to need your local hwaddr, so get it by typing “hciconfig”, which will display all you need to know, specifically you’re looking for something like “BD Address: 00:11:22:33:44:55:66”. I edited the default config file, firstly I commented out the default devices that was around, and then edited the first of the adapter devices (just change the id to something you like, and the address to the value obtained above). Now either restart asterisk or unload and load module chan_mobile.

Now enter the cli (asterisk -Rv) and check that the mobile family of commands are available (just type “mobile” and press tab twice quickly, it should show you the subcommands). If they are, proceed, else you may need to check why chan_mobile won’t load (try and load it from the CLI and it’ll probably tell you). So now you can run “mobile search”. It can take a while but you should get something like:

Address Name Usable Type Port
00:18:0F:A8:4C:A4 Thor Yes Phone 28

So, edit mobile.conf again and add the section for your phone. For the above I just did this:

[thor]
address=00:18:0F:A8:4C:A4
port=28
context=from-thor
adapter=serenity

where serenity is the name of my laptop and ID I assigned to my adapter. Restart asterisk and now you can run “mobile show devices”, if all went well you’ll see something like:

serenity*CLI> mobile show devices
ID Address Group Adapter Connected State SMS
thor 00:18:0F:A8:4C:A4 0 serenity Yes Free No

From here you can do whatever you want with incoming calls (like passing them over to your PBX via IAX2/SIP or passing it directly to a phone, or something.

There are obviously problems with doing this from my notebook – what happens if I’m at home and do actually want to take the call on my phone, which is now “associated” with my laptop – which cannot contact the PBX (ok, mine can, but this is exactly what I DON’T want – currently working around this by setting the qualify value to the PBX to something crazy low like 5 which will only ever work in the office, so it’s pretty much lagged and then having a SIP desktop phone – more comfortable than the cell anyway, and with decent loudspeaker – as fallback).

The better way is probably to make use of bluetooth adapters in machines that are in the office statically, or even network-based bluetooth “nodes” of sorts. Not sure yet exactly how to handle this. There are also obvious problems with mobility (if the phone is in your pocket whilst a call is in progress that you’re not aware of and you walk out of the bluetooth range it’s probably going to end up being dropped with an annoyed customer or something).

There are some major advantages though, you gain the ability to pass calls off to your employees without having to throw phones around. You can actually put people on hold. If you’re already busy on your phone it can automatically be routed to alternative destinations (eg, hunting, queueing, all the flexibility your PBX gives you on other channels). Also, you can even treat it like a mobile premicell!

And for those that have absolutely no other reason: GEEK FACTOR!

Tags: , , , ,

Leave a Reply

This blog is kept spam free by WP-SpamFree.