Building your own home pbx and... more
Notice that the same integration (and a more complete in fact; see the following uhci vs ohci discussion) could be done with the Asus WL500g Premium router.
IVR or not?
I (in fact not me but some relatives ;-) found it a bit annoying to be answered by an IVR when calling my home PBX. So instead of setting an IVR, I took separate phone numbers (DIDs), one for each family member, and redirected the unanswered calls to the personalized voicemails.
But since, I also intend to use this system professionally, some specific numbers are first directed to an IVR, then ring various phones (including my cell phone) and, if unanswered, are redirected to the voicemail.
Last, incoming calls from specific caller ID are used for toll-bypass (with a PIN validation of course).
Universal or Open Host Controller Interface (uhci or ohci)?
The Asterisk dummy USB Zaptel timer module is only available for uhci controllers (like the ones of the Asus WL500X family; the Linksys are ohci-based). This timing module is used for synchronization by the Asterisk Meetme application as well as for IAX2 trunking. If either one is needed, use an uhci-based router.
So the question is to decide to either used IAX or SIP trunking? They are more pros on the IAX side (mostly for the ease of signaling and integration with NAT) but since this project is about a home PBX, SIP signaling will be enough.
Note that such module is not needed if a Zaptel card is used but we are using a router not a PC and there is no expansion slot.
Mp3, wav or GSM ?
If you are planning to play music (for example using the “music-on-hold” commands of Asterisk), be aware that mp3 playing is highly demanding on the router. By far, GSM is the less resource consuming codec but the poor quality may let you go for a mid-range solution like wav. On the other side, for recording voice on the phone GSM is fine.
So basically the solution has three components:
- The router:
1) booting from the external usb 2.0(flash) drive.
2) running Asterisk 1.4 with voicemail support.
- The SIP phones (any will do, including wifi).
- A SIP provider accepting BOYD (Bring Your Own Device) for your PSTN inbound & outbound calls. Personally, I currently use Unlimitel.
The price (as of oct. '07)
- Linksys WRTSL54GS : 110 $.
- An external USB 2.0 flash drive : 10 $ with rebates.
- A SIP phone (either soft or not). I used the Grandstream gxp-200 (currently 80 $ including shipping on ebay) but cheaper can do the job.
TOTAL is 200$ + taxes. For that you will have a professional PBX at home that could be used for many more applications like follow-me, toll-bypass, etc...
1) Install openwrt whiterussian RC6. I choose RC6 for both its bcrm wifi support and x-wrt support... but I'd rather use the latest openwrt release (named kamikaze) for its 2.6 kernel.
% more /etc/ipkg.conf
src asterisk14 http://members.home.nl/hans.zandbelt/openwrt/whiterussian/packages/asterisk-1.4
src rc6-backports http://downloads.openwrt.org/backports/rc6
src whiterussian http://downloads.openwrt.org/whiterussian/packages
src non-free http://downloads.openwrt.org/whiterussian/packages/non-free
src backports http://downloads.openwrt.org/backports/rc5
2) Install nas to enable wifi encryption.
% ipkg install nas
3) If needed, enable ssh (TCP port 22) for the wan interface in /etc/firewall.user and run this script. In case something goes wrong you will still have ssh access.
4) install x-wrt (a more complete web interface to router management).
% ipkg install http://ftp.berlios.de/pub/xwrt/webif_latest_stable.ipk
then, from the x-wrt web interface (http://your_router), configure the router as a AP, client or bridge depending on your network deployment.
5) install QoS from the x-wrt web interface (Network pane) or at the command prompt:
% ipkg install qos-scripts
then prioritize the SIP packets (5060 UDP/TCP) and RTP/RTCP ports used to convey audio (by default ports from 10000 to 20000 in Asterisk). To do so, add two new express rules (rules does no work of you add both port numbers and port ranges in the same).
QoS will be needed on the router to ensure proper bandwidth for the VoIP connections. As a rule of thumb, one connection will need around 100Kbps for good quality.
6) Install the usb support and (if you wish) make the router usb-bootable (see USBStorageHowTo).
You will have to only install usb 2.0 drivers (for the flash disk).
7) Create some swap either on a partition or, as in the example, on a file.
% ipkg install swap-utils
# use the losetup package to create a loop device on a swap file
% ipkg install losetup
# create the swap file: 80Mg seems enough for a 32Mg router.
% dd if=/dev/zero of=/swapfile-80 bs=81920 count=1024
# install the script /etc/init.d/S95swap to make swap available at boot time & reboot.
8) Install Asterisk 1.4(see zandbelt site)
first update the /etc/ipkg.conf file to contain:
% ipkg update
% ipkg install asterisk14 asterisk14-sounds asterisk14-voicemail
First, touch /var/spool/asterisk/astdb or asterisk will not even start... Then run asterisk in CLI mode using /usr/sbin/asterisk -c -vvvv -C /etc/asterisk/asterisk.conf to debug it.
Asterisk will complain (and sometimes won’t start) about missing modules, then you will have to look at the /etc/asterisk/modules.conf file.
For example, music on hold support will require the following modules:
load => res_indications.so ; Indications Configuration
load => res_musiconhold.so ;
Asterisk voicemail, astdb and logs
By default, voicemail and astbd are located in /var/spool/asterisk while logs are located in /var/log/asterisk. In openwrt, /var is linked to /tmp and thus temporary. To avoid this, you will have to either link /var/log and /var/spool to a more permanent location (and don't forget to rebuild the link at startup) or change all references to log or spool in the configuration files to point elsewhere.
In order to forward voicemail by email, a sendmail-syntax-compliant mailer, like mini-sendmail, must be installed.
% ipkg install mini-sendmail
then add in /etc/asterisk/vociemail.conf
mailcmd=/usr/sbin/mini_sendmail -syour-mail-relay -fyour-from@email -t
Alternative voice prompts
Alternative voice prompts are available from various sources, but Nathan Pralle's siteprovides interesting ones specially if you want multi-lingual support with the possibility for the caller to change it dynamically as in the following /etc/asterisk/extensions.conf example:
; default language is French
exten => 123,n,Set(CHANNEL(language)=en)
exten => 123,n,Background(welcome)
exten => 123,n,Background(continue-english-press)
exten => 123,n,Background(digits/star)
exten => 123,n,Set(CHANNEL(language)=fr)
; change language
exten => *,1,Set(CHANNEL(language)=en)
Asterisk GUI support
Package asterisk14-gui can also be installed. But some configurations will be needed to make it work:
1) setting enabled, webenabled and admin account /etc/asterisk/manager.conf
2) setting enabled, enablestatic in /etc/asterisk/http.conf
3) loading app_system.so in /etc/asterisk/modules.conf
4) changing all references to /var/lib/asterisk to /usr/lib/asterisk in all files in /usr/lib/asterisk/scripts and /usr/lib/asterisk/static-http (altermatively link /var/lib/asterisk to /usr/lib/asterisk).
then you will be able to access the gui at http://your_router:8088/asterisk/static/config/cfgbasic.html