Sangoma 语音卡 配置

前几天入手Sangoma的A200语音卡,在CentOS下进行配置,使用FreeSwitch。由于网络上大部分人不是很熟悉这个东西,所以都会选择Asterisk作为系统。

以下是本人配置FreeSwitch经历,

 

在livejournal.com找到一片相关的配置文章。

FreeTDM seems to be replacing OpenZAP now. Following is a quick FreeTDM-based setup to use FreeSWITCH with a Sangoma FXO/FXS card, B600.
We start with minimal CentOS 5.5 install, all options unchecked. After the install is finished,
 

yum -y update

reboot

yum -y install autoconf automake make gcc gcc-c++ bison flex libtool kernel-devel libjpeg-devel libtermcap-devel libogg-devel libvorbis-devel nano ncurses-devel ntp mc wget

remove most 32-bit packages
yum -y remove glibc.i686

remove the rest of i386 packages
yum list installed | grep i386

service iptables save
service iptables stop
chkconfig iptables off
service ip6tables save
service ipt6ables stop
chkconfig ip6tables off

mcedit /etc/selinux/config
change
SELINUX=enforcing
to
SELINUX=disabled

chkconfig ntpd on
ntpdate pool.ntp.org

reboot

cd /usr/src
wget ftp://ftp.sangoma.com/linux/current_wanpipe/wanpipe-3.5.17.tgz
tar xfz wanpipe-*.tgz
cd wanpipe-*
make freetdm
make install

wanrouter hwprobe verbose
cd /usr/src

wget http://files.freeswitch.org/freeswitch-snapshot.tar.gz
tar xfz freeswitch-snapshot.tar.gz
cd freeswitch-snapshot
./bootstrap.sh
./configure
mcedit modules.conf

uncomment ../../libs/freetdm/mod_freetdm (I also uncommented mod_flite, mod_spandsp, mod_shout, mod_pocketshpinx)

make all install
make samples && make cd-sounds-install && make cd-moh-install

/usr/sbin/wancfg_fs
mcedit /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml
add <load module="mod_freetdm"/> (should be in the same section as mod_openzap)
(Again, look for mod_flite, mod_spandsp, mod_shout, mod_pocketshpinx)
Create FreeSwitch start/stop script:
nano /etc/init.d/freeswitch

Put the following into the file (starting from "#! /bin/sh" and up to "exit $RETVAL"):

#! /bin/sh
#
# freeswitch:       Starts the freeswitch Daemon
#
# chkconfig: 345 96 02
# processname: freeswitch
# description: Freeswitch fedora init script \
# config:
# Author: gled
# Source function library.
. /etc/init.d/functions
. /etc/sysconfig/network
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/l
ocal/freeswitch/bin
DESC="FreeSwitch Voice Switching System"
NAME=freeswitch
DAEMON=/usr/local/freeswitch/bin/$NAME
PIDFILE=/usr/local/freeswitch/log/$NAME.pid
do_setlimits() {
        ulimit -c unlimited
        ulimit -d unlimited
        ulimit -f unlimited
        ulimit -i unlimited
        ulimit -n 999999
        ulimit -q unlimited
        ulimit -u unlimited
        ulimit -v unlimited
        ulimit -x unlimited
        ulimit -s 244
        ulimit -l unlimited
        return 0
}
base=${0##*/}
do_start() {
        do_setlimits
        $DAEMON -nc
        RETVAL=$?
        if [ $RETVAL = 0 ]; then
                success $"$base startup"
        else
                failure $"$base startup"
        fi
        echo
        return $RETVAL
}
do_stop() {
        $DAEMON -stop
        RETVAL=$?
        [ $RETVAL = 0 ] && success $"$base shutdown" || failure $"$base shutdown"
        rm -f $LOCKFILE
        echo
        return $RETVAL
}
# See how we were called.
case "$1" in
  start)
        do_start
        ;;
  stop)
        do_stop
        ;;
  restart)
        do_stop
        echo "Waiting for daemon to exit…"
        sleep 5
        do_start
        ;;
  *)
        echo $"Usage: $0 {start|stop}"
        exit 2
        ;;
esac
exit $RETVAL

 

