Thursday, May 26, 2011

Fun With Cheap SIP VoIP Hardware

A few months ago I saw a few articles float through Google Reader about people doing some neat stuff with SIP hardware, at which point I really realized how much the second-hand SIP hardware market had finally come down to a point where I could afford to start playing around with it.

SIP is a Voice over Internet Protocol system, much like Skype, except that where Skype is a complete black box, SIP is a public specification, meaning that everyone else uses it, and can all call each other using their email-address like telephone numbers.  Also unlike Skype, since everyone ELSE can use it, there is much more nicer hardware supporting SIP than Skype, so you get a whole range of devices from epic teleconference rigs all the way down to simple ATA (Analog Telephone Adapters) allowing you to use any touch-tone phone you want, instead of only the crappy USB pseudo-soundcard "phones" you can get for Skype.

Between eBay and hitting up the Silicon Valley Swap Meet last week before the Maker Faire, I managed to get three SIP lines at $10 a piece (I'm actually getting pretty good at haggling at the swap meets).

This now of course begs the question, since everyone we know uses Skype, what use do I have for having three SIP phone to call myself across the room?  Personally, I have to admit I currently don't have much use for it, BUT, I think the consumer application for these is OBVIOUS:

Daughters.  I reckon every daughter at some point wants their own phone line to be able to call their friends in privacy.  With SIP, you can build your daughter and her girlfriends an entire phone system, separate from the general population, and if you setup your own SIP server (like Asterisk), even separate from the rest of the SIP network.  Buy each little friend their own ATA and they can all call each other as much as they want with no fixed costs for you, while you have the additional advantage that this is a walled garden environment.  Think of applying this to the same target audience as the popular-among-hackers IM-ME instant messaging system.

In that vein, here are a few walk-through guides as to how to configure various models of SIP hardware, which can at times become... difficult.  Setting up your own SIP server, and doing it well, is a little beyond me at this point, but if I ever do happen to figure it out, I'll update this.  For now, good luck reading through all the vague and half-correct tutorials out there on Asterisk, and enjoy these hardware tutorials to go with them:
And of course, if you have a different piece of SIP hardware that you want me to write a guide for, feel free to email me for my mailing address and mail me one to play with. :-)

Another cheap one I've seen pop up a few times which you could use is the OBi100 ATA.

How to Configure a Grandstream Handytone-386

 As part of my tutorials on configuring your own VoIP phone system, this is a step-by-step walk-through on how to configure the low cost Grandstream Handytone ATAs.  ATAs, or Analog Telephone Adapters, are kind of neat because they allow you to use any normal touch-tone you want, or even plug it into a house's existing analog phone wiring (after double-making-sure you're house is unplugged from POTS).
I got my Handytone on eBay, but even Amazon has the single port Handytones for a very good price.  The difference between the Handytone 386 I have and the Handytone 286 is that the 286 has a single phone port, where the 386 has two ports that you can configure to two SIP accounts, so it's essentially two 286s in one box.

And yes, that telephone is FABULOUS.  It also happens to be the only telephone I have access to...


Now, before trying to setup the hardware, I assume you already have access to some sort of SIP VoIP server.  This can either be by setting up and configuring your own Asterisk server, or more simply by signing up for an account from a SIP provider, such as SIP2SIP, which lets you have a free SIP account to call other SIP numbers and then only give them your payment info if you want to call POTS numbers.
  • Plug in the power cord, an Ethernet cable running to your router with DHCP, and a touch-tone phone into the FIRST port.  Wait a minute for the device to come up.
  • To configure the Handytone, we need to know its IP address on our home network to view its configuration page, much like how you configure a router.  To find out it's IP address, pick up the line 1 phone, dial ***02, and listen for the magical voice to say something like "IP Address one nine two dot one six eight dot zero zero one dot one five seven"
  • Now that we know the IP address, type it into a web browser like this: http://192.168.1.157/  This will hopefully bring up the login screen, where you can type in the admin password (hopefully the default "admin"). If the password admin doesn't work, you can reset the device per the instructions at the end of this post.
  •  Once you're in, most of the defaults as far as ringer, line voltage, etc are sane for North America. Click on the links for "FXS Port 1" or "FXS Port 2" and enter all of the information given to you by your SIP provider in the first five fields.  In the picture is everything needed to work with sip2sip.info.
  •  That should be it.  Plug phones into both ports, and you should have a dial tone and be able to make calls.  Calling other numeric SIP addresses in the same domain as you is as simple as dialing in their extension (i.e. I pick up my phone, which is 7653@sip2sip.info, and can dial 3333 to call 3333@sip2sip.info).  You can call other domains and POTS phones, but that's beyond the scope of this post, and you should just follow their instructions as such.


