text stringlengths 0 152 |
|---|
| |
Chapter 13: Device States |
• UNAVAILABLE |
• RINGING |
• RINGINUSE |
• HOLDINUSE |
• ONHOLD |
SIP Presence |
Asterisk gives devices the capability to subscribe to extension state using the SIP pro‐ |
tocol. This functionality is often referred to as BLF (Busy Lamp Field); see |
Figure 13-1. |
Figure 13-1. Busy Lamp Field aka sidecar |
The configuration of the module will be slightly (or very) different for each manufac‐ |
turer; however, the subscription information will—one way or another—need to |
include the following: |
• The address of the Asterisk server (this might be defined on a per-button basis, |
or it might apply to the whole phone). |
• The context to subscribe to (in our sample dialplan, it’s named [hints]). This |
setting is defined in the subscribe_context field of the asterisk.ps_endpoints |
table. |
SIP Presence |
| |
243 |
• The relevant extension (100, 101, 102, etc.)1 |
One of the more simple and inexpensive ways we’ve found for testing presence is |
using the open source Windows softphone, MicroSIP.2 You’ll first need to download |
MicroSIP and get it registered to your Asterisk system. Then, under the contacts tab |
of the softphone, you can right-click in the open area to Add a contact. In the Name |
section you can put whatever you wish, but under the Number section, you will input |
extension@hints context, which in our case would be one of 100@hints, 101@hints, |
102@hints, or 103@hints. If you’ve set everything up in Asterisk per the previous |
examples, you should see the state of your subscriptions change in response to what‐ |
ever the far end set is doing. You can also monitor this from Asterisk’s perspective |
using a command such as: |
$ watch -n 0.5 "sudo asterisk -rx 'core show hints'" |
The configuration of presence on physical desk telephones is essentially the same, but |
it can be more difficult to make sense of the specific syntax each manufacturer |
requires. Our advice is to get it working with MicroSIP (which you should be able to |
run on WINE under Linux or macOS). It’s an easy setup, and from there you’ll have a |
known-good configuration you can trust when you’re sorting out a similar config for |
one of your desk phones. |
Using Custom Device States |
In addition to the devices Asterisk knows internally how to monitor (PJSIP, Conf |
Bridge, Park, Calendar), Asterisk also provides the ability to create custom device |
states, which can be very useful in the development of some interesting applications. |
Custom device states are defined using a prefix of Custom:. The text that comes after |
the prefix can be anything you want. To set or read the value of a custom device state, |
use the DEVICE_STATE() dialplan function. Put this into your extensions.conf right |
after extension 235: |
exten => 235,1,Noop(The state of 100@hints is ${EXTENSION_STATE(100@hints)} ) |
same => n,Hangup() |
exten => 236,1,Noop(Set a custom status) |
same => n(blink),Set(DEVICE_STATE(Custom:rudolph)=UNAVAILABLE) |
same => n,Set(DEVICE_STATE(Custom:santa)=NOT_INUSE) |
same => n,Wait(0.75) |
same => n,Set(DEVICE_STATE(Custom:rudolph)=NOT_INUSE) |
same => n,Set(DEVICE_STATE(Custom:santa)=UNAVAILABLE) |
same => n,Wait(0.75) |
same => n,Goto(blink) |
1 Items 2 and 3 may be formed as a single string, looking like 100@hints, or something similar. |
2 Which is written using the same PJSIP library that Asterisk uses. |
244 |
| |
Chapter 13: Device States |
Then add this to your [hints] context: |
exten => 221,hint,ConfBridge:221 |
exten => santa,hint,Custom:santa |
exten => rudolph,hint,Custom:rudolph |
Festive, yeah? |
You will notice that when you hang up, one of the custom device |
states will remain “Unavailable.” This is an important point: there is |
nothing in the system that will update your custom device states, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.