Set attributes:
chmod a+x /etc/init.d/freeswitch
Set startup:
chkconfig –add freeswitch
chkconfig freeswitch on
useradd freeswitch
groupadd freeswitch
chown -R freeswitch:freeswitch /usr/local/freeswitch
mcedit /etc/group

Change the line:
freeswitch:x:500
to:
freeswitch:x:500:freeswitch

mcedit /root/.bash_profile
set PATH variable to:
PATH=$PATH:$HOME/bin:/usr/local/freeswitch/bin

mcedit /usr/local/freeswitch/conf/vars.xml
set global_codec_prefs to allow video, adding H263 and H264 codecs:

<X-PRE-PROCESS cmd="set" data="global_codec_prefs=G7221@32000h,G7221@16000h,G722,PCMU,PCMA,GSM,H263,H264"/>
reboot

do the tests with X-Lite softphone
check using fs_cli command
issue ftdm list and ftdm dump commands while in fs_cli to see spans and channels
!!! for dialplan you need to use span_id and chan_id, not physical_span_id, and not physical_chan_id !!!
close fs_cli with "…" (ellipsis)
Here is the autogenerated freetdm.conf.xml with some additions I’ve made:

<configuration name="freetdm.conf" description="Freetdm Configuration">
<settings>
   <param name="debug" value="0"/>
   <!–<param name="hold-music" value="$${moh_uri}"/>–>
   <!–<param name="enable-analog-option" value="call-swap"/>–>
   <!–<param name="enable-analog-option" value="3-way"/>–>
</settings>
<config_profiles>
</config_profiles>
<analog_spans>
  <span name="FXO">
   <!–<param name="hold-music" value="$${moh_uri}"/>–>
   <param name="dialplan" value="XML"/&gt
;
<!–
   next line commented out as pstn_context is not defined
   <param name="context" value="$${pstn_context}"/>
   next 3 lines added:
–>
   <param name="context" value="default"/>
   <param name="tonegroup" value="us"/>
   <param name="enable_callerid" value="true"/>
   <!– regex to stop dialing when it matches –>
   <!–<param name="dial-regex" value="5555"/>–>
   <!– regex to stop dialing when it does not match –>
   <!–<param name="fail-dial-regex" value="^5"/>–>
  </span>
  <span name="FXS">
   <!–<param name="hold-music" value="$${moh_uri}"/>–>
   <param name="dialplan" value="XML"/>
<!–
   next line commented out as pstn_context is not defined
   <param name="context" value="$${pstn_context}"/>
   next 3 lines added:
–>
   <param name="context" value="default"/>
   <param name="tonegroup" value="us"/>
   <param name="enable_callerid" value="true"/>
   <!– regex to stop dialing when it matches –>
   <!–<param name="dial-regex" value="5555"/>–>
   <!– regex to stop dialing when it does not match –>
   <!–<param name="fail-dial-regex" value="^5"/>–>
  </span>
</analog_spans>
</configuration>
Addition to the default.xml dialplan:
   <extension name="FXS">
     <condition field="destination_number" expression="^2911$">
       <action application="bridge" data="freetdm/1/1"/>
     </condition>
   </extension>
   <extension name="outboundFXO">
     <condition field="destination_number" expression="^(\d{10})$">
       <action application="bridge" data="freetdm/2/1/${destination_number}"/>
     </condition>
   </extension>
  <extension name="inboundFXOto1001">
     <condition field="source" expression="mod_freetdm">
       <action application="transfer" data="1001 XML default"/>
     </condition>
   </extension>

以上是一个老外的日记。

配置完成后发现一些问题,Wanpipe虽然模块启动了,但相关协议没有加载,查看log找到问题,wanpipeX.conf 没有这个文件。

找到Wanpipe的源文件,执行./Setup install 选择TDM Install,系统会询问一些诸如linux-Kernel位置的问题,默认按Enter继续,执行到最后安装成功,会自动检测协议和当前模块,生成自动启动脚本。

执行wancfg进入图形化的配置界面。根据界面提示很容易的就可以创建wanpipe1.conf文件,这样wanpipe模块在启动之后就可以自动加载wanpipeX.conf文件,同样,在Back到wancfg的主配置界面可以继续配置wanpipe2.conf。