Resetting the device

If the default password doesn't work, and you don't know the changed password (e.g. bought it used), you need to reset the Handytone to factory defaults.  This is done by picking up the line 1 phone and dialing in ***99[MASTERPASSWORD], where the master password is the MAC address.

For example, reading the MAC address off the barcode on the bottom of my device, it is 000B820BB051.  All of the letters in the MAC address get encoded as: A - 22, B - 222, C - 2222, D - 33, E - 333, F - 3333.  Therefore, my MAC address becomes 000222820222222051, and the entire dial pattern: ***99000222820222222051.

This is all per the instruction manual found on Grandstream's website.

How to Configure a Polycom Soundpoint IP 330

This is another tutorial in my VoIP phone system series, specifically for configuring the Polycom Soundpoint IP 330 SIP phone.  This is one of several models of SIP phone made by Polycom, all of which are very simple, low-cost SIP VoIP phones.  The difficulty with using Polycom phones compared to the Grandstream Handytone series is that these are designed to be used with a provisioning server in addition to the SIP server.

What provisioning means is that in addition to the option of configuring the device through its web interface, you can instead point the phone at some kind of file transport server on the network (TFTP, HTTP(S), FTP(S)), where the phone will first try and download a device specific configuration file (based on its MAC address), then failing that, download a generic 000000000000 configuration file to setup defaults.

These configuration files need to do a couple basic things.  First of all, they need to define the phone's application; which will pretty much always just be the SIP application which Polycom provides on their product download page.  Second, the configuration files all point to a single config file with the SIP server details, which is common between all the phones.  Lastly, each config file points to a unique config file per user with their login credentials for the SIP server.  All of this together means you can easily reconfigure all of your phones by editing all of the config files on the provisioning server and then rebooting all of the phones, including updating the BootROM and SIP firmware on each phone.  This is great in large installations, but does tend to be another hurdle for personal use.

Luckily, at least on the 330 model, the phone has its own filesystem on-board such that once it successfully boots from the provisioning server once, it'll be able to boot independently from it, and you can reconfigure it through its web interface, so once you load the SIP firmware on the phone it CAN act like a normal SIP phone and this provisioning hubbub can be completely ignored.




