> What I mean is I want a call to go out on ProviderA, UNLESS it's down and
> then go to ProviderB.
> I want it to ring 30 seconds and then Hangup if nobody has answers.

This one's actually a bit more complicated than it first seems, since you need 
to know how each provider reports status when it's unavailable. We run the 
following AEL macros to achieve something similar:

(apologies to the list for the big chunk of code below - I'm not sure how 
well/if the list handles attachments)

// DIAL NUMBER (with a range of routing options)
macro outbound (number, route1, route2, route3, route4, route5) {
        // set correct outbound caller id
        if (${LEN(${CALLERID(number)})} < 10 & ${LEN(${CALLERID(number)})} > 0) 
{
                if (${LEN(${DB(callerid/${CDR(accountcode)})})} > 9) {
                        CALLERID(number)=${DB(callerid/${CDR(accountcode)})};
                } else
                        Set(CALLERID(number)=);
        };
        dialstart:
        switch (${route1}) {
                case dundi:
                        if (${number:0:2} = 00) {
                                &dundi-e164 (${number:2});
                        } else if (${number:0:1} = 0) {
                                &dundi-e164 (44${number:1});
                        } else
                                &dundi-e164 (${number});
                        break;
                case provider1:
                        &dialout (IAX2/provider1/${number});
                        break;
                case provider2:
                        &dialout (IAX2/provider2/${number});
                        break;
                case provider3:
                        &dialout (IAX2/provider3/${number});
                        break;
                case pstn:
                        &dialout (Zap/g1/${number});
                        break;
                default:
                        NoOp (invalid route: ${route1});
        };
        if (${LEN(${route2})} > 0) {
                route1=${route2};
        } else {
                Playtones (congestion);
                Congestion ();
        };
        if (${LEN(${route3})} > 0)
                route2=${route3};
        if (${LEN(${route4})} > 0)
                route3=${route4};
        if (${LEN(${route5})} > 0)
                route4=${route5};
        goto dialstart;
};

// DIAL NUMBER (ignoring anything except busy)
macro dialout (dialstring) {
        Dial (${dialstring},,TW);
        switch (${DIALSTATUS}) {
                case BUSY:
                        Playtones (busy);
                        Busy ();
                        break;
                case CONGESTION:
                        Playtones (busy);
                        Busy ();
                        break;
        };
};

You can then dial from your "main" dialplan something like this for UK 
landlines:
exten => _0[12]XXXXXXXXX,1,Macro(outbound,${EXTEN},provider1,provider2,pstn)

The "dialout" macro ignores any responses from the SIP/IAX provider except Busy 
or Congestion (we have a provider which provides "congestion" when the dialled 
number is busy, that's why it's there). So, if the provider's server is 
unavailable (through qualify=yes or whatever), it'll fall through as channel 
status "unknown" and loop onto the next provider.

On an outbound call made from one of your users, why would you want a 30 second 
timeout? Surely you'd want to keep ringing the callee until the caller (i.e. 
your user) loses interest and hangs up their device? The length of time for a 
device to be rung before doing something else is usually determined by the 
recipient, not the initiator.

Hope that helps.

Regards,

Chris
-- 
C.M. Bagnall, Director, Minotaur I.T. Limited
For full contact details visit http://www.minotaur.it/chris.html
This email is made from 100% recycled electrons


_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to