PowerGod
Forum Addict!
- Joined
- Jun 20, 2011
- Messages
- 4,462
Here a script to auto-reconnect to the access point, for all the people that have problems with the integrated WiFi.
Sometimes the driver doesn't recognise the disconnection, and this is the reason why I made this program.
- old script -
In the new version I made a complete pnd structure with the menu to turn on and off the script.
It doesn't write anymore on the nand tmp dir but in his appdata.
It works well on my pandora, but I'm stuck on how to pack the directory into a PND...
I wanted to post at least the directory, cause it works like a pnd if put in the right path, but seems I can't post it here, maybe I need some permissions...
I made it ! Finally, here the pnd !!
I need to thank Slaeshjag's "swap tool" cause I studied how was working his app to make mine
INSTRUCTIONS:
Works only with NetworkManager (the Default program on the Pandora)
1) Connect to the Access Point
2) Launch WiFiRecon (from System menu) and select "Activate autoreconnection"
3) To quit launch againg WiFiRecon and select "Deactivate autoreconnection"
FUTURE ADDICTIONS:
- Better Icon... maybe
- Slow down the ping rate
- Some code cleaning
EDIT (05 August 2012):
After installing SuperZaxxon Final I'm not anymore able to reproduce the problem, so it seems I don't need this anymore
EDIT (23 January 2013):
I was wrong... and I still need to use this PND sometimes
wifirecon.pnd
Sometimes the driver doesn't recognise the disconnection, and this is the reason why I made this program.
- old script -
I'm new to this kind of things and lost many hours on man pages and google to make this, but it's not finished, I want to make at least a PND with an ON/OFF menu.
Anyway it just ping the router address until the message 'Destination Host Unreachable' comes, and then restart the same connection.
No parameters are needed, just launch it like this in a terminal:
sh /media/<YourSD>/wifirecon.shTo terminate the script use CTRL+C or kill it.
(You can also launch it "Executing" the file from Thunar, but better not for now, cause you can't see the messages and there are bugs)
BUGS:
- Sometimes the script start to replicate itself...at every reconnection... so better open it in a terminal, so closing it's window will kill all the instances
I'm actually using this script and posting from my Pandora, cause I'm able to reproduce the disconnecion problem simply turning on wifi on the other PC and make it download with some p2p software.
Now the Pandora is disconnecting every 1/3 minutes, but I don't mind cause it's reconnecting automatically
Tell me what you think and what you find wrong.
EDIT: Seems I can't upload a bash script... so here the content, copy it in a text editor and save as "wifirecon.sh"
#!/bin/bash
#
# WiFiRecon ver.0.1a
# Script for Pandora
# by PowerGod (06/09/2012)
#
# Auto-Reconnection to WiFi
# when the address is unreachable
#
# Pings the router to verify the status,
# in case of no answer it reconnects
# to the access point
#
# Find if there's already an instance running
vlockfile=/tmp/wifirecon-lock
# Find if exist the lock file
if [ -f "${vlockfile}" ]; then
# Read the ID in the lock file
# to confirm that is already running
vappid=$(head -n 1 "${vlockfile}")
vrunlrd=$(ps -p "${vappid}" | grep "${vappid}")
# If the PID is wrong will be updated
if [ -z "${vrunlrd}" ]; then
# Copy the PID in the lock file
echo $$ > "${vlockfile}"
else
echo
echo "wifirecon.sh is already running"
echo
exit 0
fi
else
# Create the lock file with the PID
echo $$ > "${vlockfile}"
fi
# Get the Router IP
vrouteip=$(ip route $1 | grep "via" | gawk '{print $3}')
# Find if there is a started connection
if [ -z "${vrouteip}" ] ; then echo ; echo "A connection must be started before launching this script !!" ; echo ; exit ; fi
echo
echo "Monitoring the IP:" "${vrouteip}"
echo
echo CTRL+C to Quit
echo
# Endless loop
while [ 1==1 ]; do
vuuid=$(ping -c 1 "${vrouteip}" | grep -o "Unreachable")
if [ -z "${vuuid}" ] ; then vuuid="null" ; fi
if [ "${vuuid}" == "Unreachable" ]; then
# Reconnect
echo
echo $(date +%x\ %X) : Reconnection to "${vrouteip}"
vuuid=$(nmcli -t -f UUID con status)
nmcli con up uuid "${vuuid}"
fi
done
Anyway it just ping the router address until the message 'Destination Host Unreachable' comes, and then restart the same connection.
No parameters are needed, just launch it like this in a terminal:
sh /media/<YourSD>/wifirecon.shTo terminate the script use CTRL+C or kill it.
(You can also launch it "Executing" the file from Thunar, but better not for now, cause you can't see the messages and there are bugs)
BUGS:
- Sometimes the script start to replicate itself...at every reconnection... so better open it in a terminal, so closing it's window will kill all the instances
I'm actually using this script and posting from my Pandora, cause I'm able to reproduce the disconnecion problem simply turning on wifi on the other PC and make it download with some p2p software.
Now the Pandora is disconnecting every 1/3 minutes, but I don't mind cause it's reconnecting automatically
Tell me what you think and what you find wrong.
EDIT: Seems I can't upload a bash script... so here the content, copy it in a text editor and save as "wifirecon.sh"
#!/bin/bash
#
# WiFiRecon ver.0.1a
# Script for Pandora
# by PowerGod (06/09/2012)
#
# Auto-Reconnection to WiFi
# when the address is unreachable
#
# Pings the router to verify the status,
# in case of no answer it reconnects
# to the access point
#
# Find if there's already an instance running
vlockfile=/tmp/wifirecon-lock
# Find if exist the lock file
if [ -f "${vlockfile}" ]; then
# Read the ID in the lock file
# to confirm that is already running
vappid=$(head -n 1 "${vlockfile}")
vrunlrd=$(ps -p "${vappid}" | grep "${vappid}")
# If the PID is wrong will be updated
if [ -z "${vrunlrd}" ]; then
# Copy the PID in the lock file
echo $$ > "${vlockfile}"
else
echo
echo "wifirecon.sh is already running"
echo
exit 0
fi
else
# Create the lock file with the PID
echo $$ > "${vlockfile}"
fi
# Get the Router IP
vrouteip=$(ip route $1 | grep "via" | gawk '{print $3}')
# Find if there is a started connection
if [ -z "${vrouteip}" ] ; then echo ; echo "A connection must be started before launching this script !!" ; echo ; exit ; fi
echo
echo "Monitoring the IP:" "${vrouteip}"
echo
echo CTRL+C to Quit
echo
# Endless loop
while [ 1==1 ]; do
vuuid=$(ping -c 1 "${vrouteip}" | grep -o "Unreachable")
if [ -z "${vuuid}" ] ; then vuuid="null" ; fi
if [ "${vuuid}" == "Unreachable" ]; then
# Reconnect
echo
echo $(date +%x\ %X) : Reconnection to "${vrouteip}"
vuuid=$(nmcli -t -f UUID con status)
nmcli con up uuid "${vuuid}"
fi
done
In the new version I made a complete pnd structure with the menu to turn on and off the script.
It doesn't write anymore on the nand tmp dir but in his appdata.
It works well on my pandora, but I'm stuck on how to pack the directory into a PND...
I wanted to post at least the directory, cause it works like a pnd if put in the right path, but seems I can't post it here, maybe I need some permissions...
I made it ! Finally, here the pnd !!
I need to thank Slaeshjag's "swap tool" cause I studied how was working his app to make mine
INSTRUCTIONS:
Works only with NetworkManager (the Default program on the Pandora)
1) Connect to the Access Point
2) Launch WiFiRecon (from System menu) and select "Activate autoreconnection"
3) To quit launch againg WiFiRecon and select "Deactivate autoreconnection"
FUTURE ADDICTIONS:
- Better Icon... maybe
- Slow down the ping rate
- Some code cleaning
EDIT (05 August 2012):
After installing SuperZaxxon Final I'm not anymore able to reproduce the problem, so it seems I don't need this anymore
EDIT (23 January 2013):
I was wrong... and I still need to use this PND sometimes
wifirecon.pnd
Attachments
Last edited by a moderator: