Asterisk cmd BristuffDevstate

app_devstate (bristuff)

Application for sending device state messages. Mainly used for lighting the LEDs on the snoms.
Generate a device state change event (inuse, busy, ringing ...)

devstate(device,state)

Details

Devstate() is part of the BRIstuff patches (0.2.0-RC7i/j and later) and therefore not included in the official Asterisk STABLE or HEAD. Obviously devstate() does not work without installing bristuff. The state values match the asterisk device states, they are:

  • 0 = unknown
  • 1 = not inuse
  • 2 = inuse
  • 3 = busy
  • 4 = invalid,
  • 5 = unavailable
  • 6 = ringing

Note: Asterisk 1.6 will come by default with its own device state application.

Example 1

Q: Has anyone written a php/perl or a hack to the 'hint' function in Asterisk that will let you monitor a MeetMe conference? So if anyone was in a conference, I could have a button light up on my Snom 360?

A: Take a look at app_devstate (part of bristuff). It lets you control SNOM LEDs from the dialplan, e.g.:

exten => 1234,hint,DS/100 ; here we are using fake 'technology' DS (DeviceState)
exten => 1234,1,DevState(100,2) ; == solid , or (100,6) for blinking
exten => 1234,2,Meetme(1234)
exten => 1234,3,Hangup
exten => h,1,DevState(100,0) ; LED off

Then configure one SNOM function key as a "destination" to 1234.

Example 2: Setting a status LED

This example is tailored for bristuff with Asterisk 1.2.x (or later).

exten => s,1,Answer()
exten => s,n,Set(status=${DB(${ARG1}/${ARG2})})
exten => s,n,GotoIf($["${status}" = "closed"]?opening|1:closing|1)

exten => opening,1,Set(status=open)
exten => opening,n,Set(DB(${ARG1}/${ARG2})=${status})
exten => opening,n,DevState(${ARG3},2)
exten => opening,n,Hangup()

exten => closing,1,Set(status=closed)
exten => closing,n,Set(DB(${ARG1}/${ARG2})=${status})
exten => closing,n,DevState(${ARG3},0)
exten => closing,n,Hangup()

Then using the value ARG3 from above:

exten => _${ARG3},hint,DS/${ARG3}

Remember to substitute the actual variables as you can't use variables with hints.

Extended example

Look here (for a patched Asterisk 1.2.9.1): http://www.vecsector.com/phonecall/valet/

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


Go back to Asterisk - documentation of application commands

Created by: JustRumours, Last modification: Sat 24 of Nov, 2007 (14:09 UTC)


Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+

Page Changes | Comments

 

Featured -

Search: