SPA942 Personal Directory

I’ve been setting up Asterisk at work recently, as our old PABX has reached it’s limits.
We picked up half a dozen SPA942′s for some initial testing.
I have to say that while the phones are nice as an end user, however some of the administration functions seem to come up a bit short.
One of the big issues for us was that the personal directory on the phones doesn’t actually have to option to be populated from Asterisk (or any other PBX other than SPA9000). I have to admit though, I’m not really one to accept that something can’t be done.
After trying a number of things, I upgraded to the latest firmware (5.1.5 at time of writing) and after some more stuffing around, I was finally able to get the following line to populate the Personal Directory:

wget --post-data '24686=n%3DGeoff;p%3D6004;r%3D1&25390=n%3DMatt;p%3D6001;r%3D1' http://myphoneIP/pdir.spa

A few things about the command.
Firstly, the command will enter in two contacts in the Directory. These will be under entry #5 (24686) and entry #2 (25390). A complete list of all the codes here can be seen in the source of the Personal Directory page in the phone’s web interface.
So taking the first of the two entries (24686), what we’re posting is:

n%3DGeoff;

n=Geoff; (we need to escape the ‘=’ signs so that wget will actually pass the info on correctly)
n is the Display Name that will appear in the Directory

p%3D6004;

p=6004;
p is the extension number (or phone number). My extension is 6004.

r%3D1

r=1
r is the ring to use. 0 is no sound, just flashing. Play around with the other numbers to find the ringtone you want to use.

To add more than one entry at a time, simply separate the strings with ‘&’.

From here I’m going to look into LDAP integration, so that I can autorun the command, pulling the users and extensions out of Active Directory.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • LinkedIn
  • PDF
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Tumblr
  • Twitter
  • Yahoo! Buzz

