Script to configure distinctive tone for FXS port

Description

In some particular scenario, you might want to distinguish 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 ring cadence.

 

Applicable Device

Device Model: P-Series, S-Series

Firmware Version: Not required

 

Code for 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 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})

 

r17 in the code is the personalized cadence from output of command asterisk -rx 'dahdi show cadences', it's only possible to choose any one available from the output.

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

0 Comments

Please sign in to leave a comment.