Last active
October 20, 2019 05:33
-
-
Save NghiaMaster/d7f2469a5d22b78785d7ad875d465f52 to your computer and use it in GitHub Desktop.
Check Wifi And AUTO Connect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/system/bin/sh | |
# source configuration | |
log=/data/local/wifi.log | |
check_interval=10 | |
# | |
exec 1> /dev/null | |
exec 2>> $log | |
echo $(date) > $log | |
# without check_interval set, we risk a 0 sleep = busy loop | |
if [ ! "$check_interval" ]; then | |
echo "No check interval set!" >> $log | |
exit 1 | |
fi | |
startWifi () { | |
wpa_cli -iwlan0 -p/data/misc/wifi/sockets/ reconnect | |
} | |
startWifi | |
while true; do | |
ONL=$(wpa_cli -iwlan0 -p/data/misc/wifi/sockets/ status | grep -c "ssid=VIETTEL - SLHNB"); | |
if [ "$ONL" = 0 ]; then | |
echo $(date) " Attempting reconnect..." >> $log | |
echo 1 >/sys/class/leds/button-backlight/brightness | |
startWifi | |
sleep 3 | |
else | |
echo 0 >/sys/class/leds/button-backlight/brightness | |
sleep $check_interval | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment