GL-MT1300 LED control instructions

You can turn the light off by pressing on the button very briefly

1 Like

Hi, i bought this router to replace the GL-MT300N-V2, but the old one support the led costumization for example to turn on the middle ligh only if vpn is connected.

Its possible have the same thing on this one? For example only show white light if vpn is connected?

I already configurated the internet kill switch, but when the vpn drop the ligh not change to blue (no internet light)

Thank you for your attention

Now, with VPN it is breathing white. Withut vpn it is solid white.

Of course you can configure as you want but it is more complicated. You should find your script and then control the LED as in this instructions.

Hi thank you for your attention.

I already tested and the light doesnt change…
With VPN → solid white
Without VPN → solid white

There is some update/configuration that needs to be done for breathing white when VPN is on?

How did you set up vpn? openvpn or wireguard/

Yes i am connected to VPN using Openvpn protocol

I am trying to follow this article to create the script vpn_check.sh
https://forum.gl-inet.com/t/ar750-diy-vpn-status-indicator/9356/5[check_vpn.zip|attachment](upload://czHI13Rc7OJ4RTStLCPrqUdkFN2.zip) (734 Bytes)

I tried with a Wireguard client, and it seems like the LED stays solid white.

Seems that light does not changes when vpn is connected… @alzhao can you help?

I just verified. I submit a bug.

1 Like

Any follow up on this bug?

Maybe I misunderstand. The definition of the LED, does not show VPN status. Sorry for confusing.

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.