22 Responses to “SPA942 Personal Directory”

  • Anonymous says:

    VERY helpful! Thanks so much for posting this. Exactly what I was looking for tonight.

  • Anonymous says:

    Handy piece of information. It also works on the SPA-941.The only thing to note is that the directory table cell ID’s differ from phone to phone. (or at least thats what I have experienced)

  • Anonymous says:

    interesting pieced of work, and will be of use at some stage. Thanks

  • Gijs says:

    Very helpfull indeed.
    I created a simple shell-script to update the personal directory in my SPA921 phone from a file.

    The script needs a file called tel_list which contains on each line the name and telephonenumber, with a “,” as seperation.
    e.g.:

    Foo Bar,12345
    Foo & Bar,23456

    I’ve placed the script here:
    http://got.td-er.nl/SPA921/update_phonebook
    and a test-file http://got.td-er.nl/SPA921/tel_list

    The script generates an update-script which does the actual updating.
    It writes the entries in the tel_list file into the first memory-cells, leaving the rest untouched.
    For each wget-operation, (max) 6 cells will be updated and between each update the script sleeps for 10 seconds to give the phone some time to process each update.

  • Anonymous says:

    Great idea! Thanks a lot for posting it.

  • Lester says:

    At work I wrote a python script that pulls directory info from a LDAP server and populates it to a SPA9xx phone. If anyone is interested I’ll put it up somewhere. :)

  • Geoff Jacobs says:

    @lester I’d love to see it done in python. I’m slowly migrating my scripts away from php so it would be great to see what you’ve come up with.

  • Johnny says:

    may i get the script to update the directory of my spas?

    thanks in advance.

  • Johnny says:

    may i get the script to update the directory of my spas?

    thanks in advance.

  • Geoff Jacobs says:

    @Johnny – take a look at my follow up post. http://grimsy.blogspot.com/2007/11/follow-up-to-spa942-personal-directory.html It contains a more complete script for doing so.

  • Johnny says:

    thank you.

  • un ermitaño sociable says:

    And how about deleting existing entries?…

  • Geoff Jacobs says:

    To delete an existing entry you need to overwrite it with a blank one.

  • Onno says:

    Thanks for the posts.
    Can you please help me in how I can successfully call a SIP URI instead of a Phonenumber, using the SPA942?
    Somehow it doesn’t work for me with the SPA942, although using a softphone like x-lite there’s no issue.
    Thanks,

  • Geoff Jacobs says:

    Haven’t really done too much with SIP URI’s sorry. Someone else may be able to help. Can also check out the linksys forums, there are some useful posts over there.

    Onno :

    Thanks for the posts.
    Can you please help me in how I can successfully call a SIP URI instead of a Phonenumber, using the SPA942?
    Somehow it doesn’t work for me with the SPA942, although using a softphone like x-lite there’s no issue.
    Thanks,

  • Pablo says:

    I have a SPA942 and im trying to run this examples, but nothing happens. What could it be? the firmware is: 6.1.3(a) and I can add phones using
    http://phoneip/pdir.htm this makes a post to
    http://phoneip/pdir.spa... but from my php script or from command line wget doesnt do anything.

    with wget i get:

    D:\www\socket>
    D:\www\socket>wget –post-data=’17006=n%3Dgino;p%3D200′ http://192.168.1.7/pdir.
    spa
    –2009-09-25 12:59:53– http://192.168.1.7/pdir.spa
    Connecting to 192.168.1.7:80… connected.
    HTTP request sent, awaiting response… No data received.
    Retrying.

    Can you please help?

    thanks

  • Geoff Jacobs says:

    I’ve never tried with wget from windows, so not sure if there’s a difference there.
    I’ve also noticed in the past that when the firmware updates, so do the ID’s of the form fields. Check the source of pdir.htm to check that the ’17006′ matches up with one that’s there.
    I’m not sure about the firmware version you’re using. I’ll try and check up tomorrow to see what I’m running on our system. If I get a chance I’ll update a handset and let you know.

  • Pablo says:

    Yes 17006 matches up one memory slot. Appart from WGET y have tried with a simple http post using a form… but nothings happens… I will try to do this from a linux. If you can give me any more information it will be great!!

    thanks!!

  • Geoff Jacobs says:

    Ok, I can confirm that I’m using 6.1.3(a) as well without any issues.
    Try wget from linux, but also perhaps pay close attention to the quotation marks you’re using.
    Also, check your wget syntax for post-data
    On Linux it’s

    --post-data

    where as you’ve got

    -post-data

    (one leading dash rather than two – might just be the way my blog renders things though).
    Let me know how you go.

  • Triplebeam says:

    I have recently bought a couple dozen of them spa942 telephones and I stumbled on your blog…

    Interested this post I opened a putty instance and logged in to my asterisk box, Here i pasted the string and fired the command only to see my unix box spew out:
    Connecting to 192.168.10.136:80… connected. HTTP request sent, awaiting response… No data received. Retrying.

    I’ve read the previous comments and identified the form field names in the html file. I put in the following : wget –post-data ’24046=n%3DGeoff;p%3D6004;r%3D1&23982=n%3DMatt;p%3D6001;r%3D1′ http://192.168.10.136/pdir.spa

    where 24046 and 23982 are the field names identified in the html file…

    Any help would be appreciated,

    Triplebeam
    The Netherlands

  • Geoff Jacobs says:

    I don’t know why some people are having issues with this and others aren’t. Seems really strange.
    Not sure why it would matter, but the phones I’ve been using are AU models. I wouldn’t think that would make a difference, as they seem to use the same firmware.
    What you entered looked fine. I know there are options in the phones to restrict access to the web interface – maybe check that those aren’t on.

  • Andy says:

    For Pablo and Triplebeam or anyone else getting the ‘HTTP request sent, awaiting response… No data received. Retrying.’ message: did you paste the code from this post? If so check the ampersand and make sure it is not the unicode version, which it probably is. I had the same problem and it’s from copying the HTML output on this page. It should only be a single, real, ampersand in between the entries.

  • Leave a Reply:

    Name (required):
    Mail (will not be published) (required):
    Website:
    Comment (required):
    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>