From Campworld

OpenWRT: Wireless Access in Your Car Using OpenWRT, Linksys WRT54G, and Linksys WAP11

Status

Introduction

I felt it was time for the car to have wireless. A little research revealed that AT&T DSL customers could add AT&T wifi for only $1.99. There seemed to be plenty of locations to choose from.

With a solid excuse I'm off to building.

I haven't ddecied if I want to permanently mount it in the car. I may keep it as a mobile unit. There are times when I would like to use it in someone elses car or run on batteries.

Here's a quick diagram of how I have everything setup.

 

             |-------------------------------|
EXT ANT =====| WRT54G                        |
             | (wifi configured as WAN port) |
             |-------------------------------|
                |
                | LAN
                |
             |-------------------------------|
             | WAP11                         |====== ANT
             | (configured as access point   |
             |-------------------------------|


Linkssy WAP11

There is nothing special about the WAP11. The WAP11 is configred as an AP for the clients in and around the car.

Linksys WRT54G

The WRT54G has OpenWRT installed on it. The big change is that the wifi gets set to client mode. The wifi port then is configured to replace the WAN port. The LAN with its firewall and NAT remain unchanged. The WAP11 plugs into one of the lan ports.

Software Setup

WRT54G

I'm not going to cover installing OpenWRT. Please visit http://www.openwrt.org. Once you have OpenWRT installed continue on.

Next there are some packages to install. If you have other packages to install this would be a good time to do it.
> ipkg install microperl wl

Now we want to set the wireless for client mode. I based my config on this howto http://wiki.openwrt.org/ClientModeHowto?highlight=%28HowTo%29. The mode I chose was routed client mode. Please read the howto for more in depth info. Type the following commands to set everything up.
> nvram set wl0_mode=sta
> nvram set lan_ifname=br0
> nvram set lan_ifnames=vlan0
> nvram set wan_ifname=eth1
> nvram set lan_ipaddr=192.168.2.1
> nvram set lan_proto=static
> ncram set wan_proto=dhcp
> nvram commit
> reboot

Next there are some scripts and web pages to create. This will make it easy to look for and join wireles networks. Most of the scripts are not formatted. There isn't a lot of memory in the WRT54G. Extra spaces to make it look pretty just eats up memory.

Rename the web interface page.
8>mv /www/index.html /www/webif.html

Now a new index.html page needs to be created. Enter the following for /www/index.html

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11$
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<center>
<h2>Magoo-Car Hotspot</h2>
<br>                         
<a href="/cgi-bin/wireless.cgi">WIFI SCANNER</a>
<br>
<a href="/webif.html">Web Interface</a>
</center>
</body>
</html>

Paste the following into /www/cgi-bin/wireless.cgi

 
#!/bin/sh
cat <<EOF
Content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<center>
<h2>Magoo-Car Hotspot</h2>
EOF
echo -n "<p>Date: "; date
echo "</p>"
echo "<h3>Current Connection</h3>"
echo "<pre>"
wl status
echo "</pre>"
echo "<table border='1'>"
iwlist eth1 scanning | microperl /sbin/wmonitor.pl
cat <<EOF
</table>
</center>
</body>
</html>
EOF

Paste the follwoing into /www/cgi-bin/joinwifi.cgi

 
#!/bin/sh
cat <<EOF
Content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<center>
<h2>Magoo-Car Hotspot</h2>
<pre>
EOF
echo -n "Date: "; date
echo "Connecting to network"
echo "QUERY_STRING:  $QUERY_STRING"
eval $(echo "$QUERY_STRING"|awk -F'&' '{for(i=1;i<=NF;i++){print $i}}')
myid=`httpd -d $id`
echo "ESSID=$myid"
mych=`httpd -d $ch`
echo "CHANNEL=$mych"
echo
ifdown wan
nvram set wl0_ssid=$myid
nvram set wl0_channel=$mych
ifup wan
/sbin/wifi
cat <<EOF
</pre>
</center>
</body>
</html>
EOF

These files need to be made executable.
> chmod 755 /www/cgi-bin/wireless.cgi
> chmod 755 /www/cgi-bin/joinwifi.cgi

The following script was based on a script I found on the openwrt website. Paste the following into /sbin/wmonitor.pl

 
open(INP,'-') or die "Couldn't read from STD input!\n";

my $line="";
my $essid="";
my $channel="";
my $signal="";
my $noise="";
my $snr="";

print "<tr><td><b>Channel</b></td><td><b>Signal</b></td><td><b>Noise</b></td>";
print "<td><b>SNR</b></td><td><b>TYPE</b></td><td><b>ESSID</b></td></tr>\n";

while ($line=<INP>) {
 if ($line=~m/ESSID:"(.*)"/) {
  $essid=$1;
 } elsif ($line=~m/Channel:(\d+)/) {
  $channel=$1;
 } elsif ($line=~m/Quality.*Signal level:-(\d+) .*Noise level:-(\d+)/) {
  $signal=$1;
  $noise=$2;
  $snr=$2-$1;
  $chkap="-";
  if ($essid eq "attwifi") {
   $chkap="*";
  }
  print "<tr><td>$channel</td><td>-$signal</td>";
  print "<td>-$noise</td><td>-$snr</td><td>$chkap</td>";
  print "<td><a href=\"/cgi-bin/joinwifi.cgi?id=$essid&ch=$channel\">$essid</a></td></tr>\n";
 }
}

WAP11

Well the WAP11 is pretty easy. Just configure the AP the way you like. If there is another AP you want to use then use it.

Hardware Setup

I wanted a package that could easily worked with. The WRT54G, WAP11, and mounting plate are secured with each other.

Feeding The Devices The Power They Need

The car will have a max voltage of 13.8 volts. The WRT54G can use this voltage without any issues. On the other hand the WAP requires 5 volts to run. I chose to use a LM7805. You can buy a DC to DC converter if you wish. The 7805 regulator will dissipate around 5 watts. A heatsink is required I cut the ends off the power adaptors. 6 inches of wire is good. I used a small project box for the regulator, wiring, and power indicator.

Conclusion

This has been a usefull project. This setup has many more uses. Experiment and have fun.

Comments

rcamp?07 February 2009, 17:44

When I wrote this howto Kamikaze wasn't out yet. Openwrt didn't support client and ap mode at the same time. And yes my new setup doesn't need the wap11.

I need to take a look at the ALIX 3c3. I want the usb to get internet through Verizon or AT&T cell networks. But when it finds my home wifi or an AT&T wifi hotspot I want it to switch over. I also want a usb GPS device.

Rob?05 February 2009, 13:33

If it makes you feel any better, I've got a similar setup in my Jeep; I was using an Asus WL-500gD to provide not only wireless access, but with USB ports also running MPD and some USB flash drives to turn it into a media player. I've since then upgraded to an ALIX 3c3 running openWRT that has two wireless radios built into it to give the same sort of wireless config you have, along with the USB audio/Mp3 player configuration... the sky's the limit here!

trevorj?21 December 2008, 12:54

This is a great idea, a car wireless repeater.

You really don't need the WAP11, you can have the wrt54g setup in client mode and AP mode at the same time, and set them both up on different split networks.

Gnarlodious?27 June 2007, 20:38

Bizarre!

Retrieved from http://www.campworld.net/thewiki/pmwiki.php/OpenWRT/CarWireless
Page last modified on February 07, 2009, at 05:44 PM