PIONEERS Cisco SPA Phone XML Scripts

hbonath

Guru
Joined
Jan 24, 2012
Messages
147
Reaction score
36
Location
Columbus, OH
Hey guys -

I recently started looking into Cisco SPA Phones as an alternative to Aastra, mostly due to the Pain in the Ass factor with the Aastra XML scripts, plus the fact that the Aastra Phones do not have a built-in jitterbuffer. This seems to be killing us as a hosted PBX provider, being at the mercy of the quality of the customers ISP.

These Cisco phones are very affordable, seem to work well even on less than ideal connections, and have a good overall feel, despite being made in China =) The handset on my SPA525G seems to be almost exactly the same as the one Cisco uses on the 7960G, minus the LED pipe. And it fits in the ear-to-shoulder position well!

These were relatively easy to set up, using OSS EPM, and with a few tweaks to the base template, I was up and running.
The one thing I missed, of course, was the XML Scripts.
Cisco provides a few of these that you can install and play with:
https://supportforums.cisco.com/document/67056/cisco-spa-xml-services-asterisk-environments

However the 2 I really wanted were Directory and Parking Lot.
So I figured I would give it a go - how hard could it be, right?
I first started with trying to adapt the Aastra scripts to simply output Cisco XML, however my lack of being a developer really put a wrench in my efforts.

So Ultimately, I ended up putting together a simple Directory script that pulls the username/extension from the asterisk database and outputs it in Cisco Directory XML format for the phone to interpret. Basic, but works.

