I found getting chan_mobile to be a challenge to get up and running,
so, having completed the exercise, I thought it might be useful to
make available the procedure I followed to accomplish this.
If you didn't know, chan_mobile.c is in the trunk version
of asterisk-addons. This complements the trunk version of
asterisk. If you want to use chan_mobile with 1.4, you are
in trouble. Until now.
A few brave souls have published patches to chan_mobile.c in
their blogs, and I've tried a few of them, but they are
pretty old now, and no longer apply. The current version of asterisk
1.4 appears to be 1.4.22 at the moment.
Not being able to simply download a patch and apply it to
1.4, I rolled up my sleeves and hacked away on chan_mobile.c
until it compiled, and then ran it until it stopped crashing
asterisk. I can now get and place calls. Don't have any headsets,
or I might have tried them, too.
I upgraded Linux from FC3 to Ubuntu 8.10 server; no fancy X-win,
KDE or Gnome for me. But the newer kernel should allow me
to use bluetooth without too many worries...
I had trouble understanding how to pair my phone to the new
kernel interface. The bluez.org site is pretty bare; the
wiki was outdated, and everyone's blogs were outdated.
I finally resorted to begging for help on #bluez-users,
and a tip there got me where I needed to go.
Basically, the way you define bluetooth pins has changed.
If you look in /etc/bluetooth, and see the file hcid.conf,
then create a 'pin' file there, and put a 4-digit pin in it with
a text editor. Various folks have said your pin can be longer.
I was too chicken to try that.
But, if all you see in /etc/bluetooth are files like main.conf,
network.conf, and suchlike (no hcid.conf), then follow the
procedure below to get your phone paired and chan_mobile
patched and running on 1.4:
1. wget ftp://www.parsetree.com/chan_mobile-backport-1.4
2. download the bluez-4.24.tar.gz file from bluez.org; unpack
it and have it ready; you don't need to compile it, but
you will need the test/simple-agent script. You'll only
need this, most likely, if your Linux kernel is late-model,
and using the latest version of the bluez stuff.
3. if you are interested in what changes I made to the trunk
version of chan_mobile.c, then:
wget ftp://www.parsetree.com/chan-mobile.diffs
(you don't need this, but you might be interested
in what I did).
4. svn co http://svn.digium.com/svn/asterisk-addons/branches/1.4 asterisk-addons-1.4
5. svn co http://svn.digium.com/svn/asterisk-addons/trunk asterisk-addons-trunk
6. build asterisk-1.4 from svn or a tarball; make and compile and install it.
7. cd asterisk-addons-1.4; patch -p0 < ../chan_mobile-backport-1.4; ./configure --with-asterisk=<path to asterisk-1.4 build> --enable-dev-mode; make menuselect (and make sure channels/chan_mobile is selected, and other stuff you don't want/need is turned off); make; make install (as root?)
8. plug in your bluetooth usb dongle, if you don't already have something builtin, or whatever.
I'm using a gbu221; I've tested Manhattan, Asus WL-BTD201M, Encore, they all work well.
9. hciconfig
Should give you something like:
hci0: Type: USB
BD Address: 00:02:72:07:FC:44 ACL MTU: 1017:8 SCO MTU: 64:8
UP RUNNING
RX bytes:3029676 acl:118 sco:59273 events:202 errors:1
TX bytes:2625052 acl:73 sco:51419 commands:83 errors:0
(pay attention to that BD Address!)
10. cp asterisk-addons-trunk/configs/mobile.conf.sample /etc/asterisk/mobile.conf
11. edit /etc/asterisk/mobile.conf;
comment out all example [adapter] sections and insert one for your adapter:
[adapter]
id=gbu221
address=00:02:72:07:FC:44
There are other options; I didn't need them, but you might.
Now is a good time to comment out all the headset and phone example sections in
the mobile.conf file; you'll add one for your phone in a little bit.
12. Open up a new shell on the side, and run the script
bluez-4.24/test/simple-agent
it runs silently. Just let it sit.
13. Get out your cell phone. Make sure you are in communications distance
to the bluetooth transceiver on your system. Get into your phone's
bluetooth menus, and turn on the "discovery mode". Usually your
phone will only run it for a minute.
14. ASTERISK CLI> module load chan_mobile.so
15. ASTERISK CLI> mobile search
This could take a while. If things are going well, your cell phone
should perk up and ask if you want to pair with the asterisk box.
Say yes. It'll then prompt you for a pin. Type in a 4-digit number.
Some folks say you can use more digits, but I was too chicken to try.
16. If things are going really well, that simple-agent script will now
come to life, and ask you for a pin. Type in the same 4-digit number
as before. You can cntrl-c out of this script after this, whenever
you want.
17. Meanwhile, back in Asterisk, you should get some output from
the "mobile search" command that looks like this:
Address Name Usable Type Port
00:1B:98:52:F4:F2 LG TU500 Yes Phone 4
The Address and the Port fields are the ones you'll need!
18. Edit the /etc/asterisk/mobile.conf file again, and create
a phone entry for your cell phone. Call it whatever you want,
I called mine "steves".
[steves]
address=00:1B:98:52:F4:F2 ; the address of the phone
port=4 ; the rfcomm port number (from mobile search)
context=workline ; dialplan context for incoming calls
adapter=gbu221 ; adapter to use
group=1 ; this phone is in channel group 1
There are other options, which I didn't need. Check the comments.
19. Using the file asterisk-addons-trunk/trunk/chan_mobile.txt as a guide,
set up your dialplan to make calls out using Dial(Mobile/steves/, ...)
20. ASTERISK CLI> module unload chan_mobile.so
21. ASTERISK CLI> module load chan_mobile.so
(these commands reload chan_mobile.so to get the new entry).
22. ASTERISK CLI> dialplan reload (or ael reload)
23. ASTERISK CLI> mobile show devices
If all is going well, you should see output like this:
ID Address Group Adapter Connected State SMS
steves 00:1B:98:52:F4:F2 1 gbu221 Yes Free No
You should be able to get and make calls now.
