Blog Forum Wiki Links Contact Us NetbookUser
RunCore Pro IV SSD Transforms your ASUS EEE PC by increasing 
performance 5-40X. Your satistfaction guaranteed RunCore Pro 70mm SATA Mini PCI-e SSD
RunCore Pro IV 70mm SATA II Mini PCI-e SSD
RunCore Pro IV 2.5 Inch SATA II SSD

You are not logged in.

#1 2008-04-18 7:42:38 pm

cjdshaw
Member
Registered: 2008-02-25
Posts: 72

Having trouble with Wifi connect on boot? Try this

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

 

#2 2008-04-18 9:13:08 pm

datomm
New member
Registered: 2008-04-15
Posts: 6

Re: Having trouble with Wifi connect on boot? Try this

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:

Code:

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

Code:

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

Code:

iface lan1 inet manual

i wonder what "manual" has to say?
my empty ethernet connection starts with

Code:

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

 

#3 2008-04-18 9:41:44 pm

cjdshaw
Member
Registered: 2008-02-25
Posts: 72

Re: Having trouble with Wifi connect on boot? Try this

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

 

#4 2008-04-18 10:24:31 pm

datomm
New member
Registered: 2008-04-15
Posts: 6

Re: Having trouble with Wifi connect on boot? Try this

great! works now!

tried it myself with

Code:

MATCH_ESSID=`echo $WLAN_FOUND | grep $ESSID`

. was fine.
now i am using your grep ".${ESSID}."

/tmp/wlan_on_boot.log

Code:

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

 

#5 2008-04-18 11:44:21 pm

vegassam
Senior Member
From: Las Vegas, NV
Registered: 2007-12-19
Posts: 374

Re: Having trouble with Wifi connect on boot? Try this

I made change and seems to be working.. did 10 reboots w/o a problem...
Thanks

BTW... maybe should be added to wiki???


4 Gig surf - easy mode with many changes/upgrades
installed XP then moved it to a USB stick
900A - trying to get 16 gig SSD to work

Offline

 

#6 2008-04-19 7:45:49 am

cjdshaw
Member
Registered: 2008-02-25
Posts: 72

Re: Having trouble with Wifi connect on boot? Try this

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

 

#7 2008-04-21 10:06:34 am

cjdshaw
Member
Registered: 2008-02-25
Posts: 72

Re: Having trouble with Wifi connect on boot? Try this

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

 

#8 2008-04-29 5:38:17 pm

solenostomus
Senior Member
Registered: 2008-02-23
Posts: 101

Re: Having trouble with Wifi connect on boot? Try this

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

 

#9 2008-05-07 11:51:33 pm

jim_h
Senior Member
Registered: 2008-03-11
Posts: 205

Re: Having trouble with Wifi connect on boot? Try this

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

 

#10 2008-05-08 4:48:02 am

cjdshaw
Member
Registered: 2008-02-25
Posts: 72

Re: Having trouble with Wifi connect on boot? Try this

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

 

#11 2008-05-08 3:14:44 pm

vegassam
Senior Member
From: Las Vegas, NV
Registered: 2007-12-19
Posts: 374

Re: Having trouble with Wifi connect on boot? Try this

@jim_h  I do not think it is in the wiki... AFAIK, this IS the only place its documented....


4 Gig surf - easy mode with many changes/upgrades
installed XP then moved it to a USB stick
900A - trying to get 16 gig SSD to work

Offline

 

#12 2008-05-08 6:05:08 pm

Niel1952
Moderator
From: Cambridge, UK
Registered: 2007-11-02
Posts: 4802

Re: Having trouble with Wifi connect on boot? Try this

I have taken the liberty of putting it on the wiki -WiFi Connect on Boot

cjdshaw. I hope that is ok.


[Tweaking for] Absolute Beginners - A Guide to tweaking the Eee PC with wizards.
eeeuser Google Custom Search - THE eeeuser.com Search Tool

Offline

 

#13 2008-05-09 12:56:34 am

Niel1952
Moderator
From: Cambridge, UK
Registered: 2007-11-02
Posts: 4802

Re: Having trouble with Wifi connect on boot? Try this

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?


[Tweaking for] Absolute Beginners - A Guide to tweaking the Eee PC with wizards.
eeeuser Google Custom Search - THE eeeuser.com Search Tool

Offline

 

#14 2008-05-09 2:22:10 am

oliverhet
New member
Registered: 2008-03-11
Posts: 6

Re: Having trouble with Wifi connect on boot? Try this

Great

Works and opens very quickly.

Many thanks

Offline

 

#15 2008-05-09 3:15:16 pm

miketree
Member
Registered: 2007-11-11
Posts: 91

Re: Having trouble with Wifi connect on boot? Try this

oliverhet wrote:

Great

Works and opens very quickly.

Many thanks

Ditto

Offline

 

#16 2008-05-10 11:54:09 am

jim_h
Senior Member
Registered: 2008-03-11
Posts: 205

Re: Having trouble with Wifi connect on boot? Try this

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

 

#17 2008-05-11 6:08:02 am

irm
New member
From: London, UK
Registered: 2007-12-31
Posts: 4
Website

Re: Having trouble with Wifi connect on boot? Try this

Works on my 900. Thanks!

Offline

 

#18 2008-05-15 12:52:33 pm

ph0tic
Member
Registered: 2008-04-03
Posts: 51

Re: Having trouble with Wifi connect on boot? Try this

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

 

#19 2008-05-20 8:46:45 pm

dustingram
New member
Registered: 2008-05-14
Posts: 3

Re: Having trouble with Wifi connect on boot? Try this

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

 

#20 2008-05-26 7:22:44 pm

Sisyphus
New member
Registered: 2008-05-13
Posts: 6

Re: Having trouble with Wifi connect on boot? Try this

Brilliant - both tweaks have worked - the on-boot and after-suspend wifi automated connections - thanks to neil1952 and dustingram.

Offline

 

#21 2008-06-04 5:52:44 pm

Karoly
Member
From: Hungary
Registered: 2008-02-23
Posts: 12

Re: Having trouble with Wifi connect on boot? Try this

Now my wifi connects always, thank you!

Offline

 

#22 2008-06-04 5:58:01 pm

Niel1952
Moderator
From: Cambridge, UK
Registered: 2007-11-02
Posts: 4802

Re: Having trouble with Wifi connect on boot? Try this

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.


[Tweaking for] Absolute Beginners - A Guide to tweaking the Eee PC with wizards.
eeeuser Google Custom Search - THE eeeuser.com Search Tool

Offline

 

#23 2008-06-06 10:04:15 pm

mstroe
New member
Registered: 2008-06-06
Posts: 1

Re: Having trouble with Wifi connect on boot? Try this

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

 

#24 2008-06-18 7:15:20 pm

stevieboy
New member
Registered: 2008-06-18
Posts: 1

Re: Having trouble with Wifi connect on boot? Try this

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

 

#25 2008-06-21 6:32:31 am

Random_Eee
New member
Registered: 2008-06-18
Posts: 6

Re: Having trouble with Wifi connect on boot? Try this

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:

Code:

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

 

Board footer

Powered by PunBB 1.2.15
© Copyright 2002–2005 Rickard Andersson