Hi all, I want to flash OWrt on a single Ethernet port device so want to enable WiFI by default so thinking to use the firmware selector,
Now my query is should my script will be like
uci set wireless.radio0.disabled='0' uci set wireless.radio1.disabled='0' commit wireless key="12345678" ssid="OpenWrt"
or it shoule be like this which is already there in the run script gear icon on right corner
wlan_name="OpenWrt" wlan_password="12345678" if [ -n "$wlan_name" -a -n "$wlan_password" -a ${#wlan_password} -ge 8 ]; then uci set wireless.@radio[0].disabled='0' uci set wireless.@radio[0].disabled='0' uci set wireless.@radio[0].encryption='psk2' uci set wireless.@radio[0].ssid="$wlan_name" uci set wireless.@radio[0].key="$wlan_password" uci commit wireless fi echo "All done!"
Sorry @frollic I didn't get your answer as, as far as I know that all of them should work where the second and third method will active the wireless security also, but ok I'll try them all and post the result here, it's always fun to try new things
Yes, I also got that they are incorrect but at least they are enabling the wifi. But I'm wondering the second option which I listed above is directly from firmware selector code pasting location, you just click the small gear icon at bottom right corner and will get the ready code there, so is the code wrong there? Or am I doing something wrong, can you help me please as I'm very interested to learn and understand how openwrt works that's why asking this much questions
I'm also confusing where to use these radio0 or wifi-device[0] / wifi-iface[0] and where to use only wifi-device / wifi-iface, technically they are all same right? can you please elaborate me?
That code there is most likely the one you pasted, not something offered by firmware-selector. If you're interested in learning, you should start with the wiki.
They are not the same thing, no. There are wifi/radio devices and each device (in most cases) can have multiple interfaces. Devices is not the same as the interface. It's explained in more detail in the wiki.
So till now as far as I've found that the following piece of code works to enable the wifi out of the box
uci set wireless.@wifi-device[0].disabled="0"
uci set wireless.@wifi-iface[0].disabled="0"
uci set wireless.@wifi-iface[0].ssid="WIFI-NAME"
uci set wireless.@wifi-iface[0].key="WIFI_PASSWORD"
uci set wireless.@wifi-iface[0].encryption="psk2"
uci commit wireless
or we can do like following
ssid="WIFI_NAME"
key="WIFI_PASSWORD"
wifi_enable_device() {
local cfg="$1"
uci set wireless.$cfg.disabled='0'
}
wifi_setup_interface() {
local cfg="$1"
uci set wireless.$cfg.ssid="$ssid"
uci set wireless.$cfg.key="$key"
uci set wireless.$cfg.encryption="psk2"
}
config_load wireless
config_foreach wifi_enable_device wifi-device
config_foreach wifi_setup_interface wifi-iface
uci commit wireless
Now if someone have a multiple band device they can add wifi-iface and wifi-device and the wifi-iface and wifi-device associated number with them where each wifi-iface linked to each wifi-device
eg. for a dual band device the code will be like follows
uci set wireless.@wifi-device[0].disabled='0'
uci set wireless.@wifi-iface[0].encryption='psk2'
uci set wireless.@wifi-iface[0].ssid="WIFI_NAME"
uci set wireless.@wifi-iface[0].key="WIFI_PASSWORD"
uci set wireless.@wifi-device[1].disabled='0'
uci set wireless.@wifi-iface[1].encryption='psk2'
uci set wireless.@wifi-iface[1].ssid="WIFI_NAME"
uci set wireless.@wifi-iface[1].key="WIFI_PASSWORD"
uci commit wireless
and thats all what we need for an out of box wifi experience
will update this as soon as I found what I'm doing wrong with the third code and will post all 3 working