This guide is assuming you're using the sip2sip.info SIP provider for the examples, so if you're using someone else or setting up your own SIP server, just change the sipserver.cfg file to fit your needs.
  • First step is downloading the needed files from Polycom's server.  The two zip files you'll need is the latest Split Polycom UC software (currently 3.3.1RevF[Split]), and the latest BootROM files (currently 4.3.0).  The difference between the split and combined packages is that the SIP firmware is either a bunch of 3MB files, or one giant 70MB blob.  The significance isn't particularly clear to me.
  • Now start copying files to your provisioning server.  Between TFTP, FTP, FTPS, HTTP, and HTTPS, you have plenty of different options as to what file transport you want to use.  I happen to already have an HTTP and TFTP server running on my Chumby, so I got both of those working, both with identical files:
    •  bootrom.ld & lots of 2345-#####-###.bootrom.ld files - These are the latest BootROM firmware images, which then load the SIP application.  I wasted a lot of time before updating the BootROM, so you probably want to load these, unless you enjoy having a schizophrenic telephone.  The phone will always try and download these from the provisioning server, so it they're not there this will just fail and the phone will happily move on to downloading config files.
    • sip.ld & sip.ver - sip.ld is the SIP firmware which the config files tells the BootROM to load to act like a SIP phone.  The sip.ver file is just a text file with the version number.
    • 000000000000.cfg - This is the default config file from the UC zip file which will have the phone load the sip.ld file and wait for you to configure the phone manually on the web interface.  At this point, you have enough files together to get the phones to turn on, download new BootROM images, download sip.ld, and sit there happily as unconfigured SIP phones.  The rest of the files are for bringing each phone up already configured as to its SIP identity instead of configuring them through your browser.
    • 0004f2175b35.cfg - Create a new text file with the specific phone's MAC address as its file name.  The MAC address is on a barcode on the back of the phone, and this file will point to sip.ld, sipserver.cfg, and x7653.cfg
    • sipserver.cfg - This file contains the location of the SIP server and outbound proxy, which is the same between all of your phones.  The example contents below is for sip2sip.info
    • x7653.cfg - This is the configuration file per extension, so x8835.cfg is for extension #8835, x7653.cfg is for #7653, etc.  This has the specific username and passwords for the SIP server.
    • log/ - Make this directory if you plan on giving the phones write permission to your provisioning server to post their log files, which is handy.  For TFTP, this means just configuring the TFTP server to allow PUTs, but for FTP and HTTP you can give the phones usernames and passwords to authenticate with the server to get access instead.
Now lets talk about these new config files you're making.  It's all pretty basic XML, so hopefully they can make some sense on their own.


