FEATURE REQ: WiFi on/off with side switch?

First you need to know how to use winscp to edit files on the router.

Then check these files.

/etc/rc.button/BTN_8
This is the file of AR150 switch button. Do not change it. Its contents should be like this:

#!/bin/sh

#This is the switch of AR150, left pressed, release right
# echo "$BUTTON ${ACTION}" > /dev/console
# /etc/init.d/initswitch restart

[ $SEEN -gt 0 ] || exit 0

echo "$BUTTON ${ACTION}" > /dev/console
/usr/bin/switchaction &

/usr/bin/switchaction
This is the script actually run when you toggle the switch. Just read and try to understand this script.

Pls modify as below.
Line 12, pls add

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

	else
		uci set wireless.@wifi-iface[0].disabled=0
	fi
	uci commit wireless
	wifi
}

image

Line 141 pls add

"wifi")
				toggle_wifi ON
			;;

image

Line 165 pls add

            "wifi")
				toggle_wifi OFF
			;;

image

/etc/config/glconfig
Edit this file

config service 'switch_button'
	option enable '1'
	option function 'wifi'

image

After you modify the 3 files as above, the switch button already works to turn on off wifi.
Left: wifi on
Right: wifi off

Can I get the reward from God?

4 Likes