Closed web83info closed 10 months ago
参考:[[Feature Request] Side Button to Toggle WiFi On/Off on Dual Radio Devices] https://forum.gl-inet.com/t/feature-request-side-button-to-toggle-wifi-on-off-on-dual-radio-devices/32427/3
#!/bin/sh
# 2023-07-25
# /etc/gl-switch.d/
# uci show wireless
# source: https://forum.gl-inet.com/t/feature-req-wifi-on-off-with-side-switch/2896/41
action=$1
if [ "$action" = "on" ]; then
uci set wireless.default_radio0.disabled='0'
uci set wireless.default_radio1.disabled='0'
uci commit wireless
wifi reload
logger -p notice -t wifi-toggle "radios enabled"
fi
if [ "$action" = "off" ]; then
uci set wireless.default_radio0.disabled='1'
uci set wireless.default_radio1.disabled='1'
uci commit wireless
wifi reload
logger -p notice -t wifi-toggle "radios disabled"
fi
現在のスイッチ位置を取得するには、GPIOから読み取る。
参考:GL-AR750s mode switch button configuration https://forum.openwrt.org/t/gl-ar750s-mode-switch-button-configuration/50024/4
# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/18040000.gpio, 18040000.gpio:
gpio-1 ( |gl-ar750s:green:powe) out lo
gpio-2 ( |reset ) in hi IRQ
gpio-7 ( |usb-vbus ) out hi
gpio-8 ( |mode ) in lo IRQ
gpio-19 ( |gl-ar750s:green:wlan) out hi
gpio-20 ( |gl-ar750s:green:wlan) out lo
if grep -E '^ gpio-8 .*) in hi' /sys/kernel/debug/gpio ; then
echo "Switch is on"
else
echo "Switch is off"
fi
edfbd3889656738037c2065fe724e9a9cbafcb3e で対応
例:Wifiのオンオフの切り替えなど。