[asterisk-users] Check if SIP is avaible to dial

Atis Lezdins atis at iq-labs.net
Fri Nov 23 08:06:54 CST 2007


Jakub Syrek wrote:
> I thing there was an error in last version of my macro, correct one (i 
> hope):

Just test it :)

> 
> [macro-call]
> ;sip1 - firs channel from sip outgoing cals operator
> ;sip2 - second channel from sip outgoing cals operator
> ;sipn - N channel from sip outgoing cals operator
> ;ARG1 - outgoing telephone number
> exten => s,1,SetGroup(${ARG1})
> exten => s,2,GotoIf($[ ${GROUP_COUNT(${ARG1})} < 2 ]?dial-ok)

I don't really get why you have this. Why set group count on called 
number? You won't be able to call the same number two calls at time, you 
really want that? There are lot of numbers, that can accept unlimited 
amount of calls simultaneously.

> 
> ;outgoing number was called previously by someone else?
> exten => s,n,NoOp(-- Call destination was previously called and its busy --)
> exten => s,n,Hangup
> 
> ;we can dial
> ;now chack witch chanel is free to meake a call with
> exten => s,n(dial-ok),SetGroup(sip1)
> exten => s,n,GotoIf($[ ${GROUP_COUNT(sip1)} > 1 ]?sip1-busy)
> exten => s,n,Dial(SIP/sip1/${ARG1},25,m)
> exten => s,n,Hangup

You should set group after checking that trunk is available. Once group 
on channel is set, it's not automatically removed, it remains set until 
channel is alive (or you manually unset - i just don't remember the syntax).

> 
> exten => s,n(sip1-busy),SetGroup(sip2)
> exten => s,n,GotoIf($[ ${GROUP_COUNT(sip2)} > 1 ]?sip2-busy)
> exten => s,n,Dial(SIP/sip2/${ARG1},25,m)
> exten => s,n,Hangup
> 
> ;and so on to last one
> 
> exten => s,n(sipN-busy),SetGroup(sipn)
> exten => s,n,GotoIf($[ ${GROUP_COUNT(sipn)} > 1 ]?all-busy)
> exten => s,n,Dial(SIP/sip2/${ARG1},25,m)
> exten => s,n,Hangup
> 
> ;every channel is busy
> exten => s,n(all-busy),Hangup

Regards,
Atis



More information about the asterisk-users mailing list