Neo FreeRunner Wifi

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m
Line 30: Line 30:
 
   
 
   
 
  # WPA:
 
  # WPA:
  network = {
+
  network={
 
       ssid="your_ssid"
 
       ssid="your_ssid"
 
       scan_ssid=1
 
       scan_ssid=1
Line 38: Line 38:
 
   
 
   
 
  # WEP:
 
  # WEP:
  network = {
+
  network={
 
       ssid="your_ssid"
 
       ssid="your_ssid"
 
       scan_ssid=1
 
       scan_ssid=1

Revision as of 18:35, 6 July 2008

To get wlan working on your Freerunner, you can follow these steps:

1. create and edit a suitable /etc/wpa_supplicant/wpa_supplicant.conf (use your favourite search engine to find the syntax)

2. execute `ifup eth0`

3. execute `wpa_supplicant -ieth0 -c/etc/wpa_supplicant/wpa_supplicant.conf -B` (-B for running as daemon)

4. get a IP via dhcp: `udhcpc eth0`

That's it, your wlan should now work!

Sample wpa_supplicant.conf:

ctrl_interface=/var/run/wpa_supplicant
eapol_version=1
ap_scan=1

# WPA2:
network={
       ssid="your ssid"
       scan_ssid=1
       proto=RSN
       key_mgmt=WPA-PSK
       pairwise=CCMP TKIP
       group=TKIP CCMP
       psk="secret key"
       priority=50
}

# WPA:
network={
      ssid="your_ssid"
      scan_ssid=1
      psk="secret key"
      priority=10
}

# WEP:
network={
     ssid="your_ssid"
     scan_ssid=1
     key_mgmt=NONE
     wep_tx_keyidx=0
     wep_key0="secret key"
     priority=8
}

# Open:
network={
     ssid="your ssid"
     key_mgmt=NONE
     priority=5
}

A very ugly /etc/init.d/wlan startscript:

#!/bin/sh
#
# wlan	This shell script starts and stops wlan.
#
# processname: wlan

# Source function library.
#. /etc/rc.d/init.d/functions
# "written" by HdR

RETVAL=0
prog="wlan"

# test -f /etc/default/$prog && . /etc/default/$prog

start() {
	echo -n "Starting $prog: "
	ifconfig eth0 up
	wpa_supplicant -ieth0 -c/etc/wpa_supplicant/wpa_supplicant.conf -B
	sleep 10
	udhcpc eth0
	RETVAL=$?
	return $RETVAL
}

stop() {
	# Stop daemons.
	echo -n "Shutting down $prog: "
        killall wpa_supplicant
	ifconfig eth0 down
#        killproc gpsd
	RETVAL=$?
	return $RETVAL
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|reload)
	stop
	start
	RETVAL=$?
	;;
  *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
esac

exit $RETVAL

An alternative way to automate adds the wpa_supplicant details to /etc/network/interfaces:

iface eth0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Now `ifup eth0` will start up wpa_supplicant and udhcpc for you, and `ifdown eth0` will stop them, in theory at least. In practise udhcpc can time out before wpa_supplicant has finished connecting to the access point, and if udhcpc has failed to get an address ifdown exits without stopping wpa_supplicant and bringing down the interface.

Personal tools

To get wlan working on your Freerunner, you can follow these steps:

1. create and edit a suitable /etc/wpa_supplicant/wpa_supplicant.conf (use your favourite search engine to find the syntax)

2. execute `ifup eth0`

3. execute `wpa_supplicant -ieth0 -c/etc/wpa_supplicant/wpa_supplicant.conf -B` (-B for running as daemon)

4. get a IP via dhcp: `udhcpc eth0`

That's it, your wlan should now work!

Sample wpa_supplicant.conf:

ctrl_interface=/var/run/wpa_supplicant
eapol_version=1
ap_scan=1

# WPA2:
network={
       ssid="your ssid"
       scan_ssid=1
       proto=RSN
       key_mgmt=WPA-PSK
       pairwise=CCMP TKIP
       group=TKIP CCMP
       psk="secret key"
       priority=50
}

# WPA:
network={
      ssid="your_ssid"
      scan_ssid=1
      psk="secret key"
      priority=10
}

# WEP:
network={
     ssid="your_ssid"
     scan_ssid=1
     key_mgmt=NONE
     wep_tx_keyidx=0
     wep_key0="secret key"
     priority=8
}

# Open:
network={
     ssid="your ssid"
     key_mgmt=NONE
     priority=5
}

A very ugly /etc/init.d/wlan startscript:

#!/bin/sh
#
# wlan	This shell script starts and stops wlan.
#
# processname: wlan

# Source function library.
#. /etc/rc.d/init.d/functions
# "written" by HdR

RETVAL=0
prog="wlan"

# test -f /etc/default/$prog && . /etc/default/$prog

start() {
	echo -n "Starting $prog: "
	ifconfig eth0 up
	wpa_supplicant -ieth0 -c/etc/wpa_supplicant/wpa_supplicant.conf -B
	sleep 10
	udhcpc eth0
	RETVAL=$?
	return $RETVAL
}

stop() {
	# Stop daemons.
	echo -n "Shutting down $prog: "
        killall wpa_supplicant
	ifconfig eth0 down
#        killproc gpsd
	RETVAL=$?
	return $RETVAL
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|reload)
	stop
	start
	RETVAL=$?
	;;
  *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
esac

exit $RETVAL

An alternative way to automate adds the wpa_supplicant details to /etc/network/interfaces:

iface eth0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Now `ifup eth0` will start up wpa_supplicant and udhcpc for you, and `ifdown eth0` will stop them, in theory at least. In practise udhcpc can time out before wpa_supplicant has finished connecting to the access point, and if udhcpc has failed to get an address ifdown exits without stopping wpa_supplicant and bringing down the interface.