Yun WiFi - programatically configure

I want to be able to read the WiFi configuration from the SD card, then apply and reboot the AR9331. I have all the code working, but when checking with "/usr/bin/pretty-wifi-info.lua" it doesn't detect the network.

The very same problem was experienced by someone else on this thread: Can the Yun be programmed to connect automatically to a Wi-fi connection? - #7 by sonnyyu - Arduino Yún - Arduino Forum. One of the response was to do the following:

Step 1. Web portal interface have to work.
Step 2. "./setupwifi.sh " have to work, compare "/etc/config/network" and "/etc/config/wireless" with Step 1 setting.
Step 3. compare "/tmp/setupwifi.sh" with "./setupwifi.sh "

It's not clear from the thread whether or not this resolved the issue, but I don't even understand the advise given. Can someone elaborate on this?

Thanks, Chris

I think you can do that in two ways:

  1. use "uci" command. uci is the command line tool for modifying openwrt configuration (don't forget to "uci commit" at the end, otherwise modifications won't be applied)
  2. prepare as many wifi config files as you need and just copy them to /etc/config/wireless when needed