设为首页 收藏本站
开启辅助访问 切换到宽版
注册会员 找回密码

VoIP88

james.zhu 发表于 2013-8-1 09:10 | 显示全部楼层 |阅读模式


介绍
FreeSWITCH 是目前非常流行的开源软交换平台,支持IPPBX,软交换调度,IVR系统,呼叫中心等等解决方案,同时支持PSTN的接入方式。Sangoma 模拟语音卡可以通过FreeTDM 模块和freeSWITCH 实现通信。
本文章介绍如何在FreeSWITCH linux 环境下安装配置Sangoma A200/A400。本例中使用了A400的2FXO 板卡。我们重点介绍如何安装Sangoma wanpile 驱动,FreeTDM,FreeSWITCH,和配置语音板卡以及简单的呼叫路由规则。
请用户必须按照文章介绍的流程进行安装->配置->调试->呼叫测试。
准备工作
[size=0.857142857]FXS (1,2) FXO (3,4)

[size=0.857142857]1/2/3/4 FXO


[size=0.857142857]A200 通过连接器垫加,增加板卡模块


[size=0.857142857]A400 模拟卡外观说明


下载安装Sangoma 板卡驱动 wanpipe下载最新Sangoma 板卡驱动软件包
wget ftp://ftp.sangoma.com/linux/current_wanpipe/wanpipe-current.tgz
解压压缩包
tar xfz wanpipe-current.tgzcd wanpipe-<version>.tgz
编译板卡驱动和freetdm
执行编译安装命令
make freetdm
make install
检测板卡硬件
执行以下命令,检查板卡状态
[root@localhost ~]# wanrouter hwprobe
-------------------------------| Wanpipe Hardware Probe Info |-------------------------------
1 . AFT-A400-SH : SLOT=4 : BUS=3 : IRQ=5 : CPU=A : PORT=PRI : HWEC=0 : V=11Sangoma Card Count: A200=1[root@localhost ~]#[root@localhost bin]# wanrouter status
Devices currently active:        wanpipe1Wanpipe Configevice name | Protocol Map | Adapter  | IRQ | Slot/IO | If's | CLK | Baud rate |wanpipe1    | N/A          | A200/A400/B600/B700/B800/B610| 169 | 4       | 1    | N/A | 0         |Wanrouter Statusevice name | Protocol | Station | Status        |wanpipe1    | A-ANALOG | N/A     | Connected     |[root@localhost bin]#

下载安装配置FreeSWITCH安装linux Centos 支持包
yum install expat-devel openssl-devel libtiff-devel libX11-devel unixODBC-devel libssl-devel python-devel \      
          zlib-devel libzrtpcpp-devel alsa-lib-devel libogg-devel libvorbis-devel perl-libs gdbm-devel \            
          libdb-devel uuid-devel @development-tools
安装git 以后,使用git 安装 freeSWITCH
安装FreeSWITCHgit clone git://git.freeswitch.org/freeswitch.git  
cd freeswitch  
./bootstrap.sh
编译前,添加freetdm 模块,编辑modules.conf 文件,注释掉libs/freetdm/mod_freetdm 模块,保存文件。 执行
./configure
make
make install
make all install cd-sounds-install cd-moh-install // 安装语音文件和语音等待文件配置Sangoma 板卡文件
执行 /usr/sbin/wancfg_fs 命令,启动配置脚本,通过选项来一步步配置板卡
[root@localhost sbin]# wancfg_fs#########################################################################                          Sangoma Wanpipe                                  ##        Dahdi/Zaptel/SMG/TDMAPI/BOOT Configuration Script             ##                             v2.39                                    ##                     Sangoma Technologies Inc.                        ##                        Copyright(c) 2013.                            #########################################################################Would you like to change FreeSWITCH Configuration Directory?
Default: /usr/local/freeswitch/conf1. NO2. YES[1-2, ENTER='NO']:1  // 选择默认安装目录-------------------------------------------------------Configuring T1/E1 cards [A101/A102/A104/A108/A116/T116]-------------------------------------------------------No Sangoma ISDN T1/E1 cards detectedPress any key to continue:-------------------------------------------Configuring ISDN BRI cards [A500/B500/B700]-------------------------------------------No Sangoma ISDN BRI cards detectedPress any key to continue:------------------------------------Configuring GSM cards [W400]------------------------------------No Sangoma GSM cards detectedPress any key to continue:------------------------------------Configuring analog cards [A200/A400/B600/B610/B700/B800]-----------------------------------------------------------------------------------------------A400 detected on slot:4 bus:3-----------------------------------------------------------

