Wednesday 15 May 2013

Mobile phone as asterisk trunk chan_mobile

I found that the existing links explaining chan_mobile in asterisk are not very useful. Recently I have used 35 mobiles together with asterisk for voice calling. The journey was quite challenging and experimental. I thought I would share the hurdles information gathered.

First of all, You should select the mobiles which supports bluetooth handsfree and headset profile. In mycase I have used Nokia C1, Nokia 114 and Philips E112. Nokia C1/114 ,once paired allow automatic paring in case disconnected but in case of philips E112, You need to manually accept pairing request each time. The bluetooth should be switch-on prior to using .

Second, Choose a good blue-tooth dongle with unique MAC address, I have used Asus Bt211, You can get this from ebay.

Third, Choose a good hardware and Linux OS, Fedora 18 with  a dual core /i3/i5 can max support 14 mobile phones. When you are putting the bluetooth dongles into the USB slots, make sure they are in different USB buses. Use bluetooth hub ( 4 port) for extending USB ports. Don't use PCI card for expanding the USB ports, It does not work You can use lsusb to see how your USB buses are distributed. In one bus you should put maximum 7 mobile phones.  Centos, does not work as expected, it does not recognize the Bluetooth dongles, You have use compact mode wireless driver, but after all, there are frequent bluetooth disconnection errors.

Choose the option as development environment while installing Fedora 18.


 Fourth, Softwares, use asterisk 1.8 , You need to install bluez and bluez development package..
yum install bluez
yum install bluez-libs-devel
Start  the asterisk compilation process, make sure you have selected chan_mobile , in addons using make menuselect.
for bluetooth pairing , download bluez-tools source from https://code.google.com/p/bluez-tools/  compile.
You can use hciconfig -a to see all the bluettooth dongles.
Use bt-device -a <bluetooth dongle id> -c <HW> to pair each dongle with the mobile. bt-device -a <bluetooth dongle id> -r <HW> to unpar
HW - Bluetooth Mac address of the Mobile.

use hcitool scan to see the near by mobiles.

You need to create chan_mobile.conf, It is better to automate the process, write a shell script to do that. After a reboot, the order of discovery of bluetooth device changes, so the bluetooh ids also. In Asterisk, each mobile is bound to an bluetooth dongle ( bluetooth id). The pairing has to be done accordingly.  To avoid that, You can make the system to discover as you need. You can remove all the bluetooth dongles and put all in the order, the first that inserted will have hcid0 and so on.. In this way, you don't need to do pairing every time you restart the system. You do paring once ..

chan_mobile.c in asterisk 1.8 provides only a group dialing with the first available mobile, This will be a problem as the bluetooth connections are not very stable, sometimes the mobile will be repeatedly disconnected , causing the channel free frequently. This will cause large number of calls falling on this faulty
connection. With little modification in the chan_mobile.c , it can be made to have the functionality of r1 (round Robin) dialing, Will post the code for this.

The bluetooth dongles goes faulty time to time, you need to reset them, using hciconfig -a hci<id> reset to reset, You can write a script by monitoring the  mobiles. You can do that using asterisk -rx "mobile show devvices", check which mobile has gone wrong and reset the corresponding bluetooth dongle.

Sometime, the bluetooth dongle is not visible by the system. This happens after few hours, If it happens, you need to remove the dongle and put it back....

To make this work, you need few manual interventions, as explained above...  

It works well with few disconnects and voice problem in between.



2 comments:

  1. Nice and honestly about asterisk and bluetooth.

    ReplyDelete
  2. where the source code chan_mobile.c support roundrobin

    ReplyDelete