Really basic line-out rollover style dialplan


#1

The goal is that when a particular outgoing number pattern in my dialplan
(per month ) is dialed, asterisk will rollover calls to different outbound trunks when multiple of 30 minutes are used up. After the fourth rollover to line 5, no more rollover is needed.

a call may run over the 30 min threshold, but after the call ends it automatically switches.

I wanted to confirm that this is not complex enough to warrant setting up a calling card application to track these variables.

[edit] - i tried my hand at writing this, but the last programming i did was 15 years ago for basic & pascal on a commodore 64c…

it doesn’t attempt to address the month, but i imagine i can put a line that when the date is 01 and the time is 00:01, db(RF/SEC)=0

i’d just like to get the rest started. again any help would be appreciated

[code][macro-rfexten]

; 0 - 30 minutes
exten => s,1,NoOp(${DB(RF/SEC)}) ; (RF/SEC) prints to console
exten => s,2,GotoIf($[${DB(RF/SEC)} >= 1800]?201:3) ; tests if (RF/SEC) >= 1800
exten => s,3,Dial(SIP/gw0/${EXTEN},30,r) ; dials on gw0
exten => s,4,NoOp(CDR(${billsec})) ; call time after answer to console
exten => s,5,DB(RF/SEC)=${MATH(${(DB(RF/SEC))}+${CDR(${billsec})}),int)} ;sets (RF/SEC) to (RF/SEC) plus billsec
exten => s,6,Hangup

; 31 - 60 minutes
exten => s,201,GotoIf($[${DB(RF/SEC)} >= 3600]?202:3) ; tests if (RF/SEC) >= 3600
exten => s,3,Dial(SIP/gw1/${EXTEN},30,r) ; dials on gw1
exten => s,4,NoOp(CDR(${billsec})) ; call time after answer to console
exten => s,5,DB(RF/SEC)=${MATH(${(DB(RF/SEC))}+${CDR(${billsec})}),int)} ;sets (RF/SEC) to (RF/SEC) plus billsec
exten => s,6,Hangup

; 61 - 90 minutes
exten => s,202,GotoIf($[${DB(RF/SEC)} >= 5400]?203:3) ; tests if (RF/SEC) >= 5400
exten => s,3,Dial(SIP/gw2/${EXTEN},30,r) ; dials on gw1
exten => s,4,NoOp(CDR(${billsec})) ; call time after answer to console
exten => s,5,DB(RF/SEC)=${MATH(${(DB(RF/SEC))}+${CDR(${billsec})}),int)} ;sets (RF/SEC) to (RF/SEC) plus billsec
exten => s,6,Hangup

; 91 - 120 minutes
exten => s,203,GotoIf($[${DB(RF/SEC)} >= 7200]?204:3) ; tests if (RF/SEC) >= 7200
exten => s,3,Dial(SIP/gw3/${EXTEN},30,r) ; dials on gw3
exten => s,4,NoOp(CDR(${billsec})) ; call time after answer to console
exten => s,5,DB(RF/SEC)=${MATH(${(DB(RF/SEC))}+${CDR(${billsec})}),int)} ;sets (RF/SEC) to (RF/SEC) plus billsec
exten => s,6,Hangup

; 120+ minutes
exten => s,204,Dial(SIP/gw4/${EXTEN},30,r) ; dials on gw4
exten => s,3,Hangup[/code]


#2

i made an edit above to clarify my goal and attempt at creating a macro.

please take a look and provide some feedback. thanks