在Asterisk1.6上安装X100P

玩Asterisk有一段时间了,于是想在ethernet的基础上接触一下Analog, T1/E1方面的内容,也算是对本身工作的一种补充.
X100P是Asterisk入门级的FXO卡(其实就是最便宜板型中最便宜的一款-,-),热血沸腾了一把就在淘宝上花了100元买了一块.
网上X100P安装配置的文章很多,不过大多数都是基于Asterisk1.4之前的版本,使用Zaptel.而Asterisk之后使用的是DAHDI,所以配置上有一些差异,这让我着实费了一些功夫,也让我决心把我的安装过程写下来.
DAHDI与Zaptel配置文件的对应关系

/etc/zaptel.conf <-> /etc/dahdi/system.conf
/etc/asterisk/zapata.conf <-> /etc/asterisk/chan_dahdi.conf

Step 0 前提
软件要求:

sudo apt-get install cvs make gcc g++ libncurses5-dev libssl-dev zlib1g-dev make build-essential libxml2-dev

硬件要求:当然是把X100P插好咯.-,-


Step 1 安装libpri

wget http://downloads.asterisk.org/pub/telephony/libpri/releases/libpri-1.4.10.2.tar.gz
tar zxvf libpri-1.4.10.2.tar.gz
cd libpri-1.4.10.2
sudo make; sudo make install

Step 2 安装DAHDI Linux 和 DAHDI Tools

wget http://downloads.asterisk.org/pub/telephony/dahdi-linux/releases/dahdi-linux-2.2.1.tar.gz
tar zxvf dahdi-linux-2.2.1.tar.gz
cd dahdi-linux-2.2.1
sudo make;sudo make install


wget http://downloads.asterisk.org/pub/telephony/dahdi-tools/releases/dahdi-tools-2.2.1.tar.gz
tar zxvf dahdi-tools-2.2.1.tar.gz
cd dahdi-tools-2.2.1
sudo make;sudo make install
sudo make config

这步作完系统会提示发现DAHDI设备

install -D dahdi.init /etc/init.d/dahdi
/usr/sbin/update-rc.d dahdi defaults 15 30
System start/stop links for /etc/init.d/dahdi already exist.
DAHDI has been configured.
List of detected DAHDI devices:
pci:0000:01:02.0 wcfxo+ 1057:5608 Wildcard X100P
run 'dahdi_genconf modules' to load support for only
the DAHDI hardware installed in this system. By
default support for all DAHDI hardware is loaded at
DAHDI start.

Step 3 运行dahdi_genconf
上一步作完以后提示你运行这个命令.这也是dahdi和zaptel的一个比较大的不同.在dahdi中,dahdi_genconf会根据侦测到的dahdi设备自动为你进行配置.涉及到的配置文件包括以下几个.


/etc/dahdi/modules

# Autogenerated by /usr/sbin/dahdi_genconf (Dahdi::Config::Gen::Modules) on Fri Jan 22 06:45:44 2010
# If you edit this file and execute /usr/sbin/dahdi_genconf again,
# your manual changes will be LOST.
wcfxo

/etc/dahdi/system.conf

# Autogenerated by /usr/sbin/dahdi_genconf on Fri Jan 22 12:45:37 2010
# If you edit this file and execute /usr/sbin/dahdi_genconf again,
# your manual changes will be LOST.
# Dahdi Configuration File
#
# This file is parsed by the Dahdi Configurator, dahdi_cfg
#
# Span 1: WCFXO/0 "Wildcard X100P Board 1" (MASTER)
fxsks=1
echocanceller=mg2,1
# Global data
loadzone = us
defaultzone = us

如果你是在国内使用,请将上面的loadzone和 defaultzone修改成cn.


/etc/asterisk/dahdi_channels.conf

; Autogenerated by /usr/sbin/dahdi_genconf on Fri Jan 22 12:45:37 2010
; If you edit this file and execute /usr/sbin/dahdi_genconf again,
; your manual changes will be LOST.
; Dahdi Channels Configurations (chan_dahdi.conf)
;
; This is not intended to be a complete chan_dahdi.conf. Rather, it is intended
; to be #include-d by /etc/chan_dahdi.conf that will include the global settings
;
; Span 1: WCFXO/0 "Wildcard X100P Board 1" (MASTER)
;;; line="1 WCFXO/0/0 FXSKS (SWEC: MG2)"
signalling=fxs_ks
callerid=asreceived
group=0
context=from-pstn
channel => 1
callerid=
group=
context=default

按照注释说明,dahdi_channels.conf是dahdi_genconf自动生成的.包含dahdi设备需要的默认信息.然后是希望用户在才chan_dahdi.conf中include这个file的.
实际情况是,网上的帖子基本都是实际在chan_dahdi.conf中修改完事的.没人理睬这个file.我一开始配置的时候也是这么做的.直到写这篇博客的时候重读注释才发现了这个问题.其实只要简单的做下面这一步就OK了.


修改/etc/asterisk/chan_dahdi.conf,在末尾加上如下语句

#include dahdi-channels.conf

Step 4 安装Asterisk

wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.6.2.1.tar.gz
tar zxvf asterisk-1.6.2.1.tar.gz
cd asterisk-1.6.2.1
sudo ./configure;

这步会帮你检查Asterisk需要的Library,理论上按照Step 0的话这便会顺利通过.如果你需要额外的Function(例如curl,postgresql)的话,可以在这边获得相应的提示.

sudo make
sudo make install
sudo make samples

运行Asterisk
好了.验收成果的时候来了.

sudo asterisk -vvvvc
.....
*CLI>

Asterisk启动成功.然后查看一下硬件状况.

dahdi show status
Description Alarms IRQ bpviol CRC4 Fra Codi Options LBO
Wildcard X100P Board 1 OK 0 0 0 CAS Unk YEL 0 db (CSU)/0-133 feet (DSX-1)
*CLI>

可以看到Asterisk已经读到了我的X100P.然后查看一下dahdi channels的情况.

*CLI> dahdi show channels
Chan Extension Context Language MOH Interpret Blocked State
pseudo default default In Service
1 from-pstn default In Service
*CLI>

其中”1″就是我们新添加的Dahdi Channel.
注意,如果你板卡检测到了但是Channel没有显示,很可能是chan_dahdi.conf的配置问题.


一切都OK了.连上电话线,给自己打一个电话吧.默认配置就可以听到美丽的”Welcome to Open Source PBX Asterisk…”.
问题一
使用DAHDI Complete Source Tarball编译失败.
解决办法:说实话这个问题很诡异,因为之前都没有问题.我的解决办法就是使用DAHDI Linux Source Tarball和DAHDI Tools Source Tarball分别编译安装,就没有这个问题了.
问题二

bash$ dahdi_cfg
Notice: Configuration file is /etc/dahdi/system.conf
line 0: Unable to open master device '/dev/dahdi/ctl'
1 error(s) detected

解决办法:修改 /etc/modprobe.d/dahdi.blacklist.去掉wcfxo这行.该文件是用于禁止加载某一类型的dahdi驱动的,默认禁止所有类型.

参考链接
配置X100P卡详细步骤
X100P安装手册 (转)
ASTERISK1.4.0+REDHAT9.0+X100P安装
Trixbox下使用x100p卡做FXO通道外呼的实现DAHDI配置文件与zaptel的差别

 

无觅相关文章插件,快速提升流量