Reconnect internet connection on GL-MT300N-V2

Hi,

I was wondering if I could get some help with my GL-MT300N-V2 mini router. I use easy tether with a pixel 3a, and I’ve been searching on how to reset usb/network via script.

My issue is that when I connect my pixel 3a to the mini router it will work for a while then the internet will disconnect and webpages/videos wont load anymore after some time. The wifi connection is still there but no active internet connection. I have to reconnect the usb cable back from the phone to work again or log into the webgui and restart the tap-easytether WAN. I came across a couple guides on how to set it up but not sure if mine is working correctly because I get an error.

I’m using the following script I found from this post but modified it for the GL-MT300N-V2, but it doesn’t seem to be working because I get this error about the interface being used at hotplug. Any help would be appreciated.

cat << “EOF” > /root/wan-watchdog.sh
#!/bin/sh

. /lib/functions/network.sh
network_flush_cache
network_find_wan NET_IF
network_get_gateway NET_GW “${NET_IF}”

TRIES=“0”
while [ “${TRIES}” -lt 5 ]
do
if ping -w 3 “${NET_GW}” &> /dev/null
then exit 0
else let TRIES++
fi
done

echo 0 > /sys/class/gpio/usb/value
sleep 1
echo 1 > /sys/class/gpio/usb/value

EOF
chmod +x /root/wan-watchdog.sh

My cron looks like this

*/1 * * * * /root/wan-watchdog.sh; easytether-usb

Error:

Hi! I read on the internet and found two very old solutions (2012 on the XDA forum) 1.Modem can stop when the device goes to sleep (turn off the display) - solution: in Options turn on “Always on Display on charge” . 2.Enabled adb settings breaks the connection - solution: disable adb (possible in Developer options / Enabled USB debugging mode). If possible, check it.

Thanks for replying. I actually already have my display to always on/never sleep and the usb debug, i think, needs to be on for easytether to work.

What is the state of usb after echo 0 and wait 5-30seconds?
root@GL-MT300N-V2:~# cat /sys/class/gpio/usb/value

I tested on my router with external usb card:
root@GL-MT300N-V2:~# logread -f

echo 0 > /sys/class/gpio/usb/value

Sun Nov 7 19:54:51 2021 daemon.notice netifd: Network device ‘eth1’ link is down
Sun Nov 7 19:54:51 2021 daemon.notice netifd: Interface ‘tethering’ has link connectivity loss
Sun Nov 7 19:54:51 2021 daemon.notice netifd: tethering (7811): udhcpc: SIOCGIFINDEX: No such device
Sun Nov 7 19:54:51 2021 daemon.notice netifd: tethering (7811): udhcpc: received SIGTERM
Sun Nov 7 19:54:51 2021 daemon.notice netifd: Interface ‘tethering’ is now down
Sun Nov 7 19:54:52 2021 daemon.notice netifd: Interface ‘tethering’ is disabled
Sun Nov 7 19:54:52 2021 daemon.warn dnsmasq[2161]: no servers found in /tmp/resolv.conf.auto, will retry

root@GL-MT300N-V2:~# cat /sys/class/gpio/usb/value
0

root@GL-MT300N-V2:~# echo 1 > /sys/class/gpio/usb/value

Sun Nov 7 19:55:22 2021 daemon.notice netifd: Interface ‘tethering’ is enabled
Sun Nov 7 19:55:25 2021 daemon.notice netifd: Network device ‘eth1’ link is up
Sun Nov 7 19:55:25 2021 daemon.notice netifd: Interface ‘tethering’ has link connectivity
Sun Nov 7 19:55:25 2021 daemon.notice netifd: Interface ‘tethering’ is setting up now
Sun Nov 7 19:55:26 2021 daemon.notice netifd: tethering (10586): udhcpc: started, v1.30.1
Sun Nov 7 19:55:26 2021 daemon.notice netifd: tethering (10586): udhcpc: sending discover
Sun Nov 7 19:55:26 2021 daemon.notice netifd: tethering (10586): udhcpc: sending select for 192.168.1.48
Sun Nov 7 19:55:26 2021 daemon.notice netifd: tethering (10586): udhcpc: lease of 192.168.1.48 obtained, lease time 25200
Sun Nov 7 19:55:26 2021 daemon.notice netifd: Interface ‘tethering’ is now up
Sun Nov 7 19:55:26 2021 daemon.info dnsmasq[2161]: reading /tmp/resolv.conf.auto
Sun Nov 7 19:55:26 2021 daemon.info dnsmasq[2161]: using local addresses only for domain test
Sun Nov 7 19:55:26 2021 daemon.info dnsmasq[2161]: using local addresses only for domain onion
Sun Nov 7 19:55:26 2021 daemon.info dnsmasq[2161]: using local addresses only for domain localhost
Sun Nov 7 19:55:26 2021 daemon.info dnsmasq[2161]: using local addresses only for domain local
Sun Nov 7 19:55:26 2021 daemon.info dnsmasq[2161]: using local addresses only for domain invalid
Sun Nov 7 19:55:26 2021 daemon.info dnsmasq[2161]: using local addresses only for domain bind
Sun Nov 7 19:55:26 2021 daemon.info dnsmasq[2161]: using local addresses only for domain lan
Sun Nov 7 19:55:26 2021 daemon.info dnsmasq[2161]: using nameserver 8.8.4.4#53
Sun Nov 7 19:55:30 2021 user.info mwan3rtmon[2100]: Detect rtchange event.
Sun Nov 7 19:55:31 2021 user.notice firewall: Reloading firewall due to ifup of tethering (eth1)

Hi, I got some basic knowledge of command lines, but not a whole lot. What would i type in putty to check the usb state? When i copied the cat line you posted i got a value of 1.

It’s from [OpenWrt Wiki] Turning USB power on and off
In my testcase:
root@GL-MT300N-V2:~# cat /sys/class/gpio/usb/value
0

I still need to think

I tested this:
root@GL-MT300N-V2:~# ls /sys/bus/usb/devices/
1-0:1.0 1-1 1-1:1.0 usb1 usb2

After that, the tethering stopped.
root@GL-MT300N-V2:~# echo usb1 > /sys/bus/usb/drivers/usb/unbind
usb1

And after that the LED goes off on my external Ethernet adapter:
root@GL-MT300N-V2:~# echo 0 > /sys/class/gpio/usb/value

Now:
root@GL-MT300N-V2:~# cat /sys/class/gpio/usb/value
0

Revert to back:
echo 1 > /sys/class/gpio/usb/value
echo usb1 > /sys/bus/usb/drivers/usb/bind

(I read this: debian - Turning off a single usb device... again - Stack Overflow )

So would I change my values to reflect

Also, the error I get about the easy USB being used by another process. Is that normal?

Maybe, this will help?
root@GL-MT300N-V2:~# /etc/init.d/usbmuxd stop
/etc/init.d/usbmuxd start

Thanks. I’ll try this then and see if it will work. Also, Is there any way for me to force a disconnect to see if this cron will take effect?

cat << “EOF” > /root/wan-watchdog.sh
#!/bin/sh

. /lib/functions/network.sh
network_flush_cache
network_find_wan NET_IF
network_get_gateway NET_GW “${NET_IF}”

TRIES=“0”
while [ “${TRIES}” -lt 5 ]
do
if ping -w 3 “${NET_GW}” &> /dev/null
then exit 0
else let TRIES++
fi
done

echo 0 > /etc/init.d/usbmuxd stop
sleep 1
echo 1 > /etc/init.d/usbmuxd start

EOF
chmod +x /root/wan-watchdog.sh

This is not right. Seems you messed up the command. See the below.

So it should be as follows?