Would you like to configure AFT-400 on slot:4 bus:31. YES2. NO[1-2]:1   // 选择yes
Which codec will be used?1. MULAW - North America
2. ALAW - Europe[1-2]:2  // ALAW
Which Operation Mode will be used?1. FCC2. TBR213. AUSTRALIA[1-3, ENTER='FCC']: 1   // 无中国制式,暂时选择FCC。
如果修改到中国制式,修改/etc/wanpipe/wanpipe1.conf 文件 的 TDMV_OPERMODE   = CHINA
Press any key to continue:AFT-400 configured on slot:4 bus:3 span:1Analog card configuration completePress any key to continue:------------------------------------Configuring USB devices [U100]------------------------------------####################################################################                             SUMMARY                             ####################################################################  0 T1/E1 port(s) detected, 0 configured  0 ISDN BRI port(s) detected, 0 configured  1 analog card(s) detected,
1 configured  0 GSM card(s) detected, 0 configured  0 usb device(s) detected, 0 configured
Configurator will create the following files:        1. Wanpipe config files in /etc/wanpipe      
  2. freetdm config file /usr/local/freeswitch/conf/freetdm.conf     
   3. freetdm_xml config file /usr/local/freeswitch/conf/freetdm.conf.xmlYour configuration has been saved in /etc/wanpipe/debug-2013-07-31.tgz.When requesting support, email this file to techdesk@sangoma.com###################################################################Configuration Complete!
Please select following:1. YES - Continue 2. NO - Exit[1-2]:
1  // 选择继续
Wanpipe configuration complete: choose action
1. Save cfg: Stop Wanpipe now
2. Do not save cfg:
Exit[1-2]:1  // 选择立即停止wanpipesh: asterisk: command not foundsh: asterisk: command not foundStopping Wanpipe...Removing old configuration files...Copying new Wanpipe configuration files...Copying new freetdm configuration files (/usr/local/freeswitch/conf/freetdm.conf)...Copying new freetdm configuration files (/usr/local/freeswitch/conf/autoload_configs/freetdm.conf.xml)...Wanrouter start complete...Current boot level is 3Wanrouter boot scripts configuration...Removing existing wanrouter boot scripts...OK
Would you like wanrouter to start on system boot?1. YES2. NO[1-2]:
1   // 选择系统自动启动Verifying Zaptel
boot scripts...Enabling wanrouter boot scripts ...(level:8)Enabling wanrouter shutdown scripts ...(level:91)Sangoma cards configuration complete, exiting...[root@localhost sbin]# rebootBroadcast message from root (pts/1) (Wed Jul 31 20:13:04 2013):The system is going down for reboot NOW![root@localhost sbin]#
检查配置freetdm.conf文件
这是FreeTDM 配置文件.
编辑:/usr/local/freeSWITCH/conf/freetdm.conf 文件
[span wanpipe FXO]
name => freetdm
trunk_type => fxo
group => grp2
fxo-channel => 1:7
number => 29193553   // 必须设置线路电话号码
trunk_type => fxo
group => grp2
fxo-channel => 1:8
number => 29193554   // 必须设置线路电话号码
编辑freetdm.conf.xml
autoload_configs/freetdm.conf.xml
<configuration name="freetdm.conf" description="FreeTDM Configuration">
<settings>    <param name="debug" value="0"/>
   <param name="hold-music" value="$${moh_uri}"/>
