Cisco IP Phone Services: Unrecognized Benefit

This blog post originally was going to be simply about how I can turn on and  off my home CCIE-W lab rack with my 7921 and 7970 IP Phones but when I started to think about how to develop the post I realized it could be much more. With increased functionality and benefits being all the rage these days in smartphones, tablets, computers, etc the IP Phone has also seen some of these advancements but they widely go unrecognized.

 

So what exactly is a Cisco IP Phone Service?

Well in a nutshell an IP Phone Service (IPPS) is simply a web based application that is rendered to the client as XML which the IP Phone knows how to parse and display in a user friendly manner on the phone. Cisco provides a simple image below:

As you can see from this image that the components you need at a bare minimum are a web server and an IP Phone that is setup to use some sort of PBX device, Cisco of course wants you to use their CallManager product line however at home I use Asterisk. The application can be developed in basically any language you prefer, I like PHP so all my stuff is wrote in that. But PERL, .NET, etc are all supported. You could even develop an app that has a builtin webserver to host the pages.  Hopefully you have an idea about IPPS now and how it works so how about some code?

Simple Menu Example

Let’s say for example that you simply want to display a menu as seen below:

Your Cisco IPPS code would simply be:

[codesyntax lang=”xml” lines_start=”1″]

<CiscoIPPhoneIconFileMenu>
    <Title>Menu</Title>
    <Prompt>Please Select An Item</Prompt>
    <SoftKeyItem>
            <Name>Select</Name>
            <URL>SoftKey:Select</URL>
            <Position>1</Position>
    </SoftKeyItem>
    <SoftKeyItem>
            <Name>Update</Name>
            <URL>http://192.168.10.20/cisco/services/home/phone/?name=SEP001B0CDB5159</URL>
            <Position>2</Position>
    </SoftKeyItem>
    <SoftKeyItem>
            <Name>Exit</Name>
            <URL>SoftKey:Exit</URL>
            <Position>3</Position>
    </SoftKeyItem>
    <MenuItem>
            <IconIndex>0</IconIndex>
            <Name>Home Automation</Name>
            <URL>http://192.168.10.20/cisco/services/ha?name=SEP001B0CDB5159&amp;devicename=SEP001B0CDB5159</URL>
    </MenuItem>
    <MenuItem>
            <IconIndex>1</IconIndex>
            <Name>OpenBook</Name>
            <URL>http://192.168.10.20/openbook/phone?name=SEP001B0CDB5159&amp;devicename=SEP001B0CDB5159</URL>
    </MenuItem>
    <MenuItem>
            <IconIndex>2</IconIndex>
            <Name>Cameras</Name>
            <URL>http://192.168.10.20/cisco/services/cameras?name=SEP001B0CDB5159&amp;devicename=SEP001B0CDB5159</URL>
    </MenuItem>
    <MenuItem>
            <IconIndex>3</IconIndex>
            <Name>Weather</Name>
            <URL>http://192.168.10.20/cisco/services/weather?name=SEP001B0CDB5159&amp;devicename=SEP001B0CDB5159</URL>
    </MenuItem>
    <MenuItem>
            <IconIndex>4</IconIndex>
            <Name>Traffic</Name>
            <URL>http://192.168.10.20/cisco/services/traffic?name=SEP001B0CDB5159&amp;devicename=SEP001B0CDB5159</URL>
    </MenuItem>
    <MenuItem>
            <IconIndex>5</IconIndex>
            <Name>VisualMail</Name>
            <URL>http://192.168.10.20/cisco/services/visualmail?name=SEP001B0CDB5159&amp;devicename=SEP001B0CDB5159</URL>
    </MenuItem>
    <MenuItem>
            <IconIndex>6</IconIndex>
            <Name>Help</Name>
            <URL>http://192.168.10.20/cisco/services/help.php?name=SEP001B0CDB5159&amp;devicename=SEP001B0CDB5159</URL>
    </MenuItem>
    <IconItem>
        <Index>0</Index>
        <URL>http://192.168.10.20/cisco/services/home/images/sm_icon_ha.png</URL>
    </IconItem>
    <IconItem>
        <Index>1</Index>
        <URL>http://192.168.10.20/cisco/services/home/images/sm_icon_addressbook.png</URL>
    </IconItem>
    <IconItem>
        <Index>2</Index>
        <URL>http://192.168.10.20/cisco/services/home/images/sm_icon_cameras.png</URL>
    </IconItem>
    <IconItem>
        <Index>3</Index>
        <URL>http://192.168.10.20/cisco/services/home/images/sm_icon_weather.png</URL>
    </IconItem>
    <IconItem>
        <Index>4</Index>
        <URL>http://192.168.10.20/cisco/services/home/images/sm_icon_cameras.png</URL>
    </IconItem>
    <IconItem>
        <Index>5</Index>
        <URL>http://192.168.10.20/cisco/services/home/images/sm_icon_voicemail.png</URL>
    </IconItem>
    <IconItem>
        <Index>6</Index>
        <URL>http://192.168.10.20/cisco/services/home/images/sm_icon_help.png</URL>
    </IconItem>
</CiscoIPPhoneIconFileMenu>

[/codesyntax]

The CiscoIPPhoneIconFileMenu is the specialized container that tells the phone I’m going to send you a menu to be displayed on the phone that will have icons associated with each line item. This menu is actually created via PHP code that dynamically creates that menu from a database. I have a web app that is wrote specifically to manage my Cisco IP Phones. I can assign what type of phone it is, whether or not it is authorized to use the home menu tool, and which apps are shown on the phone menu.

