GL-MT1300 LED control instructions

ok clear, but can I make this happen in a script?

If I look at usr/bin/mt1300_led I see options to change brigtness for example.

If I do
etc/init.d/led stop
The led stops, and goes on again in a second, so somewhere there is a script (maybe in hotplug.d) that checks the status of the router and sets the led accordingly.

So there must be a script that I can change to add the status of the vpn.

Something with the fact that tun0 is up when on VPN.

So if I can ping through tun0 the led breath and If I canā€™t ping tun0 itā€™s goes back to default.

I think the following script makes the led do what it default does.

/usr/bin/mt1300_led_deamon

#!/bin/sh

status="0"
count=`uci get mwan3.wan.count 2>/dev/null`
timeout=`uci get mwan3.wan.timeout 2>/dev/null`
track_ip=`uci get mwan3.wan.track_ip 2>/dev/null`
[ -z "$count" ] && count="1"
[ -z "$timeout" ] && timeout="2"
[ -z "$track_ip" ] && track_ip="1.1.1.1 1.0.0.1"

mt1300_led off
mt1300_led blue_breath daemon

for ip in $track_ip;
do
	ping -c $count -W $timeout -q $ip 1>/dev/null
	ret=`echo $?`
	if [ "$ret" = "0" ];then
		status="1"
		break
	fi
done

while true
do
	if [ "$status" = "0" ];then
		mt1300_led blue_breath daemon
	else
		mt1300_led white daemon
	fi

	sleep 5

	#mwan3 will not be used in the AP/WDS mode
	mode=`uci -q get glconfig.bridge.mode`
	if [ "$mode" = "ap" -o "$mode" = "wds" ];then
		[ "$status" = 1 ] && sleep 10
		for ip in $track_ip;
		do
			ping -c $count -W $timeout -q $ip 1>/dev/null
			ret=`echo $?`
			if [ "$ret" = "0" ];then
				status="1"
				break
			else
				status="0"
			fi
		done
		continue
	fi
	

	if [ "$status" = "0" ];then
		interface=`get_wan_interface`
		if [ -z "$interface" ];then
			continue
		fi

		for ip in $track_ip;
		do
			ping -c $count -W $timeout -q $ip 1>/dev/null
			ret=`echo $?`
			if [ "$ret" = "0" ];then
				status="1"
				break
			fi
		done
	else
		interface=`get_wan_interface`
		if [ -z "$interface" ];then
			status="0"
			continue
		fi
		
		mwan3_status=`mwan3 policies | grep "Current ipv4 policies:" -A 2 | tail -n 1 | sed 's/ //g' 2>/dev/null`
		if [ "$mwan3_status" = "default" ];then
			for ip in $track_ip;
			do
				ping -c $count -W $timeout -q $ip 1>/dev/null
				ret=`echo $?`
				if [ "$ret" = "0" ];then
					status="1"
					break
				else
					status="0"
				fi
			done
			continue
		fi

		mwan3_interface=`echo $mwan3_status | awk -F \( '{print $1}' 2>/dev/null`
		check=`echo $interface | grep $mwan3_interface 2>/dev/null`
		if [ -z "$check" ];then
			for ip in $track_ip;
			do
				ping -c $count -W $timeout -q $ip 1>/dev/null
				ret=`echo $?`
				if [ "$ret" = "0" ];then
					status="1"
					break
				else
					status="0"
				fi
			done
		fi	
	fi
done

So there must be something I can add, that when tun0 is up, is does like white_breath.

For anyone who is interested in a solution for breathing led on vpn and a solid one when on normal wan. Just made a clean but dirty solution that works for me.

Please be aware that I probably broke a lot of things Iā€™m apparantly not using, but it works for me.
For the ones that are feeling comfortable deeper into the system, It will not break mwan3, as I altered this for my needs and I use it extensively.

I deleted the content of the file /usr/bin/mt1300_led_deamon (or you rename the original for backup)

past the content below to the file and save it as /usr/bin/mt1300_led_deamon

#!/bin/sh
ip="1.1.1.1"   # use any dns you want
count="1"
timeout="1"
mt1300_led off
mt1300_led blue_breath daemon

while true; do

status=$(ping -q -c "$count" -W "$timeout" "$ip"  > /dev/null 2>&1 && echo "ok" || echo "fail")

