System information
Example 14-1 shows the full example as it would appear in /etc/asterisk/extensions.conf.
Example 14-1. Custom “do not disturb” functionality using custom device states
;
; A hint so a phone can use BLF to signal the DND state.
;
exten => DND_7015,hint,Custom:DND_7015
;
; An extension to dial when the user presses the custom DND
; key on his phone. This will toggle the state and will result
; in the light on the phone turning on or off.
;
exten => DND_7015,1,Answer()
same => n,GotoIf($["${DEVICE_STATE(Custom:DND_7015)}"="BUSY"]?turn_off:turn_on)
same => n(turn_off),Set(DEVICE_STATE(Custom:DND_7015)=NOT_INUSE)
same => n,Hangup()
same => n(turn_on),Set(DEVICE_STATE(Custom:DND_7015)=BUSY)
same => n,Hangup()
;
; Example usage of the DND state.
;
exten => 7015,1,GotoIf($["${DEVICE_STATE(Custom:DND_7015)}"="BUSY"]?busy:available)
same => n(available),Verbose(3,DND is currently off for 7015.)
same => n,Dial(SIP/exampledevice)
same => n,Hangup()
same => n(busy),Verbose(3,DND is on for 7015.)
same => n,Playback(vm-theperson)
same => n,Playback(digits/7&digits/0&digits/1&digits/5)
same => n,Playback(vm-isunavail)
same => n,Playback(vm-goodbye)
same => n,Hangup()
Distributed Device States
Asterisk is primarily designed to run on a single system. However, as requirements for
scalability increase, it is common for deployments to require multiple Asterisk servers.
Since that has become increasingly common, some features have been added to make
it easier to coordinate multiple Asterisk servers. One of those features is distributed
device state support.
What this means is that if a device is on a call on one Asterisk server, the state of that
device on all servers reflects that. To be more specific, the way this works is that every
server knows the state of each device from the perspective of each server. Using this
collection of states, each server will calculate what the overall device state value is to
report to the rest of Asterisk.
Distributed Device States | 309