chan_cellphone Asterisk Channel Driver to allow Bluetooth Cell/Mobile Phones to be used as FXO devices. Features :- Multiple cell phones can be connected. Asterisk automatically connects to each cell phone when it comes in range. Command to discover bluetooth devices. Useful for configuration Inbound calls to the cell phones are handled by Asterisk, just like inbound calls on a Zap channel. CLI passed through on inbound calls. Dial outbound on a cell phone using Dial(CELL/device/nnnnnnn) in the dialplan. Application CellStatus can be used in the dialplan to see if a cell phone is connected. Supports devicestate for dialplan hinting. Using chan_cellphone :- In order to use chan_cellphone, you must have a working bluetooth subsystem on your Asterisk box. This means a working bluetooth adapter, and the Blue-Z packages. Any bluetooth adapter supported by the Linux kernel will do, including usb bluetooth dongles. The Blue-Z package you need is bluez-utils and your package manager will probably want to install bluez-pin also. You also need libbluetooth and libbluetooth-dev if you are compiling Asterisk from source. There are sample bluetooth config files in the Asterisk source directory under contrib/bluetooth. I suggest you use the sample hcid.conf and pinhelper script. Both of these go in /etc/bluetooth and will set your Asterisk box up with a bluetooth name of "Asterisk PBX" and a default pin of "0000". (change this if you want). Dont forget to make the /etc/bluetooth/pinhelper script executable. See www.bluez.org for other details about setting up Bluetooth under Linux. Assuming you have bluetooth working ok:- Load chan_cellphone.so Search for your Bluetooth Cell Phones using the CLI command 'cell search'. Be patient with this command as it will take 8 - 10 seconds to do the discovery. Also, if this is the first time Asterisk has talked to phone via bluetooth, your phone may/will prompt you to enter a PIN. Use the number in the /etc/bluetooth/pinhelper script. "0000" is the default. This will return something like the following :- *CLI> cell search Address Name Usable Port 00:0F:86:0E:AE:42 Daves Blackberry Yes 2 00:12:56:90:6E:00 LG TU500 Yes 4 00:17:44:55:66:12 Toaster No 0 This is a list of all bluetooth devices seen and whether or not they are usable with chan_cellphone. The Address field contains the 'bd address' of the cell phone. This is like an ethernet mac address. The Name field is whatever is configured into the phone as its name. The Usable field tells you whether or not the devices supports the Bluetooth Handsfree Profile, and if so which 'rfcomm port number it uses'. If this field is 'No' (like Toaster in the example above) then the device is not usable. Choose which device(s) you want to use and edit /etc/asterisk/cellphone.conf. There is a sample included with the Asterisk source under configs/cellphone.conf.sample. Assuming we want to use both devices above, cellphone.conf needs to look like this :- =================================================================================== ; ; cellphone.conf ; [general] interval=60 ; Number of seconds between trying to connect to devices. ; The following is a list of the devices we deal with. ; Every device listed below will be available for calls in and out of Asterisk. ; Discovered devices not in this list are not available. ; Use the CLI command 'cell search' to discover devices. ; Use the CLI command 'cell show devices' to see device status. ; ; To place a call use Dial(CELL/[device]/NNN.....) in your dialplan. [dave] address=00:12:56:90:6E:00 port=4 context=incoming-mobile [blackberry] address=00:0F:86:0E:AE:42 port=2 context=incoming-mobile =================================================================================== Be sure to configure the right bd address and port number from the search. If you want inbound calls on a device to go to a specific context, add a context= line, otherwise the default will be used. The 'id' of the device [bitinbrackets] can be anything you like, just make the unique. Having done this, unload chan_cellphone and load it again. The CLI command 'cell show devices' can be used at any time to show the status of configured devices. *CLI> cell show devices ID Address Connected State blackberry 00:0F:86:0E:AE:42 Yes Free dave 00:12:56:90:6E:00 Yes Free *CLI> All being well Asterisk will now try and establish a connection to each configured device. If it cant it will retry after 'interval' seconds, infinately. This means that as your cell phone comes into range and goes out of range, Asterisk will automatically connect and disconnect from it. You dont need to worry about it. The first time Asterisk trys to connect to your cell phone, probably as a result of the 'cell search' command, the bluetooth subsystem will ask for a PIN, this will be what ever value is in the pinhelper script above. This happens only once, and is a 'security mechanism' meaning you need to know the pin in order to connect your cell phone to the Asterisk box. As each phone is connected you will see a message on the Asterisk console :- Loaded chan_cellphone.so => (Bluetooth Cellphone Driver) -- Bluetooth Device blackberry has connected. -- Bluetooth Device dave has connected. If someone calls your cell phone now, Asterisk will handle the call and it will be sent into the context you specified, or the default context. Mostly likely this means some SIP phone somewhere will ring, pick it up and take the call. To make outbound calls, add something to you Dialplan like the following :- (modify to suit) ; Calls via TU500 exten => _9X.,1,Dial(CELL/dave/${EXTEN:1},45,tT) exten => _9X.,n,Hangup ; Calls via Blackberry exten => _8X.,1,Dial(CELL/blackberry/${EXTEN:1},45,tT) exten => _8X.,n,Hangup Pick up a SIP phone and dial 9 and the call vill go via the device 'dave' in cellphone.conf. Dialplan hints :- chan_cellphone supports 'device status' so you can do somthing like exten => 1234,hint,SIP/30&CELL/dave&CELL/blackberry CellStatus Application :- chan_cellphone also registers and application named CellStatus. You can use this in your Dialplan to determine the 'state' of a cell phone. For example, suppose you wanted to call dave's extension, but only if he was in the office. You could test to see if his cell phone was attached to Asterisk, if it is dial his extension, otherwise dial his cell phone. exten => 40,1,CellStatus(dave,DAVECELL) exten => 40,2,GotoIf($["${DAVECELL}" = "1"]?3:5) exten => 40,3,Dial(ZAP/g1/0427466412,45,tT) exten => 40,4,Hangup exten => 40,5,Dial(SIP/40,45,tT) exten => 40,6,Hangup CellStatus sets the value of the given variable to :- 1 = Disconnected. i.e. Cell Phone not in range of Asterisk, or turned off etc etc 2 = Connected and Not on a call. i.e. Free 3 = Connected and on a call. i.e. Busy Debugging :- Different phone manufacturers have different interpretations of the Bluetooth Handsfree Profile Spec. This means that not all phones work the same way, particularly in the connection setup / initialisation sequence. I've tried to make chan_cellphone as general as possible, but it may need modification to support some phone i've never tested. The RIM Blackberry 7250 works extremely well. The LG TU500 WCDMA 3G phone works mostly, be seems to do strange things randomly. If your phone doesnt behave has expected, turn on Asterisk debugging with 'core set debug 3'. This will log a bunch of debug messages indicating what the phone is doing, importantly the rfcomm conversation between Asterisk and the phone. This can be used to sort out what your phone is doing and make chan_cellphone support it. Be aware also, that just about all cell phones behave differently. For example my LG TU500 wont dial unless the phone is a the 'idle' screen. i.e. if the phone is showing a 'menu' on the display, when you dial via Asterisk, the call will not work. chan_cellphone handles this, but there may be other phones that do other things too... Important: Watch what your cell phone is doing the first few times. Asterisk wont make random calls but if chan_cellphone fails to hangup for some reason and you get a huge bill from your telco, dont blame me. Feedback, Support, Please can you make Cell Phone X work... etc :- email me at david.bowerman at gmail.com or dseeb_ on #asterisk & #asterisk-dev irc.