From 7758c58028bf2d7cdf7e0678e86972a5cf152fd8 Mon Sep 17 00:00:00 2001 From: saeedjohar Date: Wed, 9 Oct 2019 13:55:31 +0300 Subject: [PATCH] reconnect script added for Tracker HAT --- ppp_installer/reconnect_tracker | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ppp_installer/reconnect_tracker diff --git a/ppp_installer/reconnect_tracker b/ppp_installer/reconnect_tracker new file mode 100644 index 0000000..faee971 --- /dev/null +++ b/ppp_installer/reconnect_tracker @@ -0,0 +1,30 @@ +#!/bin/sh + +gpio -g mode 23 in #status +gpio -g mode 24 out #powerkey +gpio -g mode 17 out #disable +# enabling the power of the HAT +gpio -g write 17 1 +sleep 1 +gpio -g write 17 0 + +while true; do + + if [ $(gpio -g read 23) = "0" ]; then + echo "Power up" + + gpio -g write 24 1 + sleep 2 + gpio -g write 24 0 + sleep 2 + else + ping -q -I ppp0 -c 1 8.8.8.8 -s 0 >/dev/null + + if [ $? -ne 0 ]; then + echo "Connection down, reconnecting..." + sudo pon + fi + fi + + sleep 10 +done