DAHDI channel status

Hello,

I am trying to determine whether or not a DAHDI channel is on or off the hook. But no matter what I do it always returns unknown or zero for the value. I’m running Asterisk 1.6.0.9. In the CLI I can see that the phone is off or on the hook by doing a dahdi show channel 1.
Any Ideas? Let me know if you need anymore info.

Here is part of my extensions.conf

exten => s,1,ChanIsAvail(SIP/server&DAHDI/1)
exten => s,n,Read(${AVAILCHAN})
exten => s,n,Set(NEWVAR=${CUT(AVAILCHAN,/,1)})
exten => s,n,GoToIf($["${NewVar}"=“DAHDI”]?dahdi
exten => s,n,GoToIf($["${NewVar}"=""]?down
exten => s,n(dahdi),NoOp(My phone state is currently ${DEVICE_STATE(DAHDI/1)})
exten => s,n,Noop(${AVAILSTATUS})
exten => s,n,Dial(DAHDI/1/${MACRO_EXTEN:1})
exten => s,n,Hangup()

Here is what the CLI shows.
Executing [s@macro-test:1] ChanIsAvail(“SIP/2190-240bad10”, “SIP/server&DAHDI/1”) in new stack
== Using SIP RTP CoS mark 5
– Hungup ‘DAHDI/1-1’
– Executing [s@macro-test:2] Read(“SIP/2190-240bad10”, “DAHDI/1-1”) in new stack
– User entered nothing.
– Executing [s@macro-test:3] Set(“SIP/2190-240bad10”, “NEWVAR=DAHDI”) in new stack
– Executing [s@macro-test:4] GotoIf(“SIP/2190-240bad10”, “1?dahdi”) in new stack
– Goto (macro-test,s,6)
– Executing [s@macro-test:6] NoOp(“SIP/2190-240bad10”, “My phone state is currently UNKNOWN”) in new stack
– Executing [s@macro-test:7] NoOp(“SIP/2190-240bad10”, “0”) in new stack

Thanks,
Grant

This will work but you should probably put in a playback so the caller will know what happened
exten => 1960,1,ChanIsAvail(DAHDI/1)
exten => 1960,n,GoToIf($["${AVAILCHAN}"=""]?taken)
exten => 1960,n,Read(${AVAILCHAN})
exten => 1960,n,Set(NEWVAR=${CUT(AVAILCHAN,/,1)})
exten => 1960,n,GoToIf($["${NEWVAR}"=“DAHDI”]?dahdi)
exten => 1960,n(dahdi),NoOp(My phone state is currently ${AVAILSTATUS})
exten => 1960,n,Dial(DAHDI/1/6163010})
exten => 1960,n,Hangup()
exten => 1960,n(taken),noop(channel is unavailable)
exten => 1960,n,Hangup()
exten => 1960,i,noop(channel is unavailable)

ok… Is there any reason why it would always return the value of UNKNOWN?

because DAHDI isn’t a supported technology in the Device_state function.

See

issues.asterisk.org/view.php?id=15227