Upgrade 3CX to v18 and get it hosted free!

Asterisk cmd BristuffDevstate

Author image

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 Asterisk phone 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.

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

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.