Next for the Parking lot - using some of the ideas I gleaned from the Aastra scripts, I implemented this one using Bash of all things, called from cgi-bin. (Can you tell I'm a sysadmin and not a developer?)
This one performs a similar function, however uses bash to call Asterisk CLI commands and interprets the results, then outputs any currently parked calls with park slot number, and caller-id name in the same Cisco Directory XML format, since the phone has built-in softkeys for selecting and dialing to "pick-up" parked calls.

I'd love to have some community feedback on these, as well as to share my efforts with the greater community - so I have posted these scripts on GitHub: https://github.com/hbonath/ciscospaxml

I would also like to know if anyone has any input on the security of using the CGI method, I would think that this should be pretty secure since it doesn't really take any outside arguments. However I'm definitely not a security expert!

These scripts need to be mapped as programmable softkeys on the SPA Phones:
First you need to define some PSK's:
Code:
<PSK_8>
  fnc=xml;url=http://your-pbx.com/cisco/directory/spadir.php;nme=Directory
</PSK_8>
<PSK_10>
  fnc=xml;url=http://your-pbx.com/cgi-bin/parkinglot;nme=Parking
</PSK_10>
Then you would set your Idle key list to display your softkeys when the phone is idle: (note the psk entries that would match your definitions)
Code:
<Idle_Key_List group="Phone/Programmable_Softkeys">
  em_login|1;acd_login|1;acd_logout|1;astate|2;avail|3;unavail|3;redial|5;psk8|6;cfwd|7;psk1|8;psk7|9;psk9|10;psk10|11;lcr|12;pickup|13;gpickup|14;unpark|15;em_logout
</Idle_Key_List>
Finally, I also gleaned a couple other bits from the internets that help solve a couple other challenges I had with this phone:

DND - Like pretty much any IP phone, when you press the DND key it uses a built-in function of the phone to reject any SIP INVITEs with a BUSY reply. However I wanted to see a DND that would both set the screen, and also tell Asterisk that the phone is on DND so that hints get updated for anyone that would be monitoring BLF.
I found a PSK definition on the Cisco Forums that will dial the *78/*79 codes plus update the local DND which will display that the phone is on DND on the screen.
Code:
<!-- DND with Asterisk --> 
<PSK_1 group="Phone/Programmable_Softkeys">fnc=sd;ext=*78;nme=DND;ext2=*79;nme2=ClearDND</PSK_1>
<DND_Act_Code group="Regional/Vertical_Service_Activation_Codes">*78</DND_Act_Code>
<DND_Deact_Code group="Regional/Vertical_Service_Activation_Codes">*79</DND_Deact_Code>
<Service_Annc_Base_Number group="Regional/Vertical_Service_Announcement_Codes">*7</Service_Annc_Base_Number>
<Service_Annc_Extension_Codes group="Regional/Vertical_Service_Announcement_Codes">DDT:8;DDF:9</Service_Annc_Extension_Codes>
<DND_Serv group="Phone/Supplementary_Services">Yes</DND_Serv>
<Service_Annc_Serv group="Phone/Supplementary_Services">Yes</Service_Annc_Serv>
<!-- /DND with Asterisk -->
Park - Aside from retreiving calls which are parked via XML, I needed a way to park a call and I didn't want to tie up one of the Line keys on the right of the phone with a bunch of "Speed-Dial/Xfer" functions.
This one adds the PSK to the screen when in-call (Connected state) which is basically a Speed-Dial/Xfer, however it adds a setting that will allow for the end user to hear the park slot before the call disappears.
Code:
<!-- PARK with Asterisk -->
<Connected_Key_List group="Phone/Programmable_Softkeys">
psk2|1;endcall|2;conf|3;xfer|4;crdstart;crdstop;bxfer;confLx;xferLx;park;phold;flash;
</Connected_Key_List>
<Keep_Referee_When_REFER_Failed group="SIP/SIP_Parameters">Yes</Keep_Referee_When_REFER_Failed>
<PSK_2 group="Phone/Programmable_Softkeys">fnc=sd;[email protected]$PROXY;vid=1;nme=Park</PSK_2>
<!-- /PARK with Asterisk -->
I hope that this is something of use to the community, and again - would love to get some feedback on some of the security-type stuff.
-Henry
 

hbonath

Guru
Joined
Jan 24, 2012
Messages
147
Reaction score
36
Location
Columbus, OH
Thank you Lorne!
The FreePBX Tie-in is exactly what I wanted to do with the directory. I also appreciate the "starter" for PHP.
When I get back, I'll dig into this some more, as I'd love to have a nice package for these phones that folks can use.

You are right on the compatibility with the 79xx series, at least for the Directory. The Park script I put together uses the same Directory schema, and I did test it on my 7960G. (Mapped it to the services button) and it pulls parked calls and lets you pick them up.
 
  • Like
Reactions: lgaetz

hbonath

Guru
Joined
Jan 24, 2012
Messages
147
Reaction score
36
Location
Columbus, OH
That $astman class is killer - I was re-inventing the wheel with my bash script ;-)
I'll have to play with that some.
 

tm1000

Schmoozecom INC/FreePBX
Joined
Dec 1, 2009
Messages
1,360
Reaction score
77
I spent a small bit of time attempting to get this to work:
PHP:
$out = $astman->ParkedCalls();
print_r($out);
Based on these docs, I assumed it would give me something useful, but output is:
Code:
Array ( [Response] => Success [Message] => Parked calls will follow )
I have seen this before when using the $astman, but can't recall what to do to fix. Perhaps one of the FreePBX Gurus like tm1000 can provide a hint?
"x will follow" means it's a non threaded reply. The reply comes from asterisk well after your script has ended. There are solutions to this but the function would have to be reworked. You can see examples of what I've done in 12 to get the functionality to work for conferences here (which also do the whole 'x will follow'): https://github.com/FreePBX/framework/blob/develop/amp_conf/htdocs/admin/libraries/php-asmanager.php#L521

That said I haven't done it for parking yet, though it could be done, just need a feature request on it so I can remember. Though it would be a 12 only feature.
 
  • Like
Reactions: lgaetz

tm1000

Schmoozecom INC/FreePBX
Joined
Dec 1, 2009
Messages
1,360
Reaction score
77
There is probably not more than a handful of people who care, but I encourage the FreePBX team to prioritize the cleanup.
Slowly but surely, in 12 I finally moved the code to use php5 functionality as opposed to PHP4, that is how old it is. I need to go through and modify the steam resources as well eventually.

Totally unrelated, but what is the history and/or status of phpagi (files: phpagi.php and phpagi_asmanager.php)?
FreePBX updates it over time, which means essentially qwell and I. It's the most up-to-date working PHP version of that script around.

Did FreePBX fork an independent project or was it absorbed by FreePBX?
It was originally just taken "as-is" from sourceforge when the project was updated. I would now say it's a fork.

There doesn't appear to be anything newer than 2009 on sourceforge, was the project abandoned?
That is correct the person working on it abandoned it. Most-likely because they either: A) No longer had a use for it B) Had no one helping to keep it up to date.

Are FreePBX improvements contributed back?
I have thought about that and would like to of course but I honestly have not reached out to the developer and every time I look at the site there's no activity. I have been told in passing that we have reached out in the past and didn't hear anything back but that is all hearsay as I haven't done it myself. I have also thought about moving it directly to github and let it be it's own stand alone project but it needs some tweaking as over the years developers have added core elements and functionality into it from FreePBX (such as $amp_conf which has no relation to a project outside of FreePBX). So I'd have to do that first.
 
  • Like
Reactions: lgaetz

hbonath

Guru
Joined
Jan 24, 2012
Messages
147
Reaction score
36
Location
Columbus, OH
So I learned that the Cisco XML limits directory entries to 32.
I updated with the FreePBX bootstrap and added some logic there to deal with a users table with more than 32 entries.
I'm having some fun getting my hands dirty working with PHP, but it's a slow go for me with a lot of Google Searching =)

I've updated it on Github so you can test it out if you get a chance.
 

phoneguy

Guru
Joined
Jan 13, 2008
Messages
285
Reaction score
54
We were considering adding the SPA line as the next phones to the FreePBX Phone Apps but since Cisco is no longer developing the SPA line and moved all developers off the project they are not the phones we would want to start supporting since they are not going to be around much longer.
 

hbonath

Guru
Joined
Jan 24, 2012
Messages
147
Reaction score
36
Location
Columbus, OH
Hmm that really stinks actually, I really am starting to like those phones...
Cisco doesn't have any documentation on them being end of life, how good is your intel there?
 

mike s.

New Member
Joined
Jan 4, 2015
Messages
2
Reaction score
0
Location
Boston, MA
Hi all,
I'm having trouble setting up my Commercial(paid) EndPoint Manager template doing BLF function with call Parking (Pro) I'm using Cisco SPA525G2 phones that at this moment all setup one by one manually ( thru web interface) and I dont have any issue using line commands:


fnc=blf+sd+cp;[email protected]$PROXY;nme=LINE 1 - NO issue reprodusing it under profiles at endpoint Mgr as BLF and Value *8571


fnc=blf+sd+cp;[email protected]$PROXY;nme=LINE 2 - BLF and Value *8572

But

fnc=sd;[email protected]$PROX;nme=PARK MY Call - no way I can generate this string and most important function, the only way I can do is to use *8670 - but its not doing the same thing such as park call on next spot and hangup



Please help, Thx mike
 

compuguy1088

Member
Joined
May 25, 2013
Messages
54
Reaction score
6
Hmm that really stinks actually, I really am starting to like those phones...
Cisco doesn't have any documentation on them being end of life, how good is your intel there?
That would explain why amazon (directly) isn't selling these phones anymore.....
 

fizadmin

Guru
Joined
Nov 27, 2011
Messages
78
Reaction score
2
We were considering adding the SPA line as the next phones to the FreePBX Phone Apps but since Cisco is no longer developing the SPA line and moved all developers off the project they are not the phones we would want to start supporting since they are not going to be around much longer.
It's now 2016, and the line of SPA phones continues to be available and to be developed by Cisco. Maybe this evaluation should be reconsidered?
 

fizadmin

Guru
Joined
Nov 27, 2011
Messages
78
Reaction score
2
..... and it's now 2017, and the Cisco SPA and SPA525G2 phones are still available and going strong.
 

m chapman

New Member
Joined
Jul 8, 2016
Messages
2
Reaction score
0
2019 and these 525g2 phones are still strong. This post has given information that has helped me a ton. I would like to find somewhere that can give me all the fnc flags that i could use.
 

Members online

PIAF 5 - Powered by 3CX

Forum statistics

Threads
22,319
Messages
137,021
Members
14,550
Latest member
treimers