alzhao, thanks for your code.

Tried your modifications on my ar750s 3.105 and it kind of works. When I reboot the device, the wifi is off by default regardless of the position of the switch. So if I leave it in the on position (right) and reboot, the gui will say wifi is on but it is not. To get wifi on, I have to move the switch to off (left) and then back to on (right). Now the gui is in sync with the actual state of the wifi.

Perhaps some sort of initiation code is needed.

Also, I was hoping your code would add wifi on/off as an additional option in the gui for configuring the function of the switch but it doesn’t. So does the wifi toggle replace the other switch options or works in parallel with them?

I did figure out that if I want both 2.4ghz and 5ghz wifi to be toggled, I need to make this change:

toggle_wifi(){
	local action=$1
	if [ "$action" = "OFF" ];then
		  uci set wireless.@wifi-iface[0].disabled=1
		  uci set wireless.@wifi-iface[1].disabled=1
	else
		uci set wireless.@wifi-iface[0].disabled=0
		uci set wireless.@wifi-iface[1].disabled=0
	fi
	uci commit wireless
	wifi
}