[asterisk-app-dev] Setting statis-device via dialplan (Asterisk 12)

Matthew Jordan mjordan at digium.com
Mon Mar 17 07:34:17 CDT 2014


On Mon, Mar 17, 2014 at 2:18 AM, Hannes Lechner <h.lechner at ognios.com> wrote:
> Hi!
>
> on Asterisk 12:
> is there a way to set a statis device (e.g. "Statis:myDevice") via dialplan?
>
> the following
> # "same => n, Set(Statis:myDevice=INUSE)"
> --> error: ...no error shown, but nothing happens
> or
> # "same => n, Set(DEVICE_STATE(Stasis:mydevice1)=INUSE)
> --> error: ...devstate_write: The DEVICE_STATE function can only be used to
> set 'Custom:' device state!
>
> i can currently only change the device's state via ARI... and i cannot use a
> Custom:myDevice as this is not handled by ARI.
>
> am i missing something?
>

No, you're not missing anything. Stasis device states are owned by ARI
and Custom device states are controlled via the DEVICE_STATE function.
Stasis device states have to be changed via ARI; allowing them to be
changed by the dialplan as well potentially opens up a lot of race
conditions.

If what you're after is an extension state that is configurable from
both the dialplan as well as from ARI, this can be done using a
combination of the Stasis and Custom device states:

exten => 1234,hint,Stasis:myDevice&Custom:myDevice

Use the DEVICE_STATE function to set the Custom device state from the
dialplan; using ARI to set the Stasis device state. Things that have
subscribed to 1234 will get the aggregated overall device state - so
if the dialplan says that Custom:myDevice is INUSE, then 1234 will
appear as INUSE. When the dialplan clears the Custom device state, if
ARI sets the Stasis device state to INUSE, then 1234 will also show as
INUSE.


-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org



More information about the asterisk-app-dev mailing list