Chapter 13. Device States

Out of clutter, find simplicity.

Albert Einstein

It is often useful to be able to determine the state of the devices that are attached to a telephone system. For example, a receptionist might require the ability to see the statuses of everyone in the office in order to determine whether somebody can take a phone call. Asterisk itself needs this same information. As another example, if you were building a call queue, as discussed in Chapter 12, Asterisk needs to know when an agent is available so that another call can be delivered. This chapter discusses device state concepts in Asterisk, as well as how devices and applications use and access this information.

Device States

There are two categories of devices that Asterisk provides state information for: channel devices (such as PJSIP endpoints) and virtual devices (which are built-in services that one might wish to monitor, such as conference rooms).

To reference the state of a channel, you do so in exactly the same way you would with Dial(), for example DEVICE_STATE(PJSIP/000f300B0B02), whereas to reference the state of a virtual device, the format is virtual device type:identifier, for example DEVICE_STATE(ConfBridge:1234).

Virtual devices include things that are inside Asterisk but provide useful state information (see Table 13-1).

Table 13-1. Devices for which Asterisk can provide state information
DeviceDescription
PJSIP/channel nameMany channels can have their state monitored, but the PJSIP channel offers ...

Get Asterisk: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.