Simple Image Display

Generating a text menu is one thing, but how about showing an image? That can be done as well, the newer color screen phones such as the 7921, 7925, 7926, 7945, 7965, 797x, 7985, and the IPC can all display PNG images. The older phones such as the 7940/41/42 and the 7960/61/62 can show a CIP image that is a little more complicated to use. One of the uses for images that I use on my phones is to show my security cameras as well as traffic cams that were on my way to the office when I wasn’t working from home.

And the code for this IPPS page would be:

[codesyntax lang=”xml”]

<CiscoIPPhoneImageFile>
    <Title></Title>
    <Prompt></Prompt>
    <SoftKeyItem>
        <Name>Back</Name>
        <URL>http://192.168.10.20/cisco/services/traffic/?device=</URL>
        <Position>3</Position>
    </SoftKeyItem>
    <LocationX>0</LocationX>
    <LocationY>0</LocationY>
    <URL>http://192.168.10.20/cisco/services/traffic/templates/CP-7921G/gencamimage.php?cameraid=3&amp;rand=1626227066</URL>
</CiscoIPPhoneImageFile>

[/codesyntax]

The URL for the image simply needs to be that of the raw PNG data, nothing else. So what I do is take a screenshot from the camera and use the PHP image tools to recreate just a raw PNG:

[codesyntax lang=”php”]

<?php

error_reporting (E_ERROR | E_WARNING | E_PARSE);

$cameraid = $_REQUEST['cameraid'];
$display = $_SERVER['HTTP_X_CISCOIPPHONEDISPLAY'];
//$display = '298,168,12,C';
$display = str_replace(" ",'',$display);
list($x,$y,$depth,$color) = split(",",$display);

if(isset($cameras[$cameraid]['link']))
{
	$link = $cameras[$cameraid]['link'];
}
else
{
	$link = 'http://video.dot.state.mn.us/video/image?id=' . $cameraid;
}

$image   = imagecreatefromjpeg($link);
$image_x = imagesx($image);
$image_y = imagesy($image);

$image_resized = imagecreatetruecolor($x, $y);
imagecopyresized($image_resized,$image,0,0,0,0,$x,$y,$image_x,$image_y);

header("Content-type: image/png");
imagepng($image_resized);
imagedestroy($image_resized);

?>

[/codesyntax]

User Interaction

Where the IPPS really comes into play is the ability to actually perform operations as well such as running scripts on a web server. Each of those menu items can call another web page that would have certain actions attached to it. For example in the image below this is a status screen of some of the home automation systems installed at the house:

Again we are using a basic CiscoIPPhoneIconFileMenu to display a list of items to the end user, we have two basic icons that are associated. The red icon implies that the device or sensors are in a “false” state and green icons imply “true” state. Each of these menu items however are associated with an URL that then goes and does a certain action on my Insteon based automation network being managed via Indigo which runs on OSX. In the case of the action that created the buzz on Twitter my device Lab Rack Power is turned on and off by hitting a certain URL on Indigo that toggles the relay which turns on/off the power to the rack. This allows me to query the status of the power as well as remotely control it via a 7921 for example as shown below:

I hope this blog post shows some of the benefits of the Cisco IPPS features of an IP Phone. It’s very rare that I see any company actually use the IPPS features, most of the time I feel that it is simply because of lack of understanding how easy it is to develop the apps. Any web developer could easily create an IPPS in no time, most all of my apps have taken less than a few hours to do and Cisco has made it easy using headers sent via the phone’s request to know what the capabilities of the phone are (i.e. color, screen size, model, etc) to allow easy create of templates. For more information on how to develop IPPS apps please head over to the Cisco Developer Network

Here are some more images of some of my IPPS apps I have created:

6 Comments

  1. Jason Machtemes November 26, 2012 at 4:40 pm

    Blake,

    Stumbled on your page while researching Cisco IP Phone Services and was wondering if you could share the code for the image that you have that shows the garage door status with the green icons ? I am trying to do some similiar stuff with a home automation system i am building using ddwrt/asterisk/cisco 7940/arduino/. I can make the services pages work with just static XML but I am wondering about the dymanic parts liek you have in the garage door image. If not no worries, I thought it was pretty cool to find your page especially since I knew who you were previously due to wireless podcasts and the NSA podcast.

    Thanks,
    Jmac

    1. blake November 26, 2012 at 8:50 pm

      It’s actually pretty easy to do a fake dynamic style page, simply have the page auto refresh itself. By putting a header refresh in you can force the page to reload and update the status. I wish there was a better way of doing this with something like jQuery but the phone browser is pretty basic. You could always create a java midlet as well which would be able to handle dynamic content better. Glad you found it useful and enjoy the podcasts!


      header("Refresh: 15");

  2. quldude April 28, 2013 at 12:47 pm

    Is there a way to retrieve the content of the phone display in xml format? For eg: If i make a call to cisco from phone extension 2001, cisco will show on its display the calling number as 2001. But i want to validate in my custom program that cisco is trully seeing the calling number as 2001. How can this be done?

    1. blake April 29, 2013 at 10:05 pm

      Chances are you would have to use the AXL API on the CallManager server itself to get that data.

  3. Webster February 19, 2014 at 8:54 am

    Hi,

    Would you be able to share your script for weather service? I am working on a similar service for my work but having issues parsing the data.

    Thanks

    1. blake March 12, 2014 at 3:59 pm

      My script is long broke and no longer works because of API changes, sorry.

Leave a Reply to blake Cancel reply