FreePBX Multi-Language Directory keeps playing “dir_intro” in English instead of your chosen language? Quick Hack to fix it!
January 13, 2009
Tonight we were debugging a customers PBX system for them because of what seemed like a really simple issue with their company directory. As they are located in a bi-lingual area they wanted to have english and french menus available to them. They use a combination of Asterisk 1.4 and FreePBX 2.5.
With this software they already had the Languages module available to them, so they were able to create one main IVR, and then several branching IVR's dependant on the language that was selected.
In this case, English and French. So, that's all well and good, then we noticed that when you dial the company directory from the French menu, the prompt for the instructions (and only that prompt) is always played in english, instead of our desired language of french. This is really weird. So, we debugged it a little bit and found this in the logs:
-- Executing [3@app-languages:2] Set("DAHDI/1-1", "CHANNEL(language)=fr") in new stack
-- <DAHDI/1-1> Playing 'dir-intro-oper' (language 'fr')
directory|default|from-did-direct|lo: -- Playing 'dir-instr' (language 'en')
Hmm, that's weird - it says it's playing it in french, but it's playing it in english that first time. Then it goes on to correctly say that it's playing the english soundfile, not the french one. Hm, even weirder. So, maybe it's permissions.
We checked the permissions in /var/lib/asterisk/sounds and /var/lib/asterisk/sounds/fr and everything was correct. They were owned by the asterisk user and asterisk group, we don't run as root and neither should you. The permissions were rw-r-r so that was fine too. Hmmmf. So, now we began to search google. We found one post on the subject from the freepbx bug tracker where the user was basically told it was his problem, so, we thought it was our problem too and continued searching for another hour or two trying everything possible:
- Replaced the sound files a couple times, deleting in between
- Re-did the permissions
- Symlinked them to various directories
- Added a hard coding of "fr/" to all soundfiles in the FreePBX AGI - Directory
- Ensured we have support for en and fr enabled
- Manually created the Directory with another Language and Misc Destination in FreePBX (complex!)
- Asked on IRC
Well, if you're reading this, none of that probably worked for you either. So, this is what we did - not sure how "right" it is, but it avoids this issue if you're trying to run your IVR with a company directory in english and french. It's pretty simple too.
First, login to your FreePBX interface.
Then click over to the Tools tab on the left.
Go to Custom Destinations, and Create a new one
Custom Destination: from-internal-custom,s,1
Name: French-Directory
Now press the submit button.
Now Flip over to the Setup Tab of FreePBX and go to your French IVR menu with the Directory in it.
Change the destination to go from the default (#) or whatever you have it set to, to instead go to your new Custom Destination (French-Directory)
Now you're done the setup in FreePBX.
SSH to your PBX system, and then edit the custom extensions file
# sudo nano /etc/asterisk/extensions_custom.conf
Now Paste the following in there
[from-internal-custom]
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Set(LANGUAGE()=fr)
;exten => s,n,AGI(directory,${DIR-CONTEXT},from-did-direct,${DIRECTORY:0:1}${DIRECTORY_OPTS}o)
exten => s,n,Directory(default|from-did-direct|lo)
exten => s,n,Playback(vm-goodbye)
exten => s,n,Hangup()
exten => o,1,Goto(from-internal,${OPERATOR_XTN},1)
Exit and save the file then reload asterisk.
# sudo asterisk -rx "reload"
Now, you should test the calling into your menu to make sure the proper directory is working. Does for us. Comments are open if anyone has better suggestions, or a way to fix the directory agi that comes with FreePBX to properly support the instructions/intro being played in french (or any other language) instead of only english.
Tutorial: Fixing Kayako’s broken SSL so Gmail can be used without STunnel.
December 9, 2008
A little while ago we posted an article on configuring STunnel to use with Kayako because SSL over POP3 with Google Mail/Google Applications wasn't working properly. Today we finally had some time to sit down and think about this and worked out a much better solution that doesn't require STunnel to be involved in the mix.
In the Kayako cron script, they have hard-set a “notls” option when trying to connect to the IMAP or POP3 email servers. It seems when using the imap_open() function in PHP, you must only specify the “notls” option when you explicitly do NOT want any SSL encryption. Since Kayako is forcing the “notls” option on all connection strings, it was cancelling out the “ssl” option that’s enabled when you select pop3-ssl or imap-ssl in your Kayako configuration settings.
As you can see from this sample code here, Kayako is hard setting the “notls” option:
/modules/parser/cron_parser.php:
dbCore->Record4["port"] ."/". $fetchtype ."/notls}
So, in order to make your Kayako installation work with Gmail or Google Apps you must go into the file and change the above into the following (simply remove the “/notls”):
/modules/parser/cron_parser.php:
dbCore->Record4["port"] ."/". $fetchtype ."}
Now make sure you go in and modify your server settings for each support queue:
Pop server: pop.gmail.com
POP Port: 995
Queue Type: POP3-SSL
Now, once you’ve made the changes to test your server, send a couple emails to each of your queues and hit the cron script from a web browser so you can see the debug output. This is done like this:
Testing your server:
http://support.yourserver.com/cron/index.php?_t=parser
We’re not sure why this was hard coded in the original Kayako source, because you can’t use TLS when you specify legacy SSL for a connection, so in effect the “notls” option that was hard coded performed no function except to prevent SSL from ever working in the first place.
The preferred fix would be to use the “notls” option only for POP3 connections that do not require SSL or TLS, and to add an option to the interface to select “IMAP-TLS” and “POP3-TLS” along with the code required to specify “tls” to those connection types (which would force TLS negotiation). Hopefully Kayako is reading this and integrates it to their new release – the hardest part being the addition of the two extra user interface configuration options.
Download the Kayako SSL Patch here if you'd prefer this over manually editing the file mentioned above.
Provision your Cisco 79xx SIP Phone from Active Directory with these Auto Provisioning Scripts
November 6, 2008
Our friend over at Dave.vc has released a new set of scripts for provisioning your Cisco phones from Active Directory.
Visit Dave's site for more awesome tools like this.
You can download the Cisco Provisioning scripts.
Here's his tutorial, and provisioning scripts.
Here are the scripts I use to automatically provision cisco phones via AD information. The phone number (extension) is taken from AD’s ‘phone number’ field and the mac address comes from AD’s ‘IP Phone’ field.
As with the reboot script below, these scripts require PHP to be installed and compiled with LDAP and CLI on the asterisk server. It is possible (obviously) to perform these tasks remotely (not on the asterisk server) but that’s outside the scope of this post.
The PHP script reads the template files and does simple string replacement as needed. If the user is brand new, it adds their voicemail account, picks a psuedo-random extension password and tells asterisk what their email address is for the voicemail-to-email setup. The email information will only be in AD if you put it there or are running an exchange server in the same forest (as in the example).
It’s useful to note that all of the extensions I use in this example setup are in the format of 3xx. We then have another extension of the format 4xx set up to auto-answer so that we can do paging and intercom. You may need to modify if you have more than 100 extensions.
In order to add the extension, we read the config template in the directory listed and perform string replacement:
function add_extension($name,$extension,$secret,$email){
$template = file_get_contents(â€/etc/asterisk/phones/conf.templateâ€);
$template = str_replace(â€<<<mainextension>>>â€,$extension,$template);
$template = str_replace(â€<<<email>>>â€,$email,$template);
$template = str_replace(â€<<<fullname>>>â€,$name,$template);
$template = str_replace(â€<<<secret>>>â€,$secret,$template);
$template = str_replace(â€<<<pageextension>>>â€,â€4?.substr($extension,1),$template);
file_put_contents(â€/etc/asterisk/phones/â€.$extension.â€.confâ€,$template);
}
The XML config file creation/modification follows the same format:
function provision_phone($name,$extension,$secret,$mac){
$template = file_get_contents(â€/tftpboot/SEPCONF.templateâ€);
$template = str_replace(â€<<<mainextension>>>â€,$extension,$template);
$template = str_replace(â€<<<email>>>â€,$email,$template);
$template = str_replace(â€<<<fullname>>>â€,$name,$template);
$template = str_replace(â€<<<secret>>>â€,$secret,$template);
$template = str_replace(â€<<<pageextension>>>â€,â€4?.substr($extension,1),$template);
file_put_contents(â€/tftpboot/SEPâ€.$mac.â€.cnf.xmlâ€,$template);
}
And finally we add the voicemail account:
function add_voicemail($name,$extension,$email){
$template = file_get_contents(â€/etc/asterisk/voicemail.confâ€);
$template .= “\nâ€.$extension.†=> 1234,â€.$name.â€,â€.$email;
file_put_contents(â€/etc/asterisk/voicemail.confâ€,$template);
}
These functions are really rather trivial but save a world of time when it comes to installing 75 new phones in one fell swoop — or even when you’re attempting to maintain continuity between installations separated lots of time.
I attached the the script to this post as well as some screen shots and config templates (SEPCONF and EXTENCONF) to facilitate setting up your AD objects to allow for automatic phone provisioning.
Installing Custom Themes with Trac 10.x. Beautify your Development and set yourself Apart.
November 2, 2008
Ever wanted to install a new theme to your TRAC installation? Often we'll want our development environments to look a little different from every other trac site on the Internet. We'd never tried to change the theme before, so decided to write a small tutorial on how it's done for our archiving purposes, and for anyone else that wants to change their TRAC theme.
We're using Ubuntu Linux, and this tutorial assume you've already installed TRAC on a global basis to your development server.
So, lets get some themes installed on our Trac 10.x installation shall we?
First, install the pre-requisites if not already installed.
# apt-get install python2.5-setuptools
We had to change a couple permissions as well so Trac and everything can read/write where it needs to
# chown -R www-data:www-data /var/www
Now we had to install WebAdmin for Trac 10.x:
# svn export http://svn.edgewall.com/repos/trac/sandbox/webadmin/
# cd webadmin
# python setup.py bdist_egg
# easy_install -Z dist/*.egg
Note that WebAdmin is included with Trac 11.x if you're bleeding edge, you probably don't need this.
Now we had to install ThemeEnginePlugin for Trac 10.x:
# svn checkout http://trac-hacks.org/svn/themeengineplugin
# cd themeengineplugin
# cd 0.10
# python setup.py bdist_egg
# easy_install -Z dist/*.egg
Now, lets install some themes for Trac 10.x:
# svn checkout http://trac-hacks.org/svn/pydotorgtheme/
# cd pydotorgtheme/0.10/
# python setup.py bdist_egg
# easy_install -Z dist/*.egg
# cd ../../
# svn checkout http://trac-hacks.org/svn/gamedevtheme/
# cd gamedevtheme/0.10
# python setup.py bdist_egg
# easy_install -Z dist/*.egg
# cd ../../
# svn checkout http://trac-hacks.org/svn/consultanttheme/
# cd consultanttheme/0.10
# python setup.py bdist_egg
# easy_install -Z dist/*.egg
# cd ../../
Now we added the following to our Trac.ini within the project we want the themes to be used for:
# cd /var/local/trac/trac.yourdomain.com/conf/
# nano trac.ini
Add this to the components section of your configuration file
[components]
webadmin.* = enabled
themeengine.* = enabled
Then we restarted Apache and we were able to select themes to make available, and attach to our Trac Installation. Note that with each new theme added, you will have to restart Apache in our experience.
This should get you going with installing some themes for Trac on your Ubuntu Linux server. Have Fun!
Tutorial on how to Install Apache, Subversion and Trac with Virtual Hosting suppor in Ubuntu Linux
November 2, 2008
We recently had to setup Apache, Subversion and Trac all within a virtual hosting environment for one of our Clients to be able to develop easily and effictively among team members. They wanted to use multiple domain names for separate projects. Made sense to us, so we started looking for instructions on setting this up.
We wanted to setup LigHTTPD, however it's not nearly as easy because of no svn-dav module available, so we stuck with Apache 2 for now.
We found a howto on doing this, however there were a few vital steps and explanations missing so we've re-written it in hopes it will help others the trouble of searching to find this information.
So, lets move on to the tutorial shall we.
First install the required packages on your system. We started with a clean Ubuntu JEOS 8.0.4 Install on our server.
# sudo aptitude install enscript libapache2-mod-python python-docutils trac db4.3-util libapache2-svn subversion-tools
Now create a virtual host for your SVN container.
# mkdir -p /var/local/svn/svn.yourdomain.com
Now create a development group, and add the web user to it.
# addgroup svngroup; adduser www-data svngroup
Now Add a user to the system and add them to that group
# adduser username
# passwd username
Now add that user to the group required for SVN
# adduser username svngroup
Now setup the permissions for your SVN site.
# chmod 2770 /var/local/svn/svn.yourdomain.com
Now setup the repo as you normally would
# svnadmin create /var/local/svn/svn.yourdomain.com
Remove the current password file. We're using HTTPS (or HTTP) instead of SVNSERVE so no need for it.
# rm /var/local/svn/svn.yourdomain.com/conf/passwd
# touch /var/local/svn/svn.yourdomain.com/conf/passwd
Allow your group to write to the repo
# chmod -R g+w www-data:svngroup /var/local/svn/svn.yourdomain.com
Now set the repo access permissions.
# nano /var/local/svn/svn.yourdomain.com/conf/authz
It should look something similar to the following. If in doubt, refer to the Path-Based Auth section of Subversion.
[groups]
svngroup = username1,username2,username2
[/]
@svngroup = rw
Now, create a log directory within apache for your development site.
# mkdir /var/log/apache2/svn.yourdomain.com
Now create your virtual host.
# nano /etc/apache2/sites-available/svn.yourdomain.com
Copy the following in, editing to suit your environment. Note we're using a self signed certificate, you can change this to a properly signed one if you have it.
<VirtualHost [server's IP address]:443>
ServerName svn.yourdomain.com
<Location />
DAV svn
AuthType Basic
AuthName "svn.yourdomain.com"
AuthUserFile /var/local/svn/svn.yourdomain.com/conf/passwd
AuthzSVNAccessFile /var/local/svn/svn.yourdomain.com/conf/authz
SVNPath /var/local/svn/svn.yourdomain.com
Require valid-user
</Location>
CustomLog /var/log/apache2/svn.yourdomain.com/access.log combined
ErrorLog /var/log/apache2/svn.yourdomain.com/error.log
SSLEngine on
SSLCertificateFile /etc/ssl/certs/selfsigned.pem
# Add this once there is a real (non self-signed) certificate.
# SSLCertificateKeyFile /etc/apache2/ssl/server.key
</VirtualHost>
<VirtualHost [server's IP address]:80>
ServerName svn.yourdomain.com
Redirect / https://svn.yourdomain.com/
</VirtualHost>
Now, enable the site
# a2ensite svn.yourdomain.com
Now, create a username and password to access the svn site.
# htpasswd /var/local/svn/svn.yourdomain.com/conf/passwd username1
Now, create your SSL certificate. Details are here if you need them.
# sudo aptitude install ssl-cert
Now, we found out that the default Ubuntu SSL cert is only for 30 days, so, we changed this to be 365 a little more sane no? Thanks for the tip Devio.
# which make-ssl-cert
/usr/sbin/make-ssl-cert
# nano /usr/sbin/make-ssl-cert
Replace the line near the bottom that looks like this
openssl req -config $TMPFILE -new -x509 -nodes -out $output -keyout $output
With a line that looks like this instead
openssl req -config $TMPFILE -new -x509 -days 365 -nodes -out $output -keyout $output
Exit and save the file. Now we're ready to generate our final self signed SSL certificate for Apache on Ubuntu. Like this;
# make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/ssl/certs/selfsigned.pem
Make sure to set your "common name" to your server name - ie: svn.yourdomain.com
Now you can go ahead and restart Apache to verify your DAV enabled SVN site functions.
# /etc/init.d/apache2 restart
To verify, hit it's url in a browser
If everthing was successful, you now have SVN setup, with WEB-Dav support in Apache2 on Ubuntu. Continue to setup Trac.
First we have to create the web directory for Trac.
# mkdir -p /var/local/trac/trac.yourdomain.com
Now we setup the permissions
# chmod 2770 /var/local/trac/trac.yourdomain.com
Create a Trac instance for your project
# trac-admin /var/local/trac/trac.yourdomain.com initenv
Setup the proper ownerships for the directory
# chown -R www-data:svngroup /var/local/trac/trac.yourdomain.com
Now make sure the group is added to the repo
# chmod -R g+w /var/local/trac/trac.yourdomain.com
Configure Trac where required
# nano /var/local/trac/trac.yourdomain.com/conf/trac.ini
Create a directory for log files
# mkdir /var/log/apache2/trac.yourdomain.com
Now create a virtual host for your trac instance
# nano /etc/apache2/sites-available/trac.yourdomain.com
Now, copy the following into the virtual host configuration, changing to suit your domain and configuration
# Trac Configuration
<VirtualHost [server's IP address]:80>
ServerName trac.yourdomain.com
Redirect / https://trac.yourdomain.com/
</VirtualHost>
<VirtualHost [server's IP address]:443>
ServerName trac.yourdomain.com
DocumentRoot /var/local/trac/trac.yourdomain.com/
Alias /trac/ /usr/share/trac/htdocs
<Directory "/usr/share/trac/htdocs/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Location />
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonInterpreter main_interpreter
PythonOption TracEnv /var/local/trac/trac.yourdomain.com/
PythonOption TracUriRoot /
AuthType Basic
AuthName "trac.yourdomain.com"
# Use the SVN password file.
AuthUserFile /var/local/svn/svn.yourdomain.com/conf/passwd
Require valid-user
</Location>
CustomLog /var/log/apache2/trac.yourdomain.com/access.log combined
ErrorLog /var/log/apache2/trac.yourdomain.com/error.log
SSLEngine on
SSLCertificateFile /etc/ssl/certs/selfsigned.pem
# Add this once there is a real (non self-signed) certificate.
# SSLCertificateKeyFile /etc/apache2/ssl/server.key
</VirtualHost>
Now, enable this virtual host as well
# a2ensite trac.yourdomain.com
Configure Trac Permissions for your Trac instance.
# trac-admin /var/local/trac/trac.yourdomain.com
Use the following commands to view permissions, and set permissions.
"help permission"
We set the following permissions to one of our users from the command line
# trac-admin /var/local/trac/trac.yourdomain.com permission add username1 TRAC_ADMIN
Now you're ready to restart Apache with your new Trac VHOST.
# /etc/init.d/apache2 restart
Now you're ready to restart Apache and visit your Trac installation
Login with your user (username1) and password you setup earlier.
We hope this tutorial helps others when trying to setup SVN and Trac on Ubuntu with Virtual Hosts. Let us know if you have any other handy tips!
Howto Setup Emergency Queues with Separate Outbound PRI channel using FreePBX and Ring Groups.
October 31, 2008
One of our clients recently had a question about his system using FreePBX 2.5.1 and Asterisk 1.4 regarding using specific lines to reach staff.
He runs a support queue for his company. During the day he has a regular IVR with Call queues enabled to handle customer calls and direct them to the appropriate staff member to deal with customer inquiries etc. After hours the menu functions the same way, however there are less staff to answer the phones so mainly the emergency extension is the only one being monitored, for - well, emergencies!
Of course, the people monitoring for emergencies don't want to get a call on their blackberry asking what the company address is at 4 o'clock in the morning. So our client wanted the ability to set his system up so all calls to the emergency queue would be directed out a specific channel on his DID with a specific CallerID.
This enables his staff to set their cell phones to "ignore all calls except for those from this number". Of course they set "this number" to the one being used by the outbound PRI channel on the PBX.
Setup of is type of scenario is detailed below.
1. Login to your FreePBX Control Panel.
2. Go to the Trunks Menu and add a new ZAP trunk. Note this is different if you're using SIP or IAX. Here, we're using a T1 PRI.
3. When you create the new trunk, put in the following configuration variables.
Outbound Caller ID: "emer" <5555551212>
Never Override CallerID: <checked>
Maximum Channels: <set to max cellular phones used>
Disable Trunk: <unchecked>
Dial Rules: .
Outbound Dial Prefix: <blank>
Zap Identifier: g2
4. Your new trunk is now created in Asterisk.
5. Click on the Outbound Routes link item on the left of the FreePBX Control Panel.
6. Add a new Route and put in the following information:
Route Name: Emergency
Route Password: <blank>
PIN Set: None
Emergency Dialing: <unchecked>
Intra Company Route: <unchecked>
Music On Hold: Default
Dial Patters:2133|NXXXXXX
2133|NXXXXXXXXX
Trunk Sequence: g2
Note the above and the "2133" used. This number can be anything you want, we just chose something we knew wouldn't be used in the next step of the configuration. This number will get stripped out before getting sent out the trunk so it's really not a big deal what you pick here. Just use something that won't be used anywhere.
7. Click on Submit changes in this menu to add your new route
8. Click on the Ring Groups Menu on the left side of FreePBX 2.5.1 Interface
9. Edit, or Create a new Ring Group for the Emergency Group and ensure that it has the following settings along with your own configuration customizations if you have made them (merge these in):
Ring Strategy: Ringall
Ring Time: 50 Seconds (Time appropriately for Cell Voicemail!)
Extension List:21335555551212#
21335555551212#Announcement: Change to your own if you want
Play MOH: Ring
CID Name Prefix: CompanyName
Confirm Calls: Checked
Remote Announce: Same as "Announcement"Destination if no answer: Hangup (or whatever you need)
Note that the 2133 prefix's the cellular phone example numbers above. If you changed that earlier make sure to change it here when you're changing the mobile phone number.
10. Click on the submit button and you're done adding your ring group to the configuration for this portion.
11. Click the "Queues" button on the left side of the FreePBX Management Interface and either modify or create a new queue for your Emergency staff.
12. When creating the new Queue use similar information to the following:
Queue Number: A extension for queue
CID Name: EMR-
Wait Time: No
Alert Info: Blank
Static Agents:1234,0
Note that 1234 in this section is the number of your Ring Group used for the Emergency Dialing feature for Outbound calls.
Set your Agent Timeout to something respectible.
Agent Timeout: 40 seconds
Keep scrolling down the settings and set the "fail over destination" to your Emergency Queue (to itself).
13. Now you should ssh to the FreePBX server and create a change in the zaptel/dahdi configuration.
14. Edit the file like this
# nano /etc/asterisk/zapata.conf
15. Change it to something like this matching your system. We originally were using all 23 channels for the main line. Now we've separated it out into two groups (g1 and g2). G2 is the Trunk you setup earlier.
So, we started with:
group = 1
context=ext-did
switchtype=national
signalling=pri_cpe
stripmsd=1
channel=1-23
We ended with:
group = 1
context=ext-did
switchtype=national
signalling=pri_cpe
stripmsd=1
channel=1-22group = 2
context=ext-did
switchtype=national
signalling=pri_cpe
stripmsd=0
channel=23
16. Exit and save the zapata.conf file.
17. Now you are ready to add this to your IVR menu and start testing.
18. Go back to FreePBX and go to the IVR menu option on the left of the Administration Panel. Find your IVR menu tree and add a new menu option to it that will dial your Emergency Queue.
19. You're done. Give your menu a call, and hit the emergency queue!
If it doesn't work, try the instructions again. If it still doesn't work, leave us a comment and we'll try to give you hand. Have you done something similar with FreePBX and Asterisk? Tell us about it below, we'd love to hear what other cool things people are doing.
We hope you enjoyed this howto!
Installing and Configuring chan_mobile for Bluetooth Presence support in Asterisk 1.6
October 30, 2008
Following this tutorial on how to get Chan_Mobile working with Asterisk for Bluetooth support for our headsets and mobile phones we worked out how to get it working on Asterisk 1.6.
We figured we would share this information with our readers incase they were interested in Bluetooth for Asterisk and the capabilities it will open up to their system. Just think, the server will know when you're in the room or out of the office and other fancy things.
First you should make sure that your Bluetooth Dongle works with Asterisk, and that your Cellular Phone is known to work with Asterisk and Bluetooth. You can verify all this information over at the Voip-Info Chan_Mobile page.
Requirements:
- Asterisk PBX
- Bluetooth Support (Motherboard or Dongle)
- Cellular Phone with Bluetooth support
- Bluez Bluetooth Libraries and Development Headers
Tutorial:
So, first we have to install some pre-requisite software. We'll assume that you already have Linux installed, your kernel is compiled, Asterisk is installed and working, and that you have a basic familiarity with Linux commands. We've written this tutorial for Ubuntu, using FreePBX so instructions may change based on your OS or Asterisk Configuration GUI.
So, lets get down to business shall we.
First, install Bluez Utilities on your Server
# apt-get install bluez-utils bluez-hcidump
Now Configure Bluez to work with your server and dongle. We won't go into depth on this as it mostly "just works" but there are ample tutorials and documentation if your dongle is a little finiky on your system.
Now, open up the file hcid.conf in the Bluetooth configuration directory, and match the contents to the following.
# nano /etc/bluetooth/hcid.conf
Erase the contents, and replace it with this
# HCId options
options {
autoinit yes;
security auto;
pairing multi;
passkey "1234";
}device {
name "Our PBX System";
class 0x3e0100;
iscan enable; pscan enable;
discovto 0;
lm accept;
lp rswitch,hold,sniff,park;
}options {
autoinit yes;
security auto;
pairing multi;
pin_helper /etc/bluetooth/pin;
}
Note you can also experiment with making Asterisk a handsfree headset, but we won't go over this in this tutorial. The following lines can be added to your hcid.conf in replacement of the "Our PBX System" device mentioned above if you want to try this:
device {
name "Asterisk";
class 0x200404;
iscan enable;
pscan enable;
lm accept;
lp rswitch,hold,sniff,park;
}
Now that our bluetooth is configured, we can go back to configuring Asterisk to work with Chan Mobile for Bluetooth Support. We'll assume you already have Asterisk 1.6 running on your machine for this to work. If not, compile it and instal it!
Now, Enter the directory with your Asterisk-Addons 1.6 source.
# cd /opt/asterisk/asterisk-addons-1.6.0/
Issue your configure line
# make distclean
# ./configure --with-bluetooth
Now, issue the configure menu tree
# make menuselect
Now, on the left hand side, hit the down arrow button until you get to the Channel Drivers section. On the right hand side, you should see "chan_mobile" with a little "*" next to it telling us it's enabled.
[*] chan_mobile
If you don't, pretty right on your arrow keys, and then press the enter key to select chan_mobile. Exit the configuration menu by pressing F12 to save your changes.
Now, build Asterisk-Addons 1.6 as you normally would
# make
# make install
This will place chan_mobile.so into /usr/lib/asterisk/modules so the next time you start Asterisk it will be available.
We're pretty much done the "difficult" stuff now, and just need to go on and start bluetooth on our system and then configure Asterisk to work with it.
So, start up bluetooth
# /etc/init.d/bluetooth start
Now, lets make sure that Bluetooth is running and sees our devices
# hcitool dev
This should output some information like this:
Devices:
hci0 00:50:B6:80:34:DD
Make a note of the "hardware" address in a text file or somewhere handy because we will need it later. The hardware address is the one that looks like a MAC address. In this case it's "00:50:B6:80:34:DD" note that your system will be different.
Now, lets edit Asterisk's mobile configuration file
# nano /etc/asterisk/mobile.conf
Add your Bluetooth Adapter to the file like this, using the Hardware ID from the hcitool command you ran above. There should already be an entry that looks similar to this (with an id=blue) just replace the hardware ID in this entry with yours.
[adapter]
id=blue
address=00:50:B6:80:34:DD
;forcemaster=yes
;alignmentdetection=yes
Now exit and save the file.
Before we forget, we should add bluetooth to the startup options of the server if it's not already there. Do so like this;
# update-rc.d bluetooth defaults
Now, in order for other devices to be able to see your server and vice-versa we have to make it discoverable. That's done with the following command.
# dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetMode string:discoverable
The fun begins right about now. Go and get your mobile phone. Turn bluetooth on on the phone. You should see your Asterisk PBX in the list of discoverable devices. Double click on it to add it to your device, and input the security key of 1234 when prompted.
Note that on our windows mobile 6.1 devices, after adding the Asterisk PBX to our bluetooth list, we also had to click on it and then hit refresh services list a few times until it showed us "Bluetooth Headset" as a list of supported options. We selected it on the screen, and closed the bluetooth configuration on our HTC Tytn II (Kaiser) test devices.
Now it's time to make your phone discoverable so the PBX can attach to it. Go back to your phone, and find the option to enable bluetooth discovery. Turn it on.
Now from the Asterisk Server Command Line we should be able to issue this command to search for our Bluetooth Mobile Phone.
# hcitool scan
It should show you a list of results like this
Scanning ...
00:16:BC:1F:E1:E8 Phone1
00:17:83:6F:BD:51 Phone2
In our example, we'll only be connecting to Phone2. One finicky thing we noticed is that if you want to connect more than one mobile phone at a time, you need a dongle to match. So, for example if you want to connect 5 bluetooth mobile phones, you would also need 5 bluetooth dongles, and 5 free USB ports (or a USB HUB) to get it all working. We've never tried with more than 2 bluetooth phones, so your mileage may vary.
If you don't see your phone, something is wrong - try the above steps again to see if it fixes it.
Now continue on by stopping Asterisk PBX, and reloading it to take advantage of our new chan_mobile module.
# /etc/init.d/asterisk stop
Now start Asterisk in debug mode so you can verify everything is working.
# asterisk -vvvvvvvvvvvvvgc
Now type this command on the Asterisk CLI to find your mobile devices
*CLI> mobile search
You should see something similar to the following
Address Name Usable Type Port
00:17:83:6F:BD:51 Phone2 Yes Phone 2
00:13:33:44:4d:23 Phone1 Yes Phone 5
The above is a listing of all Bluetooth devices available to your Asterisk PBX.
- The Address Field is the Device Identifier Code (MAC Address)
- The Name Field holds the name of the device (Phone1)
- The Usable Field tells us if the phone is Usable by Asterisk or not (Yes/No)
- The Type Field tells us if it's a Phone (FXO) or a Headset (FXS) device
- The Port Field tells us which port the phone is using
Make a note of this information and continue on to the next step.
Now, exit Asterisk by typing "stop now" on the command line
*CLI> stop now
You'll be back at the CLI now.
In our example, we'll be using Phone2 to configure to work with Asterisk.
Go back and edit your mobile configuration file in /etc/asterisk to look similar to this
# nano /etc/asterisk/mobile.conf
Add something similar to the following below the adapter configuration you added earlier in the tutorial.
[TytnII]
address=00:17:83:6F:BD:51
port=2
context=from-pstn
adapter=blue
;group=1
If you are configuring a headset, the line would look something like this instead
[headset]
address=xx:xx:xx:xx:xx:xx ; the address of the headset
port=x ; the port number
type=headset ; tells asterisk it is a headset
adapter=blue ; adapter to use
Now you can start asterisk again. I would start it in debug mode so you can verify your phone is connected.
# asterisk -vvvvvvvvvvvvvvvgc
You should see messages similar to the following on the Asterisk Console letting you know your device has connected to Asterisk
-- Bluetooth Device TytnII has connected.
-- Bluetooth Device TytnII initialised and ready.
And if you issue the show devices command
*CLI> mobile show devices
You should see something like this
ID Address Group Adapter Connected State SMS
TytnII 00:17:83:6F:BD:51 0 blue Yes Free No
This means your phone is now connected to Asterisk. Depending on the context you put it in, if a call comes in to your cellular phone and you are within proximity of your Asterisk server it should route over to your one of your SIP extensions. Asterisk will automatically pair and unpair with your mobile phone as you come in and out of range respectively. Cool huh?
It is worth it to mention this warning from the original article as well: "Important: Watch what your cell phone is doing the first few times. Asterisk won’t make random calls but if chan_mobile fails to hang up for some reason and you get a huge bill from your telco, don’t blame me."
Hope you enjoyed this tutorial, let us know if you have any comments or other fun ideas to do with chan_mobile, bluetooth and Asterisk in the comments!



