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 stateIntroduced 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
- Asterisk func HINT: New HINT() function in Asterisk 1.6
- Asterisk func EXTENSION_STATE: New EXTENSION_STATE() function in Asterisk 1.6
- Backport for Asterisk 1.4
- Extstate() function for 1.4, get extension state instead of device
- Asterisk cmd BristuffDevstate
- Asterisk SLA
- Mini How-To: Blog entry by the author
Comments
333New Version of fun_devstate
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
333
3331.4 backport
333DevState Backport mod
Syntax: funcdevstate change <custom device> <state>
Example: funcdevstate change Custom:test0 RINGING
URL Here: http://paul.voinetworks.net/func_devstate.c
333Devstate - SIP Channel remain NOT_INUSE
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.
333devstate for SIP channel
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.