Getting DAHDI channel number in Asterisk dialplan

Hello experts,

In an Asterisk box, we have one TDM401 card with 3FXO modules. When receiving an incoming call through any of those three ports, I want to use the channel number (1,2 or 3) in the dialplan. I have checked FUNC_CHANNEL, but it doesn’t seem to return channel number or name.
I can solve this by using separate context for each channel, but that becomes a problem when using more channels.

Any help?

Generally this is a trace for incoming call:

 -- Starting simple switch on 'DAHDI/2-1'
    -- Executing [s@entrada:1] Wait("DAHDI/2-1", "2") in new stack
    -- Executing [s@entrada:2] Answer("DAHDI/2-1", "") in new stack

What do you want to do in the dialplan you can catch the ID with AMI maybe.

Recent additions to func_channel included in 1.8.5.0,

exten => _5XXX,1,NoOp(Channel-${CHANNEL(dahdi_channel)})
exten => _5XXX,n,NoOp(Span----${CHANNEL(dahdi_span)})
exten => _5XXX,n,NoOp(Type----${CHANNEL(dahdi_type)})

I’ve used the patch in earlier 1.8 releases and it’s worked fine, new AMI events too.

Thank you for the great news. I think that I have to upgrade to 1.8 soon.

BTW, I have solved it in 1.6.2 by using setvar=LINENO=1 (or the channel number) in dahdi-channels.conf, then in the dialplan, I used ${LINENO} to return the channel number.