Based on my needs, I had to find a solution to make the router change the wireless network if it went down, by itself.
After some work (I'm kinda nooby with linux scripting), I got this script.
It's been growing slowly with the help of the users in the forum, actually it works very well.
Many thanks to them!
Requisites:
- Openwrt installed, will not work on DDWRT!
- Enable and configure wifi as client, set it to WAN:
uci set wireless.@wifi-iface[0].disabled=0
uci set wireless.@wifi-iface[0].mode=sta
uci set wireless.@wifi-iface[0].network=wan
Disable wan from physical wired port, so it will work with wifi:
uci del network.wan.ifname
uci del network.wan6.ifname
Download the zip file, and follow the intructions inside "Readme.txt"
Do not copy & paste the text! It may fail due differences between linux's and windows's new line syntax.
There are two versions:
- WifiMgr 1.0 switches the wifi network ONLY when the network fails
- WifiMgr 1.0b also checks every few seconds if the preferred network is available, and switches to it if it's not connected to it already. This behaviour will cause constant drops if the preferred network fails often, as it will be switching constantly!
https://mega.nz/#F!KUcVSb6L!UvNxZlm1VsiyFAW3n6wAzA
To modify networks, edit the file /etc/wifiMgr/config.
Remember that if "net1" (COFFEE1) is found, it will be configured before "net2"(DSLrouter).
So, the order is important, configure at your own needs.
/etc/wifiMgr/config
##################################
# wifiMgr config file
##################################
# Background internet connection checking interval
ConnCheckTimer=60
# After new network is set, time to wait for network to establish, before checking if it's working
NewConnCheckTimer=25
# Set a random MAC on each boot
randMac="0"
net1_ssid="COFFEE1"
net1_encrypt="wep"
net1_key="CofeeWireless"
net2_ssid="DSLrouter"
net2_encrypt="psk2"
net2_key="dsl12345678"
net3_ssid="Home"
net3_encrypt="psk"
net3_key="MyHomeNetwork"
# ....and so on, make as much as you want. Remember to put the values between "" !
NOTE:
The script will never do anything else than a few "pings" when the network is ok.
Continuosly scanning and going to the preferred network would cause problems, like broken downloads or angry gamers.
So, it only works when the connection is already down!
UPDATES
2013-09-12
* Added input arguments to the script.
Now you can force a network scan and reconfigure the network by issuing:
wifiMgr.sh --force
The "--daemon" flag is created but shouldn't be used directly by the user. It is reserved for the init.d startup script.
2013-09-13
* Added timing variables.
* Changed "wlist" to a better undestandable name: "config"
* Now you can force a network scan specifying a network, example:
wifiMgr.sh --force 3
It will try to connect to the corresponding network "net3_ssid" (Home) and the result:
Not found, connection failed, or sucessful
2013-09-29
* Now it performs a scan on each reboot and reverts to the preferred network in the config file.
2013-10-08
* Added the variable "randMac". Setting it to "1" inside the config file will make the script to set a random MAC on each boot
2013-10-16
* Now all the generated MAC addresses have the format 00:xx:xx:xx:xx:02.
This is for testing purposes, as there was some strange issues on some of the generated MAC addresses
2014-06-03
* Fixed the file, it was completely wrong, it had a mix of files from an old version and the newest, so it didn't work.
Sorry for the big mistake!
(Last edited by dabyd64 on 22 Apr 2016, 20:56)