How to reconnect wifi on waking from hibernation?

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
n0ukf
Posts: 129
Joined: Tue 14 Feb 2012, 21:53

How to reconnect wifi on waking from hibernation?

#1 Post by n0ukf »

How do I get my wifi connection to reconnect automatically after waking from suspended/hibernate mode?
"Cogito, ergo es. I think, therefore you is." [i]Ray D. Tutto (King of the Moon) to Baron Munschaussen[/i]

jafadmin
Posts: 1249
Joined: Thu 19 Mar 2009, 15:10

#2 Post by jafadmin »

I use shell scripts to connect to wireless instead of using wizards. I would imaging there would be a way to get puppy to execute a script upon resuming.

Code: Select all


#!/bin/sh
# Find our wifi device.
#
WIFI=$(iwconfig  | grep IEEE|awk {'print $1'})

# Bounce wifi device
ifconfig $WIFI down 
ifconfig $WIFI up

# Configure for WEP encryption on open/wep network
#
iwconfig $WIFI essid JR-MiFi
iwconfig $WIFI key "s:<<pwd-key>>"
iwconfig $WIFI mode managed
iwconfig $WIFI freq 2.452G
iwconfig $WIFI channel 9

# now to obtain an automatic IP address (DHCP)
# for Puppy 4.0 onwards
rm -f /var/lib/dhcpcd/*.info
rm -f /var/run/*.pid
dhcpcd -t 30 -h Lucid-Puppy -d $WIFI 

# Display connection info. (Optional; Rem if unwanted)
#
ipinfo


User avatar
n0ukf
Posts: 129
Joined: Tue 14 Feb 2012, 21:53

#3 Post by n0ukf »

Is this good for any available wifi or just reconnecting to the last one? Can I have a list of previously configured router connections (both open and encrypted) and autoconnect to whichever is available?

Does anyone know how to execute a script on wake?
"Cogito, ergo es. I think, therefore you is." [i]Ray D. Tutto (King of the Moon) to Baron Munschaussen[/i]

User avatar
n0ukf
Posts: 129
Joined: Tue 14 Feb 2012, 21:53

#4 Post by n0ukf »

Okay, ignoring the wake from hibernation for now...

I connect to one open router at home, one at my brother's home, one open but MAC-filtered at work, and have been trying to get connected to a secure one at church (but can't get the AES protocol that's being used there, only TKIP), as well as others. Can I have a list of connections for a connect script to connect to whichever (encrypted or unencrypted) router is available without specifying which myself?
"Cogito, ergo es. I think, therefore you is." [i]Ray D. Tutto (King of the Moon) to Baron Munschaussen[/i]

User avatar
chiron
Posts: 87
Joined: Mon 30 Oct 2006, 18:13
Location: Franken, Bavaria, Germany

#5 Post by chiron »

You need to find your suspend.sh file in /etc/acpi/actions.

In this file are all actions that are carried out on suspend.

In my file, it looks like this

Code: Select all

#suspend

/etc/rc.d/rc.network stop
killall wpa_cli
killall dhcpcd-wpagui
killall dhcpcd
killall wpa_supplicant
echo mem > /sys/power/state 

# process at recovery from suspend
modprobe ehci_hcd
/etc/rc.d/rc.network
/etc/init.d/50-Wpagui start
I am using fatdog64, but I remember in Lupu it was similar.

WPAGUI seems to be a pretty good way to manage wireless. I don't know whether it is available for a lot of puppies.

User avatar
n0ukf
Posts: 129
Joined: Tue 14 Feb 2012, 21:53

#6 Post by n0ukf »

Will that only reconnect to the last router or also connect to another if I've moved from work to home or wherever while suspended?
"Cogito, ergo es. I think, therefore you is." [i]Ray D. Tutto (King of the Moon) to Baron Munschaussen[/i]

User avatar
chiron
Posts: 87
Joined: Mon 30 Oct 2006, 18:13
Location: Franken, Bavaria, Germany

#7 Post by chiron »

since it starts a new instance of wpagui (after the oldone is killed when entering suspend), I suppose that it connects to whatever network is in reach. It usually takes some seconds from flipping the lid open to being connected again.

User avatar
n0ukf
Posts: 129
Joined: Tue 14 Feb 2012, 21:53

#8 Post by n0ukf »

Flipping the lid? All that does here is blank the screen, not suspend. And the power switch only turns it on, not off (except for the long-press hard stutdown) or hibernate. Unless someone can tell me how to fix that on Asus Eee900.
"Cogito, ergo es. I think, therefore you is." [i]Ray D. Tutto (King of the Moon) to Baron Munschaussen[/i]

User avatar
chiron
Posts: 87
Joined: Mon 30 Oct 2006, 18:13
Location: Franken, Bavaria, Germany

#9 Post by chiron »

I think you need some kind of acpi-support, and acpi tools. What puppy are you running? I assumed you had figured out suspend and hibernation, sorry.

The script I mentioned also uses acpi.

User avatar
n0ukf
Posts: 129
Joined: Tue 14 Feb 2012, 21:53

#10 Post by n0ukf »

Lucid 528. All I have for suspend right now is a one-line script:

Code: Select all

acpitool -s
with a symlink icon on the desktop that I doubleclick when I want it to sleep.
"Cogito, ergo es. I think, therefore you is." [i]Ray D. Tutto (King of the Moon) to Baron Munschaussen[/i]

User avatar
chiron
Posts: 87
Joined: Mon 30 Oct 2006, 18:13
Location: Franken, Bavaria, Germany

#11 Post by chiron »

The Lucid528 should have all the acpi support out of the box, which is good. Looong time ago I set up Lucid 510/520 to do the sleep thing on my thinkpad and that was quite complicated, it involved tinkering with the kernel etc.

You need to find the folder /etc/acpi/events in this folder, there should be some files, among them lid. This file tells the acpi subsystem what to do on closed lid. In my case it points to a script that is located in /etc/acpi/actions, with the name of suspend.sh.

One question though, does your eeepc have a lid switch? Or any means of detecting whether the lid is open or closed? Without it, you naturally won't be able to suspend on lidclose. Maybe you nee dspecial drivers/modules for lid-switch detection for the eeepc, I don't know, don't have one.

When you put your eeepc to sleep by clicking on the symlink, how do you wake up again? Pressing any key? Anyhow, you could put the lines I posted previous in your script, if all else fails.

User avatar
n0ukf
Posts: 129
Joined: Tue 14 Feb 2012, 21:53

#12 Post by n0ukf »

After the

Code: Select all

acpitool -s
I added the

Code: Select all

# process at recovery from suspend
modprobe ehci_hcd
/etc/rc.d/rc.network
/etc/init.d/50-Wpagui start 
and now it reconnects to both open and encrypted routers on wake (pressing any key). It must be automatically seeing my settings somewhere.
chiron wrote:One question though, does your eeepc have a lid switch? Or any means of detecting whether the lid is open or closed? Without it, you naturally won't be able to suspend on lidclose. Maybe you nee dspecial drivers/modules for lid-switch detection for the eeepc, I don't know, don't have one.
It has a magnetic lid switch which used to suspend it under Xandros. Currently with Puppy it only blanks the screen/backlight until I open it again. I'll look for those files you mentioned.
"Cogito, ergo es. I think, therefore you is." [i]Ray D. Tutto (King of the Moon) to Baron Munschaussen[/i]

Post Reply