Hi, some comments on your script:

1.

Line 13 to 31, you are finding the radio0 sta iface, I’d rather just write one loop to do this. Go through $N=1 to 5 and find the “device=radio0” and “mode=sta”. This will be much clear.

2.

Line 33, you can just use “uci” to get if the interface is disabled, which will be much clear. Set a name for your sta wireless interface, like the following:

config wifi-iface ‘sta’
option device radio0
option mode ‘sta’
option disabled ‘1’
The use “uci get wireless.sta.disabled” to check if it is diabled.

3.

You are backing up the whole /etc/config/wireless file, which I think no good. Because the file may contains some other info that you didn’t want to reserve.

Just set the appropriate values. I think the values you are trying to reserve is ssid, channel, password, encryption, key, just store them in one file, for example, write another /ect/config/wireless_parameters file, and get these values by uci.

4.

I am not very clear of your logic to back up and restore configurations. Seems you stores many configurations and indicate them by flashing the LED a number of times. are you just restoring the last config?

Everytime when you trigger the script the router reboots. this could be last long. You can just reset the wireless or whole network.

reset wireless: execute “wifi”

reset network, execute “/etc/init.d/network restart”