diff --git a/ppp_installer/install.sh b/ppp_installer/install.sh old mode 100644 new mode 100755 index 5ba4f50..c83d52d --- a/ppp_installer/install.sh +++ b/ppp_installer/install.sh @@ -8,17 +8,19 @@ SET='\033[0m' echo "${YELLOW}Please choose your Sixfab Shield:${SET}" echo "${YELLOW}1: GSM/GPRS Shield${SET}" echo "${YELLOW}2: 3G, 4G/LTE Base Shield${SET}" -echo "${YELLOW}3: Cellular IoT Shield${SET}" +echo "${YELLOW}3: Cellular IoT App Shield${SET}" +echo "${YELLOW}4: Cellular IoT HAT${SET}" read answer case $answer in 1) echo "${YELLOW}You chose GSM/GPRS Shield${SET}";; 2) echo "${YELLOW}You chose Base Shield${SET}";; - 3) echo "${YELLOW}You chose Cellular Iot Shield${SET}";; - *) echo "${YELLOW}You did not chose 1, 2 or 3${SET}"; exit 1; + 3) echo "${YELLOW}You chose CellularIoT Shield${SET}";; + 4) echo "${YELLOW}You chose CellularIoT HAT${SET}";; + *) echo "${YELLOW}You did not chose 1, 2,3 or 4${SET}"; exit 1; esac -if [ $answer -eq 3 ]; then +if [ $answer -eq 3 || $answer -eq 4 ]; then echo "${YELLOW}Please choose LTE Technology:${SET}" echo "${YELLOW}1: GPRS/EDGE${SET}" echo "${YELLOW}2: CATM1${SET}" @@ -139,8 +141,11 @@ do elif [ $answer -eq 3 ]; then - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_cellulariot -O reconnect.sh + wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_cellulariot_app -O reconnect.sh + elif [ $answer -eq 4 ]; then + + wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_cellulariot -O reconnect.sh fi mv reconnect.sh /usr/src/ diff --git a/ppp_installer/reconnect_cellulariot b/ppp_installer/reconnect_cellulariot index 330fa0b..96737f4 100644 --- a/ppp_installer/reconnect_cellulariot +++ b/ppp_installer/reconnect_cellulariot @@ -1,22 +1,22 @@ #!/bin/sh -gpio -g mode 20 in -gpio -g mode 11 out -gpio -g mode 26 out +gpio -g mode 23 in #status +gpio -g mode 24 out #powerkey +gpio -g mode 17 out #enable -gpio -g write 26 0 +gpio -g write 17 1 sleep 1 -gpio -g write 26 1 +gpio -g write 17 0 while true; do - if [ $(gpio -g read 20) = "1" ]; then + if [ $(gpio -g read 23) = "0" ]; then echo "Power up" - gpio -g write 11 0 - gpio -g write 11 1 + gpio -g write 24 0 + gpio -g write 24 1 sleep 2 - gpio -g write 11 0 + gpio -g write 24 0 sleep 2 else ping -I ppp0 -c 1 8.8.8.8 diff --git a/ppp_installer/reconnect_cellulariot_app b/ppp_installer/reconnect_cellulariot_app new file mode 100644 index 0000000..330fa0b --- /dev/null +++ b/ppp_installer/reconnect_cellulariot_app @@ -0,0 +1,33 @@ +#!/bin/sh + +gpio -g mode 20 in +gpio -g mode 11 out +gpio -g mode 26 out + +gpio -g write 26 0 +sleep 1 +gpio -g write 26 1 + +while true; do + + if [ $(gpio -g read 20) = "1" ]; then + echo "Power up" + + gpio -g write 11 0 + gpio -g write 11 1 + sleep 2 + gpio -g write 11 0 + sleep 2 + else + ping -I ppp0 -c 1 8.8.8.8 + + if [ $? -eq 0 ]; then + echo "Connection up, reconnect not required..." + else + echo "Connection down, reconnecting..." + sudo pon + fi + fi + + sleep 1 +done