The question I post is that I have some problems with HKBN 2b. Dial out encountered problem. I have to fail over to PSTN. But my PSTN trunk is connected via SPA3000.
Now my solution as follow:
Use a macro- [macro-superdial]
- ; add some abilities to Dial(Technology/resource[&Technology2/resource2...][|timeout][|options][|URL]):
- ; ${ARG1} - Technology/resource[&Technology2/resource2...] (like SIP/2201)
- ; ${ARG2} - timeout in seconds
- ; ${ARG3} - Dial command options
- ; ${ARG4} - URL (see Dial command for info)
- ; ${ARG5} - Group name (used if you want to limit the number of calls in any way)
- ; ${ARG6} - Max. group number (maximum number of concurrent calls you want to allow for that group)
- ; ${ARG7} - Caller ID name (typically for outgoing calls only)
- ; ${ARG8} - Caller ID number (typically for outgoing calls only)
- ; ${ARG9} - CDR account name (over-rides account group setting in sip.conf or iax.conf)
- ; ${ARG10} - voicemail to send to if noanswer (typically for incoming calls only)
- ; Usage instructions:
- ; for an outgoing call, in extensions.conf you just list multiple lines like:
- ; exten => s,1,Macro(superdial,IAX2/voipjet/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,voipjet)
- ; exten => s,2,Macro(superdial,IAX2/alpeh-com/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,aleph)
- ; and it will take the first one that is available
- ;
- ; it also works for incoming like so ..
- ; exten => s,1,Wait(2)
- ; exten => s,2,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
- ; exten => s,3,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
- ; exten => s,4,Voicemail(b${GENERALVM})
- ; and then goes to unavailable voicemail if one times out .. otherwise (eg if busy) it tries the next extension
- ; if all are busy or unavailable .. it gets to the last priority which is the busy voicemail
- ;
- exten => s,1,Set(GROUP()=${ARG5})
- exten => s,2,Set(GROUPCOUNT=${GROUP_COUNT(${ARG5})})
- exten => s,3,GotoIf($[${GROUPCOUNT} > ${ARG6}]?104)
- exten => s,4,GotoIf($["${ARG7}" = ""]?macro-superdial,s,6)
- exten => s,5,Set(CALLERID(name)=${ARG7}) ; skip this if ARG7 is empty
- exten => s,6,GotoIf($["${ARG8}" = ""]?macro-superdial,s,8)
- exten => s,7,Set(CALLERID(number)=${ARG8}) ; skip this if ARG8 is empty
- exten => s,8,GotoIf($["${ARG9}" = ""]?macro-superdial,s,10)
- exten => s,9,SetAccount(${ARG9}) ; skip this if ARG9 is empty
- exten => s,10,Dial(${ARG1},${ARG2},${ARG3},${ARG4})
- exten => s,11,Goto(s-${DIALSTATUS},1)
- exten => s,104,Goto(s-CHANUNAVAIL,1)
- exten => s-BUSY,1,Noop
- exten => s-NOANSWER,1,GotoIf($["${ARG10}" = ""]?macro-superdial,s-NOANSWER,3)
- exten => s-NOANSWER,2,Voicemail(${ARG10})
- exten => s-NOANSWER,3,Noop
- exten => _s-.,1,Noop
複製代碼 |