Set Up Linksys/Cisco PAP2T-NA With Gizmo5/Google Voice

Gizmo5 (recently acquired by Google) gives you a SIP phone number that you can link to Google Voice. This lets you use the Gizmo5 application to receive phone calls. But what if you want to use a real phone? Enter the ATA (Analog Telephone Adapter). Using a VoIP ATA you can hook in a normal telephone and receive calls from your Google Voice number like a landline!

For this tutorial I’m going to give the configuration requirements for a Linksys/Cisco PAP2T. Unfortunately, ATAs have a myriad of settings so it’s difficult to say exactly what you need to configure if you’re not using this model, but hypothetically speaking the settings should be similar.

With that caution out of the way let’s get started…

Prerequisites

To do this you will need an ATA (preferably a Linksys PAP2T-NA), a Gizmo5 account, and a Google Voice account. If you don’t have a Gizmo5 account you’re out of luck for now, because new signups are closed. If you meet these requirements then you’ll need to look up your Gizmo5 SIP number (starts with 1747). This can be found in your account overview at my.gizmo5.com. Write it down or copy it to a text file because we’ll use it in a few different places.

Configuring your Linksys PAP2T-NA ATA

Connect your PAP2T-NA to your network. It will obtain a DHCP lease, but you need to know the IP so you can look at the web interface. To find this, you can typically go look at the “device list” on your local router (which is frequently found at http://192.168.1.1). The ATA should show up named “LinksysPAP”. Once you’ve found the IP, type it in your browser and you will see this screen.
pap2t

Now you’ll need to click admin login, then click advanced view, then click line 1. This will bring you to this screen:
pap2t-advanced

Now scroll down and find the following options. Make sure they’re set as follows (don’t touch any other settings)1.

Sip Port: any port from 5060-5099
Proxy: proxy01.sipphone.com
Use Outbound Proxy: no
Outbound Proxy: leave blank
Use OB Proxy in Dialog: no
Register: yes
Make Call Without Reg: no
Register Expires: 60
Ans Call Without Reg: no
Use DNS SRV: no
DNS SRV Auto Prefix: no
Proxy Fallback Intvl: 3600
Proxy Redundancy Method: normal
Display Name: Your Name
User ID: 1747####### (Gizmo5 ID)
Password: yourgizmo5password
Use Auth ID: yes
Auth ID: 1747#######
Preferred Codec: G711U
Use Pref Codec Only: no
DTMF TX: Auto
Dial Plan: ([2-9]xx[2-9]xxxxxx|011xx.|1[2-9]xx[2-9]xxxxxx)2

Now click regional and change the ring waveform to “sinusoid” and the ring voltage to 90.

Finally, you’ll need to set up STUN support under the SIP tab. At the bottom of the page set the following settings:

STUN Enable: yes
STUN Server: stun01.sipphone.com
EXT RTP Port Min: 3478

Click save settings and let’s move on to configuring Google Voice.

Configuring Google Voice and Gizmo5

Head to the Google Voice website, click settings, then click “add another phone”. Select Gizmo, put in your 1747 number from earlier, and follow the directions. When it calls you to verify the number the landline you’ve connected to your PAP2T-NA should now ring. Once you’ve verified the phone you are done. To test you can call your Google Voice line yourself, or use the Google Voice website to call someone else! Enjoy your free phone.

  1. Hat tip to this thread for the requisite settings.
  2. The dial plan is only required if you wish to enable direct dialing of outbound calls (which costs money).

One Year Blogiversary

Around a year ago I finally decided to start a blog. Since then I’ve changed the domain, name, written over 60 posts about various things, and released two WordPress plugins. I had no defined goals when I started…and I still don’t! So in the spirit of my random posting, here are some stats about traffic growth and download numbers for my plugins. Let the navel gazing commence.

Random Traffic Statistics

The site has grown from an average of under 100 visits a week to well over 1500 now. Much of that growth has been driven by the release of Fidgetr and CDN Tools, my WordPress plugins (more on them later). However, the single most popular post I’ve written so far was the fix for GrowlMail in 10.6.2. Google indexed it quickly and it became the #1 search result for people attempting to fix their Mail plugin incompatibilities. Other popular articles include items about VMware and OpenSSL UCC/SAN certificates.

Plugin Statistics

Fidgetr has seen almost 9000 downloads since its initial release at the end of January. In that time it has dramatically improved, but I still welcome feature suggestions and patches (and new themes!). Would Picasa support be a useful addition?

CDN Tools has had over 2000 downloads since the end of February. Due to how deeply it hooks into WP I had to make significant changes for WP 2.8 as well as utilize several new hooks for WP 2.9 support. There is still quite a ways to go before I’m happy with this plugin, but I’m pleased that so many people are using it on their blogs.

With these two plugins I am currently the 605th ranked WP plugin dev (by downloads) according to w-shadow. Top 500 here I come!

WordPress 2.9 Upgrade

WP 2.9 is out. The upgrade went quite smoothly here, but be sure you upgrade your plugins before running the core upgrade! Fidgetr and CDN Tools are both 2.9 compatible already, so if you have the latest versions you’re set.

Comcast Chicago Clear QAM Cable Channels

For those who may wonder, as of the date of this posting here are the digital channel mappings for the various high definition channels Comcast (Chicago, north side) offers over clear QAM. These channels will be available if you directly connect a coaxial cable to an HDTV with a clear QAM tuner. Most TVs with ATSC (aka over the air/antenna tuners) also support clear QAM.

Channel Name Reported As
2.1 CBS CBS2
5.1 NBC NBC5-DT
7.1 ABC WLS-HD
9.1 WGN WGN-DT
11.3 PBS WTTW-HD
20.1 Wise TV WYCC-HD
26.1 The U WCIU-HD
32.1 Fox WFLD-DT
38.1 ION ION
50.1 my50 (MyNetworkTV) WPWR-DT
93.36 Hallmark Movies Nothing

There are many, many more SD digital channels available as well, but this list is intended to index only HD stations. Let me know if I’ve missed any or if the logical mappings change.

Writing Compatible PHP For WordPress

One of the big problems I’ve run into as a WordPress plugin developer is the diversity of PHP installations. Simply stating you only support PHP5 and greater is insufficient to ensure compatibility. Things you may take for granted in your development environment may be missing or worse, partially functional. I’ve decided to document a few of the bigger “gotchas” I’ve run into so future WordPress hackers will have a starting point for investigating problems.

Minimum PHP Version

One easy way to reduce compatibility confusion is specifying a minimum version of PHP for your WordPress plugin or widget. To do so you can use PHP’s version_compare function:

if(version_compare(PHP_VERSION, '5.0.0','<')) {
	die(sprintf('You are currently running PHP version %s and you must have at least PHP 5.0.x', PHP_VERSION));
}

Take a look at the version_compare documentation for more information.

PHP Modules

The biggest single thing to remember is that any module for PHP is optional. If you want to require something like curl, that’s great, but be aware that some non-trivial percentage of your potential users may not have it. Still want to use that module? Test for its presence during the instantiation of your plugin and die if it’s not present. This will prevent users from being able to successfully install your “broken” product if they don’t have the proper requirements.

Sometimes you’ll find yourself using functions you think are core to PHP like “mime_content_type”. This is not the case. In fact, I have frequently run into PHP installations that have no MIME detection facilities at all. Consider writing a fallback for suffix detection1 in addition to coding for mime_content_type and the finfo_* methods.

Safe Mode and Related Problems

Another common issue is safe_mode and open_basedir. These flags enforce certain security restrictions (must have the same group as PHP when writing to a directory, can’t open files beneath the basedir, et cetera). However, they also impact some modules. For instance, using curl you can’t use CURLOPT_FOLLOWLOCATION. This will trigger the error “CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set”.

Network Communication

I’ve already talked a bit about the curl module, but you may also be tempted to use file_get_contents() assuming allow_url_fopen is enabled. This is very frequently untrue in shared hosting environments. Luckily, you don’t need to rely on curl or allow_url_fopen or write your own fsockopen() wrapper class. Instead, WordPress has integrated Snoopy into the core. Invoking it to fetch just the contents of a URL could not be easier!

require_once( ABSPATH . 'wp-includes/class-snoopy.php');
$snoopy = new Snoopy();
$result = $snoopy->fetch($url);
if($result) {
	$response = $snoopy->results;
}

Just hit up Google for the class docs to learn everything Snoopy can do for you.

There are many more where these came from, so drop your problems and solutions in the comments!

  1. This can be a security risk in certain circumstances, so be careful.

Building Services Using Automator Workflows in Snow Leopard (10.6)

In Snow Leopard (Mac OS X 10.6) the Automator tool has been drastically upgraded to support the creation of service workflows. In simple terms, this means you can build automated chains of tasks that can be invoked in a context sensitive manner. Not simple enough? Using this tool, you can automate common actions you perform and the proper service will appear in the menu only when it is capable of being used. You can even assign global hotkeys (via the Keyboard preference pane) to your service. Let’s take a look at a simple service workflow so you can see how it’s done.

Open Automator (it’s located in your /Applications folder). You will be greeted by a sheet requesting a template for your workflow. Choose service.

choose_your_template

You’ll now be greeted by the main Automator window. On the left you’ll see a Library and actions you can perform. On the right you’ll see an empty pane where you drag actions or files to build your workflow. Third party applications you have installed can expose additional available actions, so the list of available actions will vary for each user’s computer.

main_window

As an example, we’re going to build a service that allows you to select files in the Finder, automatically zip them, and attach them to a new email. To begin, change the drop down in the upper right from “text” to “files or folders” and change “any application” to “Finder”. This means that the service we’re constructing will accept files or folders from the Finder as input. Next we need to add our first action. To accomplish this type “create” in the search field in the upper left of the actions pane. This will live filter the available actions so you can more easily locate the “Create Archive” action. Once you’ve found it, drag and drop it to the right hand side.

After creating the zip archive we want to attach it to a mail message. Search for “new mail message” and drag and drop it below the first action. It will prompt you with a few dialogs (mostly for permissions to access your keychain), but when you’re done you should have the workflow below.

prelim_workflow

To test you can click Run, but you’ll receive a warning that states “This service will not receive input when run inside Automator. To test this service within Automator, add the “Get Specified Finder Items” action to the beginning of your workflow. Remove or disable the action before running the workflow outside of Automator.”. Hit cancel (there’s no point to running our service without input!) and add the “Get Specified Finder Items” action to the very top of your workflow. You’ll also need to add an item or two for testing.

get_specified

To test the entire service, click Run in the upper right! You should see it create a zip file in the same directory as whatever files you specified, then open a new Mail message with your zip file attached.

If everything is working you can remove or disable the “Get Specified Finder Items” action and save your new service. Whatever you name it will be how it appears in your Services menu, so try to give it a descriptive name (something like “Create Zip and Email”). Now head to the Finder, select a file or folder, and click the Finder menu to see the Services submenu.

services_menu

Success!

But what if you don’t want to use that submenu? OS X allows you to assign global shortcuts/hotkeys to any Service using the Keyboard preference pane in System Preferences. Go to Keyboard Shortcuts within it, click the services option on the left, then find your “Create Zip and Email” option on the right. To add a shortcut you’ll need to double click on the righthand side of the Create Zip and Email row. Once the text box appears, press the key combination you want to use to invoke this service. Try to choose one that won’t conflict with anything.

keyboard_assigned

Automator has a great deal of power, so try experimenting with various actions to build your own ideal workflow. For example, I frequently parse SSL certificates in the course of my day, so I built this workflow to do it quickly and display the results in a text document in my editor of choice:

parse_cert

I also wanted a universal key combo to start the screensaver (which requires a password) so I could lock my computer quickly without using the mouse.

start_screensaver

If you’ve got other service ideas or want to show off one of you’ve written drop a comment! It’s always great to discover a better/more efficient way to accomplish a task.