Asterisk
  1. Asterisk
  2. ASTERISK-14231

DEVICE_STATE() always returns 0 (Unknown)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Severity: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Target Release Version/s: None
    • Labels:
      None
    • Mantis ID:
      15227
    • Regression:
      No

      Description

      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.

      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

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        Tilghman Lesher added a comment -

        1) ChanIsAvail returns a hangup causecode in AVAILSTATUS, not a device status code. Since the channel is available, there is no cause for termination, hence 0.

        2) DEVICE_STATE() only works with channels that support devicestate. DAHDI channels do not support devicestate, as you can confirm with the following CLI command: core show channeltypes.

        Show
        Tilghman Lesher added a comment - 1) ChanIsAvail returns a hangup causecode in AVAILSTATUS, not a device status code. Since the channel is available, there is no cause for termination, hence 0. 2) DEVICE_STATE() only works with channels that support devicestate. DAHDI channels do not support devicestate, as you can confirm with the following CLI command: core show channeltypes.

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: