Creating a DIALPLAN for Tuning DVSwitch

; After fudging a AP command in rpt.conf
; 97 = autopatchup,context=dvs-set,dialtime=90000,farenddisconnect=1,noct,quiet=1

; Use Format: (AP command prefix) + (dvs mode 1-5) + (dvs tg)
; Requires that you set dvs mode each time with the leading digit 1-5.
; So, a command here of *97 1 3100 would set dmr 3100
; 2xxxx tunes dstar adhoc number only
; 2*1 tunes dstar REFxxx
; 2*2 tunes dstar DCSxxx
; 2*3 tunes dstar XLSxxx
; 2*4 tunes dstar XRFxxx
; 2*5 tunes dstar mem # or ## from file

; ** disconnects any mode

; The dialplan in extensions.conf

[dvs-set] ; this context needs to be unique in the system and match dialing context

exten = _1.,1,Wait,1 ; DMR
exten = _1.,2,NoOp() ; room for you to insert a command without renumbering anything
exten = _1.,3,SayAlpha(dmr,${EXTEN:1}) ; speak dmr tg before execution
exten = _1.,4,Wait,4 ; wait with time to cancel (autopatchdn)
exten = _1.,5,System(/opt/MMDVM_Bridge/ mode DMR) ; set mode
exten = _1.,6,Wait,1 ; allow some time to return from the shell
exten = _1.,7,System(/opt/MMDVM_Bridge/ tune ${EXTEN:1}) ; set TG
exten = _1.,8,Hangup ; done/hangup

exten = _2x.,1,Wait,1 ;The following for dstar adhoc
exten = _2x.,2,NoOp()
exten = _2x.,3,SayAlpha(d*,${EXTEN:1}) ; speak dstar & tg before execution
exten = _2x.,4,Wait,4
exten = _2x.,5,System(/opt/MMDVM_Bridge/ mode DSTAR)
exten = _2x.,6,Wait,1
exten = _2x.,7,System(/opt/MMDVM_Bridge/ tune ${EXTEN:1})
exten = _2x.,8,Hangup

exten = _2*1.,1,Wait,1 ;The following for dstar-REF
exten = _2*1.,2,NoOp()
exten = _2*1.,3,SayAlpha(d*,ref${EXTEN:2}) ; speak dstar ref & tg before execution
exten = _2*1.,4,Wait,4
exten = _2*1.,5,System(/opt/MMDVM_Bridge/ mode DSTAR)
exten = _2*1.,6,Wait,1
exten = _2*1.,7,System(/opt/MMDVM_Bridge/ tune ref${EXTEN:2})
exten = _2*1.,8,Hangup

exten = _2*2.,1,Wait,1 ;The following for dstar-DCS
exten = _2*2.,2,NoOp()
exten = _2*2.,3,SayAlpha(d*,dcs${EXTEN:2}) ; speak dstar dcs & tg before execution
exten = _2*2.,4,Wait,4
exten = _2*2.,5,System(/opt/MMDVM_Bridge/ mode DSTAR)
exten = _2*2.,6,Wait,1
exten = _2*2.,7,System(/opt/MMDVM_Bridge/ tune dcs${EXTEN:2})
exten = _2*2.,8,Hangup

exten = _2*3.,1,Wait,1 ;The following for dstar-XLS
exten = _2*3.,2,NoOp()
exten = _2*3.,3,SayAlpha(d*,xlx${EXTEN:2}) ; speak dstar xls & tg before execution
exten = _2*3.,4,Wait,4
exten = _2*3.,5,System(/opt/MMDVM_Bridge/ mode DSTAR)
exten = _2*3.,6,Wait,1
exten = _2*3.,7,System(/opt/MMDVM_Bridge/ tune xls${EXTEN:2})
exten = _2*3.,8,Hangup

exten = _2*4.,1,Wait,1 ;The following for dstar-XRF
exten = _2*4.,2,NoOp()
exten = _2*4.,3,SayAlpha(d*,xrf${EXTEN:2}) ; speak dstar xrf & tg before execution
exten = _2*4.,4,Wait,4
exten = _2*4.,5,System(/opt/MMDVM_Bridge/ mode DSTAR)
exten = _2*4.,6,Wait,1
exten = _2*4.,7,System(/opt/MMDVM_Bridge/ tune xrf${EXTEN:2})
exten = _2*4.,8,Hangup

exten = _2*5.,1,Wait,1 ;The following for dstar memory file /opt/mmdvm/dstar.mem
exten = _2*5.,2,NoOp()
exten = _2*5.,3,SayAlpha(d*,m${EXTEN:3}), ; speak dstar & mem# before execution
exten = _2*5.,4,Wait,3
exten = _2*5.,5,System(/opt/MMDVM_Bridge/ mode DSTAR)
exten = _2*5.,6,Wait,1
exten = _2*5.,7,System(/opt/MMDVM_Bridge/ ${EXTEN:3}) ; calls a secondary shell that hands off info to dvs tune
exten = _2*5.,8,Hangup

