You are not logged in.
Pages: 1 2
THIS THREAD IS NOT ABOUT GENERAL WIFI PROBLEMS. ONLY GET INVOLVED IF YOU CAN CONNECT MANUALLY BUT HAVE PROBLEMS CONNECTING AUTOMATICALLY AT BOOT TIME.
Sometimes (about 1/3 of the time) my wifi wouldn't connect at startup and I'd have to start it manually. It would also be really slow to connect sometimes. I had a rummage in the scripts and found the wlan_on_boot.sh script to be deeply flawed. I've played with it to make what I think are improvements, and since then it has connected very quickly every time. If anyone wants to try it, type this
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 this thread and I'll try to help. I'd also appreciate a message letting me know if it helped.
For the more technically curious, the changes I've 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
Last edited by cjdshaw (2008-04-21 10:05:01 am)
Offline
my wifi never connects automatically on startup. no matter which hotspot i use. "on boot" is set in connection properties. connecting manually works fine.
used your wlan_on_boot.sh but it's still not the final solution to my problem.
thats my log:
Try 1 WLAN list = lan1 lan2 wlan:lan1 iface:ath0 essid:@schiller channel:11 5. WLANs found: print server 12C000 @schiller ifwlan 4. WLANs found: print server 12C000 @schiller ifwlan 3. WLANs found: print server 12C000 @schiller ifwlan 2. WLANs found: print server 12C000 @schiller ifwlan 1. WLANs found: print server 12C000 @schiller ifwlan Try 2 lan1 - @schiller will be a high priority search [...] (next two tries produce same log content)
three wifi's found. the wifi i want to connect to is @schiller.
seems MATCH_ESSID is making problems, as i never reach the echo "connecting ...".
i'm not sure about
MATCH_ESSID=`echo $WLAN_FOUND | grep "\b${ESSID}\b"`what does it exactly do?
/etc/network/interfacesn contains two of my wifi connections. the one for @schiller starts with the line
iface lan1 inet manual
i wonder what "manual" has to say?
my empty ethernet connection starts with
iface eth0 inet dhcp
to which parameter and file is the "on boot" option written to? is it probably the manual/dhcp flag? or is a simple "auto lan1" missing?
glad to find your post here. was working on that topic for days now too. took me ages to find out about wlan_on_boot.sh. when i finally started blaming the script right now, i found your post. thx for your work.
Last edited by datomm (2008-04-18 9:21:18 pm)
Offline
That data will be stored in
/etc/opt/xandros/xandrosncs/services/lan1
It must be set to "On Boot" though or the script wouldn't be trying it. You do seem to be right about that line though. It doesn't like ESSIDs with @ in them. I can probably work around that though by stripping out more of Asus's code. OK, I've replaced that line with one that should be more resilient. Try it now.
I'm curious as to why it doesn't prioritize the @schiller network though. Is it hidden or broadcast SSID? Also, is it definitely on channel 11?
Last edited by cjdshaw (2008-04-18 9:50:07 pm)
Offline
great! works now!
tried it myself with
MATCH_ESSID=`echo $WLAN_FOUND | grep $ESSID`
. was fine.
now i am using your grep ".${ESSID}."
/tmp/wlan_on_boot.log
Try 1 WLAN list = lan1 lan2 wlan:lan1 iface:ath0 essid:@schiller channel: 15. WLANs found: .@schiller. .ifwlan. Connecting lan1 on ath0 to @schiller... lan1 up ath0
for the prioritizing issue: it did prioritize on Try 2.
tested it again after startup with your last version manually
sudo /usr/sbin/wlan_on_boot.sh
and found it prioritizing on Try 1.
anyway, it's working. thx again!
edit:
SSID is broadcasted
for the last tries i set channel "11" back to "auto"
Last edited by datomm (2008-04-18 10:38:42 pm)
Offline
I made change and seems to be working.. did 10 reboots w/o a problem...
Thanks
BTW... maybe should be added to wiki???
Offline
datomm wrote:
tried it myself with
Code:
MATCH_ESSID=`echo $WLAN_FOUND | grep $ESSID`. was fine.
now i am using your grep ".${ESSID}."
The dots stop it from matching substrings, so if it's searching for "Wireless", the dot's would stop it from thinking it had found it when it saw "Freds Wireless".
Glad to see it's helping people. I thought I'd test it out here before putting it on the wiki
Offline
I've now replaced the dots with quotes, which will help when people have dots in their SSIDs. If they have quotes in them, well then they deserve everything they get.
Offline
I have been using the script as given in the original post for a week now and have not had one single connection problem. Before I had problem to automatically find the wifi network in about 1 in 5 attempts.
Great work, thanks!
Offline
Is there a current version of this script in the Wiki somewhere? I tried the wiki "search" function with "wifi script" but I must be missing something, it just produces a screen of useless unrelated so-called hits.
Offline
This is the latest version. I haven't updated my atheros-swan modules to try this script with, but it shouldn't change anything.
cjdshaw wrote:
If it still doesn't work, let it boot, wait a few minutes, then copy the contents of /tmp/wlan_on_boot.log to this thread and I'll try to help.
Was that too complicated? Do you want me to explain?
Offline
@jim_h I do not think it is in the wiki... AFAIK, this IS the only place its documented....
Offline
I have taken the liberty of putting it on the wiki -WiFi Connect on Boot
cjdshaw. I hope that is ok.
Offline
I have also now installed this on my eee and evertime I have rebooted so far it has connected.
While I understand that this does not solve all WiFi problems, I can't see why it should not be given to everybody who has "pending" problems because I think a lot of them don't understand some of the issues, like having lots of On Boot networks. It may not solve all the problems but, it seems, it can do no harm?
Offline
Great
Works and opens very quickly.
Many thanks
Offline
oliverhet wrote:
Great
Works and opens very quickly.
Many thanks
Ditto
Offline
Does this script necessarily have to run at boot time? I want to create a group of Easy Mode icons for the wireless APs I commonly use.
Each icon would invoke this script with a different SSID. I'm not a Linux guy but I can probably figure out how to parameterize this script. I'd also like to extend it to wait until the connection is ready, then bring up FireFox.
Offline
Ditto, this is another hit for the 900 crowd. thanks! nooow... if it would only come up from suspend.. heeey will it? let try....
well it doesnt look, but it loooks like that in /etc/acpi/wlan.sh is the same code you replaced from wlan_on_boot.sh ... could it be that simple to fix the suspend problem just to replace that code as well?
Offline
Yup, another 900 here and so far this is making a significant difference. Also curious about the suspend script...
EDIT: After a bit of research, I came across the solution to make this new script execute when resuming from a suspended state. Enter the following command:
sudo kwrite /etc/acpi/suspend2ram.sh
Look for the following lines:
# if wireless was ON before sleep - power it up
if [ $WLANP == "2" ]; then
sleep 1
/etc/acpi/wlan.sh poweron
/etc/acpi/wlan.sh restore
fi
And make them (changes in bold):
# if wireless was ON before sleep - power it up
if [ $WLANP == "2" ]; then
sleep 1
/etc/acpi/wlan.sh poweron
/etc/acpi/wlan.sh restore
/usr/sbin/wlan_on_boot.sh
fi
Last edited by dustingram (2008-05-24 1:45:24 am)
Offline
Brilliant - both tweaks have worked - the on-boot and after-suspend wifi automated connections - thanks to neil1952 and dustingram.
Offline
Now my wifi connects always, thank you!
Offline
Sisyphus wrote:
Brilliant - both tweaks have worked - the on-boot and after-suspend wifi automated connections - thanks to neil1952 and dustingram.
I don't understand why you are thanking me. cjdshaw is the genius behind this.
Offline
It didn't work for me because ifconfig would not return any interface, even though my blue light was on at boot. Somehow I got it working adding these llines at the beginning of the script:
#!/bin/sh
# Initial version from Asus/Xandros distribution - Modified by cjdshaw
IFACE="ath0"
/etc/acpi/wlan.sh poweroff
sleep 2
/etc/acpi/wlan.sh poweron
sleep 2
/etc/acpi/wlan.sh restore
sleep 2
#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
....
.... and so on
Offline
Niel1952 wrote:
I have also now installed this on my eee and evertime I have rebooted so far it has connected.
While I understand that this does not solve all WiFi problems, I can't see why it should not be given to everybody who has "pending" problems because I think a lot of them don't understand some of the issues, like having lots of On Boot networks. It may not solve all the problems but, it seems, it can do no harm?
Tried and tested perfectly - thanks for the help.
Offline
I don't get wifi at all and I tried this too, but no help.
Here's the contents of /tmp/wlan-on-boot.log:
Try 1 lan1 - WLAN-AP will be a high priority search WLAN list = lan1 wlan:lan1 iface:ath0 essid:WLAN-AP channel:6 5. WLANs found: "WLAN-AP" Connecting lan1 on ath0 to WLAN-AP... lan1 pending -
Offline
Pages: 1 2