[asterisk-app-dev] Setting statis-device via dialplan (Asterisk 12)
Hannes Lechner
h.lechner at ognios.com
Mon Mar 17 10:57:45 CDT 2014
ok, understood... thanks for answering!
However - I'm facing the following problem:
I would like to visualize some states (via ARI)
But I need to be able to set a state by dialing an extension on my phone (or pressing a button on an extension module with many extension keys (BLF)) - so e.g.:
dialing 2001 should "set" the state (e.g. INUSE) --> e.g. exten => 2001,3,Set(DEVICE_STATE(Custom:mydevice)=INUSE))
dialing 2000 should "clear" the state (e.g. NOT_INUSE)
dialing 2002 should "toggle" the state
as well as an expansion-key (set to 2002) should also toggle the state
so for the expansion-key to work properly (i.e. call 2002 when I press it) _and_ indicate the current state (red/green) I would also configure a "hint" like
exten => 2002,hint,#Type#:myDevice
1) using "Custom" for #Type# will provide all the above except I cannot "see" the state via ARI
I did that already - but I cannot visualize the state via ARI :(
To me, it's not important that I can change the state via ARI; it could be changed by dialing the extension via ARI which in turn would modify the state via the dialplan which in turn would again visualize the correct state in my ARI-app again)
2) using "Stasis" for #Type# will not allow me to change the state by dialing an extension...
If I use your suggestion:
exten => 1234,hint,Stasis:myDevice&Custom:myDevice
I cannot see how I could visualize the state (via ARI's DeviceStateChanged event) if the Custom:myDevice it was changed by some dialplan-extension
(it should work with the BLF/extension-key however)
Any pointers/ideas how to achieve the requested functionality???
Maybe I can trigger an ARI function via the dialplan (which in turn updates the Stasis-State)?
Or can I "hook" ARI somehow to a Custom-State (no need to change the state, just retrieve an event whenever the state changed; no polling please. I need to be notified by an event...)
Thanks for your help...
-----Original Message-----
From: asterisk-app-dev-bounces at lists.digium.com [mailto:asterisk-app-dev-bounces at lists.digium.com] On Behalf Of Matthew Jordan
Sent: Montag, 17. März 2014 13:34
To: Asterisk Application Development discussion
Subject: Re: [asterisk-app-dev] Setting statis-device via dialplan (Asterisk 12)
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
_______________________________________________
asterisk-app-dev mailing list
asterisk-app-dev at lists.digium.com
http://lists.digium.com/cgi-bin/mailman/listinfo/asterisk-app-dev
More information about the asterisk-app-dev
mailing list