Support for button scripts in MT300A and AR300M

Could you please advise me what are my options for button scripts (both reset button and the slider) with both GL and vanilla editions of OpenWrt for MT300A and AR300M?

I need to write a script which will run when either reset and/or slider is toggled.

the reset script should always be /etc/rc.button/reset

The switch script should use different names according to the module. In our firmware, you will find these script already, which just echo some text to console.

MT300A : /etc/rc.button/BTN_1

AR300M: /etc/rc.button/BTN_1

AR150: /etc/rc.button/BTN_8

I’m trying to use this with the image built with your image builder on MT300N and /etc/rc.button/BTN_1 doesn’t seem to be triggered on slider switch.

Also, how can I poll the switch status on boot?

Figured out the button ID with the simple /etc/hotplug.d/ script – it’s BTN_0.

Still, how can I poll the button status when the router is starting?

Follow up question – how do I control on/off and the color of the /sys/devices/gpio-leds/leds/gl-mt300n:wan LED?

You cannot control the color. It is only one color LED.

To turn on/off, use the following

echo 1 > /sys/class/leds/gl-mt300n:wan/brightness

echo 0 > /sys/class/leds/gl-mt300n:wan/brightness

To check the button status when router start, check /etc/init.d/initswitch script in our firmware

Thank you for your prompt reply. I’ve tried echo 0/1, but I was looking at a wrong LED and thought they didn’t work – they of course do.

I’ve checked the file you referred to, but I can’t see anything relevant to MT300N there (with MT300N and firmware 2.22):

#!/bin/sh /etc/rc.common

 

START=19

 

start(){

 

model=$(awk ‘BEGIN{FS=“-”} /machine/ {print tolower($2)}’ /proc/cpuinfo)

switch_left=

switch_disabled=“0”

 

case “$model” in

“ar150”)

switch_left=$(grep -o “BTN_8.*hi” /sys/kernel/debug/gpio)

“ar300m”)

;;

“mt300a”)

;;

“mt300n”)

;;

 

“connect inet v1” | \

“ar300” | \

“mt750” )

switch_disabled=“1”

;;

esac

 

#if switch is on 0

if [ “$switch_disabled” = “1” ]; then

exit 0

fi

}

So how can I poll the slider position on MT300N?

ah, nevermind: $(grep -o “BTN_8.*hi” /sys/kernel/debug/gpio)

Hi - on my MT300A, when i slide the swtich, nothing is echoed to console.

i’m on the 2.23-7 firmware.

Can someone write a script to set the boot count to 3 and 0 respectively with the other switch position and a reboot after setting the boot count… I’m not much for scripting.