login | register
Sun 07 of Sep, 2008 [23:35 UTC]

voip-info.org

Discuss [6] History

Asterisk func Devstate

Created by: JustRumours,Last modification on Wed 28 of May, 2008 [11:34 UTC] by leeky

DEVICE_STATE(device) and DEVSTATE(device)

Synopsis

Get or Set a device state
Introduced in Asterisk 1.6 as DEVICE_STATE(), with a backport available for 1.4.

Description

The DEVICE_STATE function can be used to retrieve the device state from any device state provider.
For example:

 NoOp(SIP/mypeer has state ${DEVSTATE(SIP/mypeer)})
 NoOp(Conference number 1234 has state ${DEVSTATE(MeetMe:1234)})

The DEVSTATE function can also be used to set custom device state from the dialplan. The "Custom:" prefix must be used.
For example:

 Set(DEVSTATE(Custom:lamp1)=BUSY)
 Set(DEVSTATE(Custom:lamp2)=NOT_INUSE)

You can subscribe to the status of a custom device state using a hint in the dialplan:

 exten => 1234,hint,Custom:lamp1

The possible values for both uses of this function are:

 UNKNOWN | NOT_INUSE | INUSE | BUSY | INVALID | UNAVAILABLE | RINGING | RINGINUSE | ONHOLD

Troubleshooting

  • Make sure you know what will happen after an Asterisk restart! It might be necessary to use a .call file (or the Asterisk manager API) to call the DevState application right after Asterisk has started to ensure correct LED status. Note that, before doing so, you might also have to reboot or initialize the phones in question so that they can renew their SIP subscription of the extension that is used to monitor the devicestate; for example SIP NOTIFY could be used for that purpose (see sip_notify.conf).

See also



Comments

Comments Filter
222

333New Version of fun_devstate

by dominic, Thursday 24 of July, 2008 [10:46:15 UTC]
After using the patch from Paul, I had some trouble with the cli - command. If i forgot the arguments (like: fundevstate change) asterisk crashed immediately. Second issue i had was that i always got a warning in the CLI.
Changed both in the file and edited the comments.
Hope this patch will help some of you guys.

New download here: http://www.hdpnet.de/downloads/asterisk/devstate/func_devstate.c
222

333

by djrodman, Sunday 06 of April, 2008 [02:28:28 UTC]
FYI - Grandstream 2000 (at least) blinks in state RINGING, lights solid red in state BUSY or INUSE. PolyCom 430 and 601 (at least) blink in state BUSY, light solid red in RINGING or INUSE. So if you're using both types you'll need a database lookup or something like that to decide which state to put the line into.
222

3331.4 backport

by jsturtevant, Thursday 03 of April, 2008 [12:54:38 UTC]
1.4 backport : http://www.asterisk.org/node/48360

222

333DevState Backport mod

by nizon, Thursday 28 of February, 2008 [07:11:41 UTC]
I just added the ability to set the custom device state from the CLI.

Syntax: funcdevstate change <custom device> <state>
Example: funcdevstate change Custom:test0 RINGING



URL Here: http://paul.voinetworks.net/func_devstate.c
222

333Devstate - SIP Channel remain NOT_INUSE

by ofernachum, Sunday 24 of February, 2008 [06:04:28 UTC]
I had the same problem described by Nasir.

I use Grandstream SIP phones and found that this particular issue is a result of wrong "type=" entry in sip.conf.
Changing type=friend to type=peer for the GS extension resolved the issue.

My Asterisk is 1.4.16.2 patched with the func_devstate.c backport.



222

333devstate for SIP channel

by nasirq, Saturday 22 of September, 2007 [15:26:45 UTC]
I have been trying devstate, but it does not work perfectly with SIP channels.

If the call is initiated by the SIP channel, then the state remains NOT_INUSE even if the call gets through. But if the call is sent to the SIP channel, the states work perfectly, but changing to RINGING, BUSY etc. I have tried SCCP and IAX2 channel and both work fine both ways meaning calling and being called.

What should I do ?

Should I submit a bug report ?

My asterisk version is Asterisk 1.4.7.1.