Asterisk Wi-Fi HotSpot Finder

WiFi Hot Spot Locator for any ZIP Code in the United States

The Asterisk WiFi HotSpot Finder is designed to retrieve name and address information for commercial, free, or all Wi-Fi Hot Spots for any zip code in the United States. Simply dial W-I-F-I and key in a zip code using any touchtone phone connected to your Asterisk PBX, and the data will be retrieved from 4INFO.net's WAP service and played back over your phone using the Flite text-to-speech engine. As with most Nerd Vittles' applications, this code is provided as an educational tool and is licensed for personal, non-commercial use.

Prerequisites

For the Asterisk WiFi HotSpot Finder to work, you'll need an Internet connection connected to your Asterisk server so that your server can access available web data on the Internet. We recommend a PBX in a Flash system with either the Flite or Cepstral voice synthesizer for Asterisk. If it's not already part of your Asterisk system, our Flite tutorial and the Flite application software are available here. This tutorial assumes you are using a PBX in a Flash server which already includes Flite.

Dialplan Setup

Your Asterisk Dialplan needs to be modified to support the Wi-Fi HotSpot Finder application. Wiht PBX in a Flash, point your web browser at your Asterisk server. Then choose System Administration->Config Edit and choose extensions_custom.conf from the file listing. When the file opens, scroll down to the [from-internal-custom] context. Cut-and-paste the following code into the file. To use Cepstral instead of Flite, uncomment the Swift lines (5 and 7) and comment out the Flite lines (5 and 7) with a leading semicolon. Then click the Update button to save your changes.

exten => 9434,1,Answer
exten => 9434,2,Wait(1)
exten => 9434,3,Set(TIMEOUT(digit)=7)
exten => 9434,4,Set(TIMEOUT(response)=10)
exten => 9434,5,Flite("At the beep enter the zip code for the Why Fye Hot Spots list to retrieve.")
;exten => 9434,5,Swift("At the beep enter the zip code for the Why Fye Hot Spots list to retrieve.")
exten => 9434,6,Read(ZIPCODE,beep,5)
exten => 9434,7,Flite("Please hold a moment while we contact Four Info dot Net for your report.")
;exten => 9434,7,Swift("Please hold a moment while we contact Four Info dot Net for your report.")
exten => 9434,8,AGI(nv-wifi.php|${ZIPCODE})
exten => 9434,9,NoOp(Wave file: ${TMPWAVE})
exten => 9434,10,Playback(${TMPWAVE})
exten => 9434,11,Hangup

freePBX Setup

While still connected to FreePBX with your browser, choose Setup, Misc Destination. Add a new entry for WiFi HotSpot Finder with 9434 as the Dial entry. 9434 spells Wi-Fi on your touchtone phone.

 Add Misc Destination
description:
dial:   

Save your entry and reload your Asterisk dialplan settings.

AGI Script Installation

Log into your Asterisk system as root. We need to copy the WiFi HotSpot Finder PHP script into the AGI directory on your server:

cd /var/lib/asterisk/agi-bin
wget http://nerdvittles.com/wp-content/nv-wifi.zip
mv nv-wifi.php nv-wifi.old.php
unzip nv-wifi.zip
rm -f nv-wifi.zip
chmod 775 nv-wifi.php
chown asterisk:asterisk nv-wifi.php

AGI Script Configuration

The WiFi HotSpot Finder script is fully functional as delivered. It will retrieve both commercial and free WiFi Hot Spots for the zip code you select. If you'd prefer to only retrieve one or the other, log into your Asterisk server as root and edit the nv-wifi.php script in the /var/lib/asterisk/agi-bin directory on your Asterisk server: nano -w /var/lib/asterisk/agi-bin/bv-wifi.php. Adjust the following configuration settings to meet your requirements. 1 means yes, and 0 means no. After updating the settings, save the file: Ctrl-X, Y, then Enter.

 $paywifi = 1 ;
 $freewifi = 1 ;

You also can change the default text-to-speech engine from Flite to Cepstral by changing $ttspick from 0 to 1. If you change the TTS engine, make sure to adjust lines 5 and 7 in the Dialplan Setup above to also use Cepstral by uncommenting the Swift lines and commenting out the Flite lines with leading semicolons.

Missing Directory Setup

On some other distributions (not PBX in a Flash), the sounds directory in which the spoken reports are stored has disappeared. The symptom for this would be a message that introduces the report but never plays it. Here's how to recreate the directory:

cd /var/lib/asterisk/sounds
mkdir tts
chmod 775 tts
chown asterisk:asterisk tts

System Setup

Temporary files in /tmp get cleaned up by Linux housekeeping automatically. Temporary files stored elsewhere don't. The easiest way is to add a crontab entry which automatically deletes the files. Log into your Asterisk server as root and issue the following command: nano -w /etc/crontab. If you have not already done so for another Nerd Vittles application, move to the bottom of the file and insert the following code on a blank line:

3 0 * * * /usr/bin/find /var/lib/asterisk/sounds/tts -type f -mtime +14 | /usr/bin/xargs /bin/rm -f >/dev/null 2>&1

This code will delete all of the files in the tts folder every two weeks. If you'd prefer a shorter time, change the number 14 accordingly. Now save your changes: Ctrl-X, Y, then Enter.

Using the Asterisk WiFi HotSpot Finder

To use the Asterisk Wi-Fi HotSpot Finder by Zip Code, pick up any phone connected to your Asterisk server and dial 9434. When prompted, key in the five-digit Zip Code for the WiFi Hot Spots you wish to retrieve. Then sit back and listen. If, for some reason, you don't receive a report, be sure to check this sample link using your web browser (http://wap.4info.net/search?searchQuery=wifi%2029464) to verify that wap.4info.net is operational.

Original Nerd Vittles Article (4/18/2007): Introducing the Asterisk WiFi HotSpot Finder