====== WiFi Connect on Boot ======
This is an article to assist people using the default Xandros who can connect manually but who have problems connecting automatically on boot. It does NOT purport to solve general WiFi problems.
==== Introduction ====
On some combinations of eees and routers WiFi won't always connect at startup and has to be started manually. Sometimes the connection is also really slow.
**cjdshaw** has investigated the the scripts and found the wlan_on_boot.sh script to be flawed. He reports on [[http://forum.eeeuser.com/viewtopic.php?pid=248729#p248729|this thread]] that, having made the following changes, it has connected very quickly every time.
==== Steps ====
- Type this in terminal (**Ctrl+Alt+t**), pressing [ENTER] after every line.cd /usr/sbin
sudo cp wlan_on_boot.sh wlan_on_boot.sh_backup
sudo kwrite wlan_on_boot.sh and replace the contents with this
#!/bin/sh
# Initial version from Asus/Xandros distribution - Modified by cjdshaw
IFACE="ath0"
#if by any chance ath0 is not up yet - give it up to 10 second wait
i=0
while [ $i -lt 10 ]; do
if [ -n "`ifconfig -a | grep $IFACE`" ]; then
break;
fi
echo Waiting for $IFACE to be up - $i...
sleep 1
i=$((i+1))
done
TRIES=1
while [ $TRIES -le 3 ]; do
echo "Try $TRIES"
FOUND_ESSID=""
WLAN_FOUND=""
if [ -n "`ifconfig -a | grep $IFACE`" ]; then
WLAN=`/opt/xandros/bin/xandrosncs-servicedb --list | grep wlan | sed 's/ .*//'`
/sbin/ifconfig $IFACE up
VOCAL_WLANS=""
SILENT_WLANS=""
SCAN=`iwlist $IFACE scan 2>/dev/null | grep ESSID | cut -d '"' -f 2 | sed 's/.*/"&"/'`
for i in $WLAN ; do
ESSID=`/opt/xandros/bin/xandrosncs-servicedb -i $i -g WIRELESS_ESSID | cut -f 2 -d '='`
if $(echo $SCAN | grep -q \""${ESSID}"\") ; then
VOCAL_WLANS="$VOCAL_WLANS $i"
echo "$i - $ESSID will be a high priority search"
else
SILENT_WLANS="$SILENT_WLANS $i"
fi
done
WLAN="$VOCAL_WLANS $SILENT_WLANS"
echo "WLAN list = $WLAN"
for i in $WLAN ; do
if $(/opt/xandros/bin/xandrosncs-servicedb -i $i -g AUTO_START | /bin/grep -q onboot) ; then
/sbin/ifconfig $IFACE down
#assume it is ath0
#DEVICEID=`/opt/xandros/bin/xandrosncs-servicedb -i $i -g DEVICE_ID`
#DEVICEID=${DEVICEID##DEVICE_ID=}
#IFACE=`/usr/sbin/xangetdevices --udi $DEVICEID | grep Network\ Device`
#IFACE=`echo $IFACE | sed 's/^.*=[ ]*\(.*\)/\1/'`
ESSID=`/opt/xandros/bin/xandrosncs-servicedb -i $i -g WIRELESS_ESSID | cut -f 2 -d '='`
CHANNEL=`/opt/xandros/bin/xandrosncs-servicedb -i $i -g WIRELESS_CHANNEL | cut -f 2 -d '='`
echo "wlan:$i iface:$IFACE essid:$ESSID channel:$CHANNEL"
if [ -n "$CHANNEL" ]; then
DELAY=5
iwconfig $IFACE channel $CHANNEL
else
DELAY=15
iwconfig $IFACE channel 0
fi
iwconfig $IFACE essid "$ESSID"
/sbin/ifconfig $IFACE up
while [ $DELAY -gt 0 ]; do
sleep 1
WLAN_FOUND=`iwlist $IFACE scan 2>/dev/null | grep ESSID | cut -d '"' -f 2 | sed 's/.*/"&"/'`
echo "$DELAY. WLANs found:"
echo "$WLAN_FOUND"
MATCH_ESSID=`echo $WLAN_FOUND | grep \""${ESSID}"\"`
if [ -n "$MATCH_ESSID" ]; then
break;
fi
DELAY=$((DELAY - 1))
done
if [ -z "$WLAN_FOUND" -a -z "$CHANNEL" ]; then
echo No vocal WLANs found. Trying next
break;
fi
if [ -n "$MATCH_ESSID" ]; then
echo "Connecting $i on $IFACE to $ESSID..."
/opt/xandros/bin/xandrosncs-control -i $i start || ESSID=
FOUND_ESSID="$ESSID"
break
fi
fi
done
rm -f /tmp/onboot_*.scan
if [ -n "$FOUND_ESSID" ]; then
exit 0
fi
fi
TRIES=$((TRIES + 1))
done
exit 1
- Save and reboot
- If it still doesn't work, let it boot, wait a few minutes, then copy the contents of ''/tmp/wlan_on_boot.log'' to [[http://forum.eeeuser.com/viewtopic.php?pid=248729#p248729|this thread]] for assistance. Please also post a message on that thread if it helped.
==== Explanation ====
For the more technically curious, the changes made are:
* Allowed the script to wait 10sec for the interface to come up. Old version tried to do this but forgot to sleep
* Tried the entire process up to three times. Sometimes connection will fail for no apparent reason. Retrying often fixes this
* Prioritised visible networks. Old script just blindly worked its way through your list, so if you had a lot of "On Boot" networks, it could take a really long time before it tried the one you had access to. This won't help speed up non-broadcast SSIDs, of course, but it also won't slow them down
* Tweaked ESSID handling. It should be more compatible with ESSIDs with unusual characters in them
[[http://www.portabilite.info|rio sosh]] [[http://www.obtenir-rio.info|code rio]]