[arm-allstar] macro question

Doug Crompton doug at crompton.com
Thu Sep 3 21:57:42 EST 2015


Neil,

 You could define multiple functions that called the same script with different parameters or channels. In this case *D1 through *D3 would set channels 1-3. You can add more as you wish and even process additional parameters.
D1=cmd,/etc/asterisk/local/set_channel 1 
D2=cmd,/etc/asterisk/local/set_channel 2
D3=cmd,/etc/asterisk/local/set_channel 3
etc....

Then in the script test the parameter and execute the proper command or just use the parameter in the call to the command.

# !/bin/bash

if [ -z $1 ]
 then
   echo "No channel given (1-16)"
   exit 0
fi

case "$1" in

  1) Echo "Channel 1"
     # command for channel 1 to asterisk put here
     ;;

  2) echo "Channel 2"
    # command for channel 2 to asterisk put here
     ;;

  3) echo "Channel 3"
     # command for channel 3 to asterisk put here
     ;;
#etc.... add channels

esac

exit

By the way Dave, KB4FXC commented to me that you could use the dialplan in extensions .conf to do this and that is exactly what I did years ago in a script to control my X10 system from the phone in Asterisk.

Here is an example -

[controlx10]
exten => s,1,background(doug/enter_x10)
exten => s,n,Set(TIMEOUT(response)=4)
exten => s,n,Set(TIMEOUT(digit)=1)
exten => s,n,WaitExten()
exten => s,n,Goto(s,1)

exten => _1.,1,System(/usr/local/bin/x10 on ${EXTEN:1})
exten => _1.,n,SayNumber(${EXTEN:1})
exten => _1.,n,Playback(on)
exten => _1.,n,Goto(s,1)

exten => _0.,1,System(/usr/local/bin/x10 off ${EXTEN:1})
exten => _0.,n,SayNumber(${EXTEN:1})
exten => _0.,n,Playback(off)
exten => _0.,n,Goto(s,1)

exten => _3.,1,System(/usr/local/bin/x10 dim ${EXTEN:1})
;exten => _3.,1,noop(${EXTEN:1})
exten => _3.,n,Goto(s,1)

exten => _4.,1,System(/usr/local/bin/x10 bright ${EXTEN:1})
exten => _4.,n,Goto(s,1)

exten => _5.,1,System(/usr/local/bin/x10 allon ${EXTEN:1})
exten => _5.,n,Goto(s,1)

exten => _6.,1,System(/usr/local/bin/x10 alloff ${EXTEN:1})
exten => _6.,n,Goto(s,1)

;exten => 4,1,Playback(goodbye)
;exten => 4,n,Hangup()

exten => *,1,Return()
exten => #,1,Hangup()

This would need to be setup in Allstar but could work. I think for now an easier and more straightforward way would be to use the script method I proposed above if it works for you.

73 Doug
WA3DSP
http://www.crompton.com/hamradio


From: k8it at cac.net
To: arm-allstar at hamvoip.org
Date: Thu, 3 Sep 2015 21:47:33 -0400
Subject: Re: [arm-allstar] macro question








Thanks Doug. And yes I agree with using scripts. What I am trying to do is 
respond to a users DTMF digits for a remote base application. I now have written 
script code using hamlib to control my TMV71A radio. it works good but only has 
a few preprogrammed memories based on which macro you use.
I would like to instead receive three DTMF digits and process them before 
passing them to the radio via hamlib. Somehow there is a way!
If I call a script
is it possible to call an asterisk function from within the script  to 
receive three DTMF digits directly to the script for more processing?
 
 
Thanks
73 Neil Sablatzky  K8IT
Allstar Node 41838 
KITLINK
Allstar Node 42087 KITLINK HUB
IRLP Node exp0068
Echolink 
K8IT-L
WIRES-X K8IT 11479 Room 21479




From: Doug Crompton 
Sent: Thursday, September 03, 2015 8:53 PM
To: ARM Allstar 
Subject: Re: [arm-allstar] macro question


Neil,

 I 
don't think you can pass parameters to a macro. There would be no way to test 
for vlaues. Why not call a script and pass parameters there. here is an example 
from rpt.conf. This is defined in the [functions] section. *A1 would call this 
and execute sayip.sh.  27225 is the passed 
parameter.

A1=cmd,/usr/local/sbin/sayip.sh 27225 

The in the 
sayip.sh script $1 is then defined as 27225.  You can have multiple 
parameters so if it were -

A1=cmd,/usr/local/sbin/sayip.sh 1 2 
3

Then in the script $1 would =1, $2 would = 2, and $3 would 
=3.

This yet again shows the power of using scripts over built-in 
code.

73 Doug
WA3DSP
http://www.crompton.com/hamradio



> From: k8it at cac.net
> To: arm-allstar at hamvoip.org
> Date: 
Thu, 3 Sep 2015 19:00:20 -0400
> Subject: [arm-allstar] macro 
question
> 
> using a macro say for example
> *52 which can 
call a bash script
> How can I pass say the next three DTMF digits to the 
script to be processed?
> For example if a user enters *52123 where 123 is 
three random dtmf digits 
> how can I pass the 123 digits to the bash 
script?
> 
> Thanks
> 73 Neil Sablatzky K8IT
> Allstar 
Node 41838 KITLINK
> Allstar Node 42087 KITLINK HUB
> IRLP Node 
exp0068
> Echolink K8IT-L
> WIRES-X K8IT 11479 Room 21479
> 

> 
> _______________________________________________
> 

> arm-allstar mailing list
> arm-allstar at hamvoip.org
> 
http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar
> 
> 
Visit the BBB and RPi2 web page - http://hamvoip.org
> 






_______________________________________________

arm-allstar 
mailing 
list
arm-allstar at hamvoip.org
http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar

Visit 
the BBB and RPi2 web page - http://hamvoip.org 






No virus found in this 
message.
Checked by AVG - www.avg.com
Version: 2015.0.6125 / Virus 
Database: 4409/10570 - Release Date: 09/03/15

_______________________________________________

arm-allstar mailing list
arm-allstar at hamvoip.org
http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar

Visit the BBB and RPi2 web page - http://hamvoip.org 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hamvoip.org/pipermail/arm-allstar/attachments/20150903/226f16b5/attachment.html>


More information about the arm-allstar mailing list