Now there really is SO much more that CAN be done with these config files, like setup speed dials, directory listings, time servers, etc, but this will hopefully get you started.
  • At this point you should have some sort of file server, with all of those files available on it, and ideally some way to get write access to it either with a username and password (FTP, HTTP) or without (TFTP).  (I left my files on my webserver at http://kwf.dyndns.org:5821/polycom, which you might try and use, though it can be painfully slow downloading stuff from a home DSL line.)  Now we just need to point the phones at your setup provisioning server and hope like hell it works.
  •  Plug in your phone.  The PC Ethernet jack is just switched through the phone to the LAN jack, but since I have 12 ports on a switch under my desk, I didn't bother using the PC jack at all.
  •  When you first plug it in, you'll see this pre-boot screen.  Press the center soft-button to go to setup, and hope the default password "456" works.  If that doesn't work, start searching online about how to reset the phone, I haven't quite figured that out...
  • Make sure the DHCP client is enabled to automatically get a good IP address from your router, and then go down three lines and enter the "Server Menu" sub-menu.
  • Select the transport method, enter the server URL / IP address, user name, and password.  When entering text, the left soft-button will toggle between numbers and abc mode, "*" will enter ".", and "#" will cycle through symbols (/:~_@?=\+-&)
  • Press "exit," enter an SNTP URL if you care (i.e. time.nist.gov), and exit again to save & reboot.
  • At this point, the phone should hopefully download all the firmware images from your provisioning server, display its IP address, and end up on its home screen.
  • At this point, you can visit the phone's configuration page through its IP address (i.e. http://192.168.1.193/), log in with user "Polycom" password "456" for any more configuration you want to do, instead of through cfg files.
  • At least the 330 model is smart enough to store all of this locally, so you now have the option of shutting down the provisioning server, and in the future the phone will boot entirely internally if it can't reach the provisioning server.
Hopefully most of this makes sense.  There are some better tutorials out there on writing the XML for the config files, and however painfully long they are, admin guides will always be your friend.

Thursday, May 5, 2011

Tuesday at ESC

So as I mentioned last week, I skipped out on class Tuesday and decided to drive back down to San Jose for the day to attend the Embedded Systems Conference.  Needless to say, the day went better than I ever imagined.

Before I showed up at the convention center, I decided to stop at the classic Donut Wheel in Cupertino to get breakfast.  This turned out to pay off in folds, since I happened to get a few too many donuts, so when some random guy sits down next to me waiting for the keynote lecture hall to open, I offered him a donut.  Turns out that this random guy just happened to be Chris Gammell, who's post last week mentioning the conference was the entire reason I was there!

Sitting next to Chris Gammell listening to The Woz talk about inspiring engineers and teaching our children.

This was Chris' first time in the Silicon Valley, so I tried to lend myself helpful as a native throughout the day, with the added advantage that he introduced me to other big names like Jeff Keyzer, Jeri Ellsworth, and Grant Imahara.  Chris also pointed out that I could upgrade to a press badge with him, which got me free meals and all-access at the convention.

Being very excited about my MEDIA conference badge.
 My free lunch at ESC which wasn't worth the paper the lunch coupon was printed on.
Having a real lunch with Chris and Jeff at St Johns.  Of course, we were there because it was Tri-tip Tuesday.

I did try and spend as much time on the convention floor meeting the industry folks, as you do at conferences like this.  It was just so many hours of being completely overwhelmed with information, but very informative getting to talk to sales people at all the companies like TI, Atmel, ST, and on and on.  Talking to people throughout the day, two things really kind of surprised me:
  • People have actually heard of my work.  I'd say something like 50-60% of the people I talked to had seen or heard something of at least one of my recent projects, like the MSP430 LCD clock, or the Nixie Thermometer.
  • People were particularly excited that I'm doing work with the TI Launchpad.  All day people were complaining that for the amount of buzz and popularity the Launchpad has garnered for the last year, there have been relatively few impressive projects built on it. I assured them I'm working to correct this as much as possible.
Of course, I tried to get as much useful swag during the day as I could, since booths were giving away whole development kits, and I'm a poor college student who can't afford dropping money on any these days.
Complementary STM32L-Discovery dev kit.  Thanks ST!
Texas Instrument's MSP430G2452 vending machine.  Really drove home how low cost their value line parts are.

Of course, when the day at the convention was finishing up, Jeri had had the forethought to tweet a few days ago to meet up at Flames and to bring our hacks to share.  I didn't happen to have anything these days that was portable (all still breadboarded), but showed up anyways and had a lot of fun hanging out with a ton of people WAY smarter than me.  Good times were had all around.

A terrible picture of Jeri, myself, and Grant at Flames after the conference.

All in all, I had an amazing day matching faces to names.  It's just too bad I had to leave to get back to Davis for school.  Now I'm sitting here watching everyone else blog and tweet about all the awesome things happening in the other two days, and I'm just sad I couldn't stay there with them.

Sunday, May 1, 2011

TFTPd Server on Chumby

 In case anyone else needs a low-performance TFTP server on their Chumby and doesn't want to be bothered to go through all the work to cross-compile it from source, here's the fruits of my labor.  TFTP is a very simple file transfer protocol, usually used for booting hardware over the network.  I use it all the time to install Linux on my computers so that I don't have to bother burning install CDs every 6 months.  I don't leave any of my Linux desktops on ALL the time, so I decided to migrate my TFTP server to my alarm clock so it's available all the time.  This was primarily prompted because I've been spending some time bidding on Polycom IP500 SIP phones on eBay, and they require having a TFTP server on the network to just turn on.

Tarball binary for download.
Having it on a USB drive would have been the simplest, but I'm partial to installing software on the Chumby's microSD card, like I did for my http server.

To install, ssh into the Chumby:
cd /mnt/storage
wget kwf.dyndns.org:5821/files/tftpd.tar.gz
tar xfvz tftpd.tar.gz

Configure it to start on boot by adding the following line to /psp/rfs1/userhook1 and reboot:
/mnt/storage/tftp/sbin/in.tftpd -l -s /mnt/storage/tftp/var

Add any files you want available via TFTP on your network to /mnt/storage/tftp/var.

I compiled this from source for tftp-hpa 0.44.