</settings>  <!-- one entry here per freetdm span -->
<analog_spans>    <span name="FXS">      
<!-- This is where the calls coming on this sapn will be directed -->      <param name="dialplan" value="XML"/>      <param name="context" value="fxs-ports"/>      
<param name="enable_callerid" value="true"/> <!-- This is the default value anyway -->
   </span>    <span name="FXO">  
    <param name="dialplan" value="XML"/>      
<param name="context" value="public"/>      
<!-- Set this to the correct value for your area, to get the           correct tones on the phones connected to the FXS ports -->      
<param name="tonegroup" value="cn"/>   // 设置到中国制式      
<param name="enable_callerid" value="true"/>   
</span>
</analog_spans>
</configuration>
在默认的FreeSWITCH 启动模块中添加添加freetdm 模块
编辑文件 vi /usr/local/freeswitch/conf/autoload_configs/modules.conf.xml 删除注释,确认freetdm 模块已经被添加
<load module="mod_freetdm"/>
检查ftdm 模块加载状态
运行 fs_cli 命令,进入到
freeSWITCH CLI
freeswitch@internal> ftdm list
+OKspan: 1 (FXO)type: analog
physical_status: ok
signaling_status: UPchan_count: 2
dialplan: XMLcontext: publi
cdial_regex:fail_dial_regex:
hold_music:analog_options: none
freeswitch@internal> ftdm dump 1 1span_id: 1   
  chan_id: 1physical_span_id: 1