exten = _3.,1,Wait,1 ; YSF
exten = _3.,2,NoOp()
exten = _3.,3,SayAlpha(ysf,${EXTEN:1}) ; speak YSF & tg before execution
exten = _3.,4,Wait,4
exten = _3.,5,System(/opt/MMDVM_Bridge/ mode YSF)
exten = _3.,6,Wait,1
exten = _3.,7,System(/opt/MMDVM_Bridge/ tune ${EXTEN:1})
exten = _3.,8,Hangup

exten = _4.,1,Wait,1 ; P25
exten = _4.,2,NoOp()
exten = _4.,3,SayAlpha(p25,${EXTEN:1}) ; speak p25 & tg before execution
exten = _4.,4,Wait,4
exten = _4.,5,System(/opt/MMDVM_Bridge/ mode P25)
exten = _4.,6,Wait,1
exten = _4.,7,System(/opt/MMDVM_Bridge/ tune ${EXTEN:1})
exten = _4.,8,Hangup

exten = _5.,1,Wait,1 ; NXDN
exten = _5.,2,NoOp()
exten = _5.,3,SayAlpha(nxdn,${EXTEN:1}) ; speak nxdn & tg before execution
exten = _5.,4,Wait,4
exten = _5.,5,System(/opt/MMDVM_Bridge/ mode NXDN)
exten = _5.,6,Wait,1
exten = _5.,7,System(/opt/MMDVM_Bridge/ tune ${EXTEN:1})
exten = _5.,8,Hangup

exten = _**.,1,Wait,1 ; disconnect seq
exten = _**.,2,NoOp()
exten = _**.,3,SayAlpha(disc)
exten = _**.,4,Wait,3
exten = _**.,5,,System(/opt/MMDVM_Bridge/ tune disconnect) ; set TG dis
exten = _**.,6,Hangup

;===DStar Memory File===
; The intention here was just a method to connect systems that can not be entered into a 15 usable dtmf digit string reasonably. But you could just store your favorite 10 for ease of dialing.
;To use dstar memory calls, you need to create a file in /opt/MMDVM_Bridge/dstar.mem
;and populate it one dstar connection of any valid call that can be made through DVS per line
;Do not put anything else in the file as it begins reading from line 1 (no comments or blank lines)
;A extra command in the dialplan of ” 2*5 xx ” will call the line# of the memory file.

;Requires one additional batch file in the /opt/mmdvm_bridge/ directory called with these contents


;/opt/MMDVM_Bridge/ tune $(sed “$1q;d” /opt/MMDVM_Bridge/dstar.mem)

;(for some reason I could not execute this inside the dialplan and suspect it’s our older version of asterisk or some bad sytax… so, using alt method)

;Don’t forget to set ownership and permissions of the .sh file

;While this is not a perfect model of operation, it is a functional example for which allows you to develop your own methods beyond it using methods and principles you see.

;The intention here was the old KISS rule and to keep it all in one place as much as possible for easy understanding. Obviously, this will challenge your memory if you do not use it often.

;For those of you who require such functionality, make a cheat sheet to carry with you mobile/portable etc.

; To keep my extensions.conf file a bit cleaner, I set this in a file in /etc/asterisk/custom named dvs.conf and call it at the end of extensions.conf
; #includeifexists custom/dvs.conf

Passing DTMF to Shell Scripts

Setting Up



So, somewhere in our dialplan, we need to create the context ‘pass2script’ and this is done in extentions.conf


[pass2script] ; this context needs to be unique in the system

exten = _X.,1,Wait,1

exten = _X.,n,SayAlpha(/var/lib/asterisk/sounds/activated,${EXTEN}) ; allison says something and then speaks the dtmf string {EXTEN}

exten = _X.,n,Wait,3 ; pause for a chance to cancel by hitting DTMF # (hangup)

exten = _X.,n,System(/source/of/ ${EXTEN}) ; here we pass the dtmf string to shell

exten = _X.,n,Hangup


So, *97 12345 in our example here, would pass 12345 to the shell for *97 is our executing command.

Outside of the ‘autopatch’ we used to capture and pass the dtmf, this dialplan is pure asterisk and you can use all asterisk dialplan functions for evaluating, reformatting and executing.

You will need your shell script to receive the ‘dtmf number string’ accordingly and help for that is available on the web as ‘passing variables to shell scripts’.

The skinny is that you would use the string inside your shell as “$1” since we have only one ‘argument string’ to pass for evaluation at a time.

You can evaluate and pass to internal asterisk/app_rpt functions as well, just using the dialplan.

Additionally evaluate that string inside your dialplan and send to different shell scripts.

Search www asterisk help for that. Inside the dialplan, the DTMF string is simply {EXTEN}

If you like to create your own functionality, you will find this tool/workaround essential for wide flexible control.

It has been well tested method since 2012, so if you are having any issues, check all your syntax.

You could have multiple autopatch dtmf hand-off’s as long as you first provide a new unique command number for it and a new unique context for it in your dialplan.

Practical uses can be site or home control via usb or network relays, radio control/ digital mode control functions, web execution scripts etc, all dependent on your script/dialplan.

So you can see that your imagination is your limit. Go for it.