if [ "$status" = "ok" ]; then
	if [ -d /sys/class/net/tun* ]; then    
		mt1300_led white_breath daemon   
	else    
		mt1300_led white daemon      
	fi
else
	mt1300_led blue_breath daemon
fi

sleep 10

done

Then restart the daemon with;

/etc/init.d/led restart

You can use any dns you want offcourse, default used by most is the dns from google 8.8.8.8, but I donā€™t us any Google or Facebook application or services. So I ban them from all my systems.

"FYI there are a lot of 8.8.8.8 and 8.8.4.4 in the firmware from Gl.Inet. This should be a choise not hardcoded. Just my 50 cents."

For I forget, make the file executable if you upload a new file instead of editing the original one.

chmod u+x filename

Note that if anyone is looking at this and uses wireguard instead, youā€™ll need to check for the existence of /sys/class/net/wg* instead.

Also, the script has been renamed to gl_mt1300_led_daemon and it seem the status checks may have changed as well. Iā€™m not sure why, but I cannot ping 1.1.1.1 while using cloudflare. Not feel motivated enough to dig deeper.

@ray308 is right that itā€™s weird all these ips and such are hard-coded. More I dive into these the scripts, the iffier the software side of this router isā€¦

Hello,

Thanks for the contribution.
I am also looking for such a setting for the LED.
It would be nice if you could control everything via Luci:

LEDs on / off
LEDs dimming +/- = light / dark
LEDs Collor
LEDs status

I am very excited about the Barly & OpenWTR, warry Nice Happy, good.

Sincerely
Sven H.

Is there any update on this?

You can also redo it so that the wifi status shows.
More or less like this:

#!/bin/sh
 
. /usr/share/libubox/jshn.sh

check_radio() {
  json_load "$(ubus call network.wireless status)"
  json_select $1
  json_select "interfaces"
  
  local idx=1
  while json_get_type type "$idx" && [ "$type" = object ] ; do
    json_select "$(( idx++ ))"
    json_get_var section "section"
  done
  json_select ".."
  json_cleanup
  json_is_a ${section} string
}

mt1300_led off
mt1300_led blue_breath daemon

while true; do
status="0"
check_radio mt7615e2 && status="0" || status="1"
if [ "$status" == "0" ]; then
 check_radio mt7615e5 && status="0" || status="2"
elif [ "$status" == "1" ]; then
 check_radio mt7615e5 && status="1" || status="3"
else
 status="0"
fi

......
......
done

This is what I did, and it worked, and it did what I wanted. When first turning on, it will be blue, but after it boots, the white LED is off. Thanks @techhome !

Any clue on when this will show up in the app? While the app is handy for network settings, removing the complexity of dimming or controlling the blazing bright light would really help.

Here is how the app works to control the LED.

I would love to say ā€œThanks that worksā€, but when I tap on the system overview bar, it depresses like a button, but does nothing more. Iā€™ve tried tapping 1, then 2, holding the two at the same time, holding system overview, and even swiping it sideways, but neither my Android cell or tablet can access the System overview section you show. The rest of the app seems to work. Ideas?

It needs to be 4.x firmware. Can you clarify your firmware version?

According to the status page in LuCI, Kernel Version is 4.14.241 and OpenWrt 19.07.8 r11364-ef56c85848. The Admin Panelā€™s upgrade section shows 3.215 as the installed version.

You should upgrade to 4.2

OK, the LED controls worked! Thanks!

I had used this trick to dim the LEDs, but with the upgrade, /usr/bin/mt1300_led is no longer there. Is it possible to dim the LEDs another way? I didnā€™t see a way within the app, control panel, or LuCI. Is there another file?

The two commands should still work, right?

Like I said, /usr/bin/mt1300_led isnā€™t present after the upgrade. Where would I edit/add those commands?

/usr/bin/gl_i2c_led

Iā€™ll have to give up - The openwrt-mt1300-4.2.0-0210-1675977894 and todayā€™s 0212 daily snapshot firmware just wasnā€™t stable. It would work at first, but at times it would not properly boot at power up, wouldnā€™t reset holding the button for 10 seconds, and required reloading firmware, Iā€™ll just wait for the stable release. Thanks!