How to place span use priority on E1?

Hi guys.

I have a system running asterisk 1.4.32 + dahdi 2.4, with two spans on a digium te210 E1 card.

We have the span on group 1 and single TRUNK.

What I need is to tell asterisk that place calls ordered per span, so until span1 get full active channels, do not place calls on span2.

This is because span1 is connected to a cheaper carrier than span2, so we like to be sure to give priority to span1 until its get filled.

Any help will be appreciated.

Thanks.

Spare your E1 in different groups, assuming you have full E1 set the channels 1-15,17-31 to group1 and the channels 32-46,48-62 in the group2.

Then in your dialplan in your rules set something like this:

exten => yourrule,1,Dial(DAHDI/g1/${EXTEN})
exten => yourrule,n,Dial(DAHDI/g2/${EXTEN})