问题描述
我正在使用sagoma 8端口卡我的chan_dahdi.conf
配置端口是
I am using sagoma 8 port card My chan_dahdi.conf
to configure the ports are
;autogenerated by /usr/sbin/wancfg_dahdi do not hand edit
;autogenrated on 2015-06-12
;Dahdi Channels Configurations
;For detailed Dahdi options, view /etc/asterisk/chan_dahdi.conf.bak
[trunkgroups]
[channels]
context=default
usecallerid=yes
hidecallerid=no
callwaiting=yes
usecallingpres=yes
callwaitingcallerid=yes
threewaycalling=yes
transfer=yes
canpark=yes
cancallforward=yes
callreturn=yes
echocancel=yes
echocancelwhenbridged=yes
relaxdtmf=yes
rxgain=0.0
txgain=0.0
group=1
callgroup=1
pickupgroup=1
immediate=no
;Sangoma A108 port 1 [slot:4 bus:2 span:1] <wanpipe1>
switchtype=euroisdn
context=from-pstn
group=1
echocancel=yes
signalling=pri_cpe
channel =>1-15,17-31
;Sangoma A108 port 2 [slot:4 bus:2 span:2] <wanpipe2>
switchtype=euroisdn
context=from-pstn
group=2
echocancel=yes
signalling=pri_cpe
channel =>32-46,48-62
;Sangoma A108 port 3 [slot:4 bus:2 span:3] <wanpipe3>
switchtype=euroisdn
context=from-pstn
group=3
echocancel=yes
signalling=pri_cpe
channel =>63-77,79-93
;Sangoma A108 port 4 [slot:4 bus:2 span:4] <wanpipe4>
switchtype=euroisdn
context=from-pstn
group=4
echocancel=yes
signalling=pri_cpe
channel =>94-108,110-124
;Sangoma A108 port 5 [slot:4 bus:2 span:5] <wanpipe5>
switchtype=euroisdn
context=from-pstn
group=5
echocancel=yes
signalling=pri_cpe
channel =>125-139,141-155
;Sangoma A108 port 6 [slot:4 bus:2 span:6] <wanpipe6>
switchtype=euroisdn
context=from-pstn
group=6
echocancel=yes
signalling=pri_cpe
channel =>156-170,172-186
;Sangoma A108 port 7 [slot:4 bus:2 span:7] <wanpipe7>
switchtype=euroisdn
context=from-pstn
group=7
echocancel=yes
signalling=pri_cpe
channel =>187-201,203-217
;Sangoma A108 port 8 [slot:4 bus:2 span:8] <wanpipe8>
switchtype=euroisdn
context=from-pstn
group=8
echocancel=yes
signalling=pri_cpe
channel =>218-232,234-248
我的问题是如何在我的拨号方案中动态获取当前呼叫端口的组号.
My problem is how can I get the group number of current calling port dynamically in my dialplan.
例如,如果用户调用端口1中的pri,则我的拨号语句为
For example if user call to the pri which is in port 1 then my dial statement is
exten => _X.,n,dial(DAHDI/g1/${NUMBER})
对于第二个pri端口2上的呼叫
And for the call on second pri port 2
exten => _X.,n,dial(DAHDI/g2/${NUMBER})
g3,g4,g5等用于其他端口,以便设置该特定DID
g3,g4,g5 etc for other ports in order to set that particular DID
当前调用时我正在做什么,我通过检查DID范围来创建一个GROUP变量来存储组
Currenty what I am doing when call comes I create a GROUP variable which stores the group by checking DID range
same => n,Set(__GROUP=${IF($[ ${EXTEN} >= ${DIDMINPORT1}]? ${IF($[ ${EXTEN} <= ${DIDMAXPORT1}]?g1:g1)} :g1)})
same => n,Set(__GROUP=${IF($[ ${EXTEN} >= ${DIDMINPORT2}]? ${IF($[ ${EXTEN} <= ${DIDMINPORT2}]?g2: ${GROUP} )} : ${GROUP} )})
对于其他组等,我要拨号
and etc for other groups ,for dialling I do
exten => _X.,n,dial(DAHDI/${GROUP}/${NUMBER})
但是我不认为这是一个好主意,因为我有8个端口,所以我必须写8行来确定组并通过匹配DID进行拨号.所以有什么方法可以在我的Dialplan中动态获取组,这意味着通道变量,我可以从中获取当前传入端口调用的组?
But I dont think its a good idea because I have 8 port so I have to write 8 lines to determine the group and dial by matching the DID.So is there any way to get group dynamically in my dialplan means if there any channel variable from which I can get the group of current incoming port call?
推荐答案
我知道该DAHDI组没有此类变量.
As I know there are no such variables for that DAHDI groups.
在chan_dahdi.conf中,您使用相同的选项"context = from-pstn",因此可以轻松地为组1设置"context = pri-g1"(为组2等设置"context = pri-g2").然后在拨号计划中定义如下内容:
In your chan_dahdi.conf you use same option "context=from-pstn", so you may easily set "context=pri-g1" for group 1 ("context=pri-g2" for group 2 and etc.) and then define in dialplan something like that:
[pri-main]
exten => s,1,NoOp(Main routine)
[pri-g1]
exten => s,1,Set(PRI_GROUP=1)
exten => s,n,GoTo(pri-main,s,1)
[pri-g2]
exten => s,1,Set(PRI_GROUP=2)
exten => s,n,GoTo(pri-main,s,1)
...
[pri-g8]
exten => s,1,Set(PRI_GROUP=8)
exten => s,n,GoTo(pri-main,s,1)
设置起来似乎不像使用通道变量那样方便,但是对于星号来说却很快.
It is not as convenient for setting up as if there were channel variables, but fast for asterisk.
请注意,在[pri-g#]中,exten可能不是"s",而是DID号码或其他-但您很快就会在CLI错误中看到它.
Just notice that in [pri-g#] exten may be not "s", but DID number or smth else - but you will see it in CLI errors very soon.
这篇关于将组名获取到星号中的相应pri端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!