Script to configure distinctive tone for FXS port

Description

In some particular scenario, you might want to play distinctive ringing tone for internal and external calls on an analog phone.

For example:

When there is internal call to analog phone, play default ring cadence.

When there is inbound call from outside to analog phone, play personalized ringing cadence.

 

Applicable Device

Device Model: P-Series, S-Series

Firmware Version: Not required

 

Operation Step

Refert to this article to make custom change by ssh. How to create custom conf file in s-series voip pbx

 

Code for direct call to FXS phone in S-Series

[macro-stdexten-fromoutside]
exten = s,1,Set(IsFromOutside=1)
exten = s,n,Set(PBXDIALNUM=${ARG1})
exten = s,n,ExecIf($[${LEN(${CALLERNUM})}=0]?YsWalkContext(whitelist-inbound,${PBXDIALNUM},1,${CALLERID(num)},inbound)
exten = s,n,Noop(Distinctive Ringtone for Inbound Calls to Analog Extension)
exten = s,n,GotoIf(${LEN(${FILTER(D,${ARG2})})}>0?+1:+4)
exten = s,n,Noop(Target is Analog Extension)
exten = s,n,Set(ARG2=${ARG2}r17)
exten = s,n,Goto(10)
exten = s,n,Noop(Target is not Analog Extension)
exten = s,n,Macro(realstexten,${PBXDIALNUM},${ARG2},${DIALOPTIONS})

 

Code for FXS phone in ring group or queue for S-Series

[ringgroup_6200]
exten = 6200,1,Set(CALLERID(name)=${CALLERID(name)}(RINGGROUP))
exten = 6200,n,Set(YSGROUPEXTEN=6200)
exten = 6200,n,Set(CDR(orgdst)=6200)
exten = 6200,n,Set(_RINGGROUPS=yes)
exten = 6200,n,Wait(1)
exten = 6200,n,Set(CDR(ringtype)=ringall)
exten = 6200,n,Set(RINGTYPE=ringall)
exten = 6200,n,Dial(${DIALPARAM_OF_EXTEN5000}r17&${DIALPARAM_OF_EXTEN5684},60,TtKkXx${RINGTONE},,ringall)
exten = 6200,n,Gotoif($["${DIALSTATUS}" = "ANSWER"]?always-Hangup,h,1)
exten = 6200,n,Set(CDR(extfield2)=6500)
exten = 6200,n,Goto(ivrs,6500,1)
exten = fax,1,Goto(inrouter_${INROUTERNAME}_fax_detect,fax,1)
exten = _.,1,Goto(from-outside,${EXTEN},1)

 

Code for direct call to FXS phone in P-Series

[macro-stdexten-fromoutside]
exten = s,1,Set(IsFromOutside=1)
exten = s,n,ExecIf($[${LEN(${SRCTRUNKNAME})}>0]?Set(FORWARDPREFIX=EX))
exten = s,n,Set(PBXDIALNUM=${ARG1})
exten = s,n,Gotoif($["${TOFORKCDR}" != "yes"]?walk_ctx)
exten = s,n,Set(CDR(transfertype)=dial)
exten = s,n,ForkCDR(erv)
exten = s,n,Set(CDR(callflow)=ext)
exten = s,n,Set(TOFORKCDR=no)
exten = s,n(walk_ctx),YsWalkContext(whitelist-inbound,${PBXDIALNUM},1,${CALLERID(num)},inbound)
exten = s,n,Noop(Distinctive Ringtone for Inbound Calls to Analog Extension)
exten = s,n,GotoIf(${LEN(${FILTER(D,${ARG2})})}>0?+1:+4)
exten = s,n,Noop(Target is Analog Extension)
exten = s,n,Set(ARG2=${ARG2}r17)
exten = s,n,Goto(16)
exten = s,n,Noop(Target is not Analog Extension)
exten = s,n,Macro(realstexten,${PBXDIALNUM},${ARG2},${DIALOPTIONS})

Code for FXS phone in ring group or queue for P-Series

[ringgroup_6303]
exten = 6303,1,NoOp(6303)
exten = 6303,n,ExecIf($["${LOOPCALL}" != "yes"]?Ringing())
exten = 6303,n,Set(CDR(rgnum)=6303)
exten = 6303,n,Set(CDR(dstname)=6303)
exten = 6303,n,Set(CDR(callflow)=ringgroup)
exten = 6303,n,Set(CDR(callflownumber)=6303)
exten = 6303,n,Set(DSCIDCALLFEATURE=6303)
exten = 6303,n,DistinctiveCid()
exten = 6303,n,Set(RINGTONE_SUPPORT=YES)
exten = 6303,n,ExecIf($["${IgnoreUpdateCallee}" = "yes"]?Noop("no need updatecallee"):UserEvent(UpdateCallee,Callee: 6303))
exten = 6303,n,Set(_RINGGROUPS=yes)
exten = 6303,n,Wait(1)
exten = 6303,n,Set(CDR(ringtype)=ringall)
exten = 6303,n,Set(RINGTYPE=ringall)
exten = 6303,n,Set(RECORDMISSCALL=yes)
exten = 6303,n,Dial(${CUSTOM_VAR(DIALPARAM_100)}r2,60,TtKkXx${RINGTONE}b(ringgroup_member_predial,callflow,1),,ringall)
exten = 6303,n,Gotoif($["${DIALSTATUS}" = "ANSWER"]?always-Hangup,h,1)
exten = 6303,n,Set(CDR(transfertype)=failover)
exten = 6303,n,ExecIf($[${ORGINALDIALSTATUS}=CHANUNAVAIL]?ForkCDR(erv))
exten = 6303,n,Set(CDR(callflow)=hangup)
exten = 6303,n,ExecIf($[${LEN(${CHANNEL(boss_exten)})}>0]?Set(BOSS_SECRETARY_EXIT()=))
exten = 6303,n,Goto(always-Hangup,h,1)
exten = fax,1,Goto(inrouter_${INROUTERNAME}_fax_detect,fax,1)
exten = _.,1,Goto(from-outside,${EXTEN},1)

 

r17 and r2 in the code are the personalized cadence from output of command asterisk -rx 'dahdi show cadences', it's only possible to choose any one available from the output. Be careful to do it for ring group and queue if there are sip and fxs user added, only add it for FXS phone, DO NOT add cadence for sip phone, otherwise calls to group even failed.

support@IPPBX:~$ asterisk -rx 'dahdi show cadences'
Unable to open specified codec config file '/ysdisk/ysapps/pbxcenter/etc/codec.conf', using built-in defaults
Unable to disable core size resource limit: Operation not permitted
r1: 125,125,2000,4000
r2: 250,250,500,1000,250,250,500,4000
r3: 125,125,125,125,125,4000
r4: 1000,500,2500,5000
r5:
r6:
r7:
r8:
r9:
r10:
r11: 1500,1500
r12: 700,300,1500,1500
r13: 2000,1000
r14: 1000,2000
r15: 500,500,500,1500
r16: 1000,1000,1000,2000
r17: 400,600,400,600,1400,1600
r18: 1000,1000,2000,2000
r19:
r20:
r21:
r22:
r23:
r24:
r25:
Asterisk ending (0).
Have more questions? Submit a request

1 Comments

  • 0
    Avatar

    Hi Tonnie,

    How to write this script in SSH? could you please give further details about script usage in S-series after logging in by SSH connection? 

    Thanks
    Emre

Please sign in to leave a comment.