Sixfab_PPP_Installer/ppp_installer/reconnect_basehat

49 lines
1.1 KiB
Plaintext
Raw Normal View History

2020-11-17 10:08:25 +00:00
#!/bin/env bash
2019-10-11 20:06:29 +00:00
2020-11-18 13:52:12 +00:00
source functions.sh
source configs.sh
2020-11-17 10:08:25 +00:00
# Pinout for base hat
POWER_OFF=26
W_DISABLE=19
2019-10-11 20:06:29 +00:00
2020-11-17 10:08:25 +00:00
# Control pins
gpio -g mode $POWER_OFF out #HAT_POWER_OFF
gpio -g mode $W_DISABLE out #W_DISABLE
gpio -g write $POWER_OFF 0
gpio -g write $W_DISABLE 0
2020-11-18 13:52:12 +00:00
2020-11-17 10:08:25 +00:00
if check_network -eq 0; then
debug "PPP chatscript is starting...";
sudo pon;
else
debug "Network registeration is failed!";
fi
2019-10-11 20:06:29 +00:00
while true; do
2020-11-17 10:08:25 +00:00
# Checking cellular internet connection
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
PINGG=$?
2019-10-11 20:06:29 +00:00
2020-11-17 10:08:25 +00:00
if [[ $PINGG -eq 0 ]]; then
printf "."
else
printf "/"
sleep $DOUBLE_CHECK_WAIT
# Checking cellular internet connection
ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1
PINGG=$?
2019-10-11 20:06:29 +00:00
2020-11-17 10:08:25 +00:00
if [[ $PINGG -eq 0 ]]; then
printf "+"
else
debug "Connection is down, reconnecting..."
if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi
sudo pon
fi
fi
sleep $INTERVAL
2019-10-11 20:06:29 +00:00
done