Change states from a Cisco IP phone's button

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
User avatar
robi
Posts: 477
Joined: Sat Mar 17, 2007 10:48 am

Change states from a Cisco IP phone's button

Post by robi »

Here's an XML service to change ZoneMinder states from a Cisco IP phone's custom services menu.

This is useful when you don't want or you don't have access to a PC-based browser interface at a certain location (for example near the door or when leaving the area), but an IP telephone set is there and can do the state change for you.

It's pretty much like having a hardware user interface to engage or disengage the alarm system. Pressing the Services button on the phone brings up a menu with the states. Selecting the corresponding menu item will activate the selected state on the ZM server.

Put this php script (cisco_change_states.php) on your ZoneMinder box. Change the menu item names and the state names as you wish. Feel free to add more states. Check the path for zmpkg.pl, below it's the one for Ubuntu.

Code: Select all

<?php
$url = $_SERVER['REQUEST_URI'];
$parts = explode('/',$url);
$dir = $_SERVER['SERVER_NAME'];
for ($i = 0; $i < count($parts) - 1; $i++) {
 $dir .= $parts[$i] . "/";
}
$myurl = "http://" . $dir . basename($_SERVER["SCRIPT_FILENAME"]);

header("Content-Type: text/xml; charset=UTF-8");
header("Connection: close");
header("Expires: -1");
print "<?xml version='1.0' encoding='utf-8'?>\n";

switch ($_GET['sw']) {
    case 0:
?><CiscoIPPhoneMenu>
<Title>Change camera system state</Title>
<Prompt>STATE CHANGING NEEDS TIME</Prompt>
<MenuItem>
<Name>State 1</Name>
<URL><? print $myurl . "?sw=1"; ?></URL>
</MenuItem>
<MenuItem>
<Name>State 2</Name>
<URL><? print $myurl . "?sw=2"; ?></URL>
</MenuItem>
</CiscoIPPhoneMenu><?
        break;

    case 1:
        $output = shell_exec('/usr/bin/zmpkg.pl State1');
?><CiscoIPPhoneText>
<Title>Camera system state</Title>
<Prompt>Activated</Prompt>
<Text>State activated: State 1</Text>
</CiscoIPPhoneText><?
        break;

    case 2:
        $output = shell_exec('/usr/bin/zmpkg.pl State2');
?><CiscoIPPhoneText>
<Title>Camera system state</Title>
<Prompt>Activated</Prompt>
<Text>State activated: State 2</Text>
</CiscoIPPhoneText><?
        break;

}
?>
After that, just assign the script URL to your Cisco IP phone's Services button. How to do that depends on your Cisco Phone setup, should be either to add the URL to your phone's SEPmac.cnf.xml file like this

Code: Select all

<servicesURL>http://zm_server/cisco_change_states.php</servicesURL>
or set the URL correctly in Cisco's CallManager server if you have any.

Tested and working with a Cisco 7942 phone and Cisco IP Communicator softphone.
v1.25.0 + Ubuntu Linux 12.04 Server
User avatar
robi
Posts: 477
Joined: Sat Mar 17, 2007 10:48 am

Re: Change states from a Cisco IP phone's button

Post by robi »

BTW, the documentation CiscoIPPhone XML Objects shows quite a lot of possibilities. A password or pin code-enabled menu can be easily added to this little PHP script to add extra security.

Moreover, these phones are able to display PNG images, one could expand functionality using GD or imagemagick to actually show live camera stills on the phone's screen.
v1.25.0 + Ubuntu Linux 12.04 Server
Post Reply