physical_chan_id: 7  physical_status: ok
physical_status_red: 0
physical_status_yellow: 0
physical_status_rai: 0
physical_status_blue: 0
physical_status_ais: 0
physical_status_general: 0
signaling_status: UP
type: FXOstate: DOWN
last_state: HANGUP
txgain: 0.00rxgain: 0.00
cid_date:cid_name:
cid_num:ani:
aniII:
dnis:
rdnis:cause: NON
Esession: (none)-- States --                   -- Function --                 -- Location --                 -- Time Offset --RING  => HANGUP                [channel_on_hangup]            [mod_freetdm.c:590]            0msHANGUP => DOWN                 [ftdm_analog_channel_run]      [ftmod_analog.c:562]           515msDOWN  => DIALING               [analog_fxo_outgoing_call]     [ftmod_analog.c:62]            161968msDIALING => UP                  [ftdm_analog_channel_run]      [ftmod_analog.c:509]           7900msUP    => HANGUP                [channel_on_hangup]            [

确认freetdm 模块已经加载。

设置呼入路由规则呼入路由设置

修改拨号规则的配置文件 dialplan/public/00_inbound_did.xml

<include>  
<extension name="public_did">   
<condition field="destination_number" expression="^(29293553)$">  // 29293553 是FXO 线路号码,必须和freetdm.conf 对应       <action application="set" data="domain_name=$${domain}"/>   
  <action application="transfer" data="1002 XML default"/>     // 分机接听   
</condition>
</extension>
</include>

此设置会让一个FXO 线路呼入的电话转接到分机1002.当然你需要注册分机1002. 呼入以后匹配29293553。系统呼叫log

2013-07-31 20:57:17.860189 [DEBUG] switch_channel.c:2116 (FreeTDM/1:1/) Callstate Change DOWN -> RINGING2013-07-31 20:57:17.860189 [DEBUG] switch_core_state_machine.c:471 (FreeTDM/1:1/) State ROUTING2013-07-31 20:57:17.860189 [DEBUG] mod_freetdm.c:453 FreeTDM/1:1/ CHANNEL ROUTING2013-07-31 20:57:17.860189 [DEBUG] mod_freetdm.c:456 [s1c1][1:7] Indicating PROCEED in state RING2013-07-31 20:57:17.860189 [DEBUG] switch_core_state_machine.c:117 FreeTDM/1:1/ Standard ROUTING2013-07-31 20:57:17.860189 [INFO] mod_dialplan_xml.c:558 Processing unknown <18665301040>-> in context publicDialplan: FreeTDM/1:1/ parsing [public->public_did] continue=falseDialplan: FreeTDM/1:1/ Regex (FAIL) [public_did] destination_number() =~ /^(29193553)$/ break=on-falseDialplan: FreeTDM/1:1/ parsing [public->unloop] continue=falseDialplan: FreeTDM/1:1/ Regex (PASS) [unloop] ${unroll_loops}(true) =~ /^true$/ break=on-falseDialplan: FreeTDM/1:1/ Regex (FAIL) [unloop] ${sip_looped_call}() =~ /^true$/ break=on-falseDialplan: FreeTDM/1:1/ parsing [public->outside_call] continue=trueDialplan: FreeTDM/1:1/ Absolute Condition [outside_call]Dialplan: FreeTDM/1:1/ Action set(outside_call=true)Dialplan: FreeTDM/1:1/ Action export(RFC2822_DATE=${strftime(%a, %d %b %Y %T %z)})Dialplan: FreeTDM/1:1/ parsing [public->call_debug] continue=trueDialplan: FreeTDM/1:1/ Regex (FAIL) [call_debug] ${call_debug}(false) =~ /^true$/ break=neverDialplan: FreeTDM/1:1/ parsing [public->public_extensions] continue=falseDialplan: FreeTDM/1:1/ Regex (FAIL) [public_extensions] destination_number() =~ /^(10[01][0-9])$/ break=on-falseDialplan: FreeTDM/1:1/ parsing [public->public_did] continue=falseDialplan: FreeTDM/1:1/ Regex (FAIL) [public_did] destination_number() =~ /^(5551212)$/ break=on-false2013-07-31 20:57:17.860189 [DEBUG] switch_core_state_machine.c:167 (FreeTDM/1:1/) State Change CS_ROUTING -> CS_EXECUTE2013-07-31 20:57:17.860189 [DEBUG] switch_core_session.c:1341 Send signal FreeTDM
设置呼出路由规则呼出路由设置

修改呼出设置文件 dialplan/default.xml file:

  <extension name="freetdm.example.com">   
<condition field="destination_number" expression="^(100)$">            
<action application="bridge" data="freetdm/1/1/186653010XX"/>  // 通过此端口呼出到手机号码
   </condition>  
</extension>

以上设置可以通过注册的分机号码,拨打100就可以通过FXO 呼出到本地的手机。系统呼叫log

2013-07-31 21:07:59.920568 [DEBUG] switch_core_session.c:861 Send signal sofia/internal/1002@192.168.1.202 [BREAK]2013-07-31 21:07:59.920568 [NOTICE] switch_ivr_originate.c:3437 Channel [sofia/internal/1002@192.168.1.202] has been answered2013-07-31 21:07:59.920568 [DEBUG] switch_core_session.c:1006 Send signal sofia/internal/1002@192.168.1.202 [BREAK]2013-07-31 21:07:59.940575 [DEBUG] switch_channel.c:3595 (sofia/internal/1002@192.168.1.202) Callstate Change EARLY -> ACTIVE2013-07-31 21:07:59.940575 [DEBUG] sofia.c:5808 Channel sofia/internal/1002@192.168.1.202 entering state [completed][200]2013-07-31 21:07:59.940575 [DEBUG] switch_ivr_originate.c:3494 Originate Resulted in Success: [FreeTDM/1:1/18665301040]2013-07-31 21:07:59.940575 [DEBUG] switch_core_session.c:861 Send signal FreeTDM/1:1/18665301040 [BREAK]2013-07-31 21:07:59.940575 [DEBUG] switch_core_session.c:861 Send signal sofia/internal/1002@192.168.1.202 [BREAK]2013-07-31 21:07:59.940575 [DEBUG] switch_ivr_bridge.c:1432 (FreeTDM/1:1/18665301040) State Change CS_CONSUME_MEDIA -> CS_EXCHANGE_MEDIA

参考文档:








您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

手机版|VoIP88 ( 粤ICP备11095982号   填写您的邮件地址,订阅我们的精彩内容:

GMT+8, 2019-8-24 07:25 , Processed in 0.128125 second(s), 25 queries .

Powered by VoIP88

© 2001-2017 VoIP88

快速回复 返回顶部 返回列表