AR750s Slate No auto reconnect to android

Hi all, I have just received my AR750s and I absolutely love it.

I am currently tethering my android phone via easytether via the following documentation EasyTether - GL.iNet Docs but I have noticed that the auto-connect instructions don’t seem to auto-connect the phone on reboot, or when connection is lost. I have to physically unplug and plug my phone to the usb cable and it automatically connects. I am wondering if there is an alternate way to fix this issue? I am running the latest 3.104.

All ideas are very much appreciated!

Thanks!
Tiberius

For easytether I am not sure.

Maybe you can write a script to check internet periodically. When there is no Internet you can power cycle the USB port. The USB port is controlled by GPIO so it can be power off and on again.

Thanks for the idea Alzahao! I’ve been looking around for a way to implement, I saw that you had mentioned in another post to start/stop usb I would have to use the following:

ls /sys/class/leds/ usbpow
Then control the USB power using it
echo 0 > /sys/class/leds/…usbpow…/brightness
echo 1 > /sys/class/leds/…usbpow…/brightness

The below works, but for some reason it doesn’t work on reboot. I have to manually remove and reconnect the device although I’ve also added the @reboot sh checkInternet

if nc -zw1 google.com 443; then
  echo "we have connectivity"
else
  echo "resetting usb"
  echo 1 > /sys/class/leds/…usbpow…/brightness
  echo 0 > /sys/class/leds/…usbpow…/brightness
fi

thanks again,
T

I have some suggestions:

  1. You need to check connectivity multiple times, not one time, which may be wrong. Generally you can check 3 times and no connectivity and then label it a no
  2. During boot, there is no internet yet, so this script execute quickly and then end. What you need to do is: (a) add detection of the easytethering interface. Only when there is easytether interface you start, otherwise you wait. (b) add some delay to execute this script after boot.

Thanks Al, I have found a possible solution @ [OpenWrt Wiki] Smartphone USB tethering
Though, we don’t need to use hub-ctrl because of the usbpow. I am currently testing this, please see below if it helps anyone:

Creating a script that checks the connection and if it’s down, it resets the USB port and network

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

Fetch WAN gateway

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

Check WAN connectivity

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

Restart network and USB port

/etc/init.d/network stop
echo 1 > /sys/class/leds/gl-ar750s:white:usbpower/brightness
sleep 1
echo 0 > /sys/class/leds/gl-ar750s:white:usbpower/brightness
/etc/init.d/network start
EOF
chmod +x /root/wan-watchdog.sh

Add cron job to check every minute

cat << “EOF” >> /etc/crontabs/root

          • /root/wan-watchdog.sh
            EOF
1 Like

How did the test go? Is this a solution to having to unplug/plug to enable it to reconnect? I use the Automate app to automatically turn on USB tether when connecting the cable, but am having the same issue with having to manually unplug/plug after a power failure and the router restarts.

Yeah the bash script should work well! I haven’t had any issues

1 Like

Scripted updated: 2022-03-14

I reformat, can you pls check if this is correct.

First create the script, called /root/wan-watchdog.sh

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_power/value
sleep 1
echo 1 > /sys/class/gpio/usb_power/value

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

then, add it to scheduled task (cron) and execute this every minute. You can change the number to 2 (every two minutes) etc.

cat << "EOF" >> /etc/crontabs/root

*/1 * * * * /root/wan-watchdog.sh
EOF

Sorry I didn’t test this.

I will test on AR750S and report back

I also have E750, and MT300V2

  • I wish to accomplish the same on the two devices
  • I don’t see any devices under /sys/class/leds/
  • Any help on the “Restart network and USB port” part?

Additional question:

  • Is there an easy way to add “easytether-usb” to crontab on reboot? I have to execute the command every time the router restarts

You can just add. For example, you can use “;” to add multiple command

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

I tried this script and got this output:

root@GL-AR750S:~# ./wan-watchdog.sh
sh: “0”: out of range
./wan-watchdog.sh: line 17: can't create /sys/class/leds/gl-ar750s:white:usbpower/brightness: nonexistent directory
./wan-watchdog.sh: line 19: can't create /sys/class/leds/gl-ar750s:white:usbpower/brightness: nonexistent directory
root@GL-AR750S:~#

Any ideas @alzhao ?

I modified the script. Pls try again.

I believe that worked, thanks @alzhao !!

I had the same problem with my Slate router (no EasyTether reconnect on router reboot) and found this thread. I wanted to reply to confirm that the script and cron task from @alzhao work perfectly for me. Thanks for the great support!

1 Like

@alzhao, is the Beryl MT1300 the same way? I’m looking to accomplish this on my Beryl but not having any luck with the exact GPIO #s… any suggestions?

MT1300, for some reason, does not have any USB power control. So cannot use this script.