From 72d1e615d87cfbb50b4485754aac9496342eb3c6 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Tue, 17 Nov 2020 02:08:25 -0800 Subject: [PATCH 01/49] reconnect.sh files revision --- ppp_installer/reconnect_basehat | 96 ++++++++++++--- ppp_installer/reconnect_baseshield | 80 +++++++++++-- ppp_installer/reconnect_cellulariot | 146 +++++++++++++++++++---- ppp_installer/reconnect_cellulariot_app | 147 +++++++++++++++++++---- ppp_installer/reconnect_gprsshield | 133 +++++++++++++++++---- ppp_installer/reconnect_test.sh | 77 ++++++++++++ ppp_installer/reconnect_tracker | 149 ++++++++++++++++++++---- 7 files changed, 714 insertions(+), 114 deletions(-) create mode 100644 ppp_installer/reconnect_test.sh diff --git a/ppp_installer/reconnect_basehat b/ppp_installer/reconnect_basehat index e870673..fd76725 100644 --- a/ppp_installer/reconnect_basehat +++ b/ppp_installer/reconnect_basehat @@ -1,21 +1,89 @@ -#!/bin/sh -# /usr/src/reconnect -# for Base HAT +#!/bin/env bash -gpio -g mode 26 out #HAT_POWER_OFF -gpio -g mode 19 out #W_DISABLE +# Pinout for base hat +POWER_OFF=26 +W_DISABLE=19 -gpio -g write 26 0 -gpio -g write 19 0 +# General variables +INTERVAL=60 +DOUBLE_CHECK_WAIT=10 +PING_TIMEOUT=9 + +function debug() +{ + echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" +} + +function check_network() +{ + # Check the network is ready + debug "Checking the network is ready..." + + for i in {1..600}; do + NETWORK_OK=0 + + debug "SIM Status:" + atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" + SIM_READY=$? + + debug "Network Registeration Status:" + # For super SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" + NETWORK_REG=$? + # For native SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" + NETWORK_REG_2=$? + # Combined network registeration status + NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) + + if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then + debug "Network is ready." + NETWORK_OK=1 + return 0 + break + else + printf "?" + fi + sleep 2 + done + return 1 +} + +# 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 + +if check_network -eq 0; then + debug "PPP chatscript is starting..."; + sudo pon; +else + debug "Network registeration is failed!"; +fi while true; do + # Checking cellular internet connection + ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1 + PINGG=$? - ping -q -I ppp0 -c 1 8.8.8.8 -s 0 >/dev/null + 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=$? - if [ $? -ne 0 ]; then - echo "Connection down, reconnecting..." - sudo pon - fi - - sleep 10 + 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 done diff --git a/ppp_installer/reconnect_baseshield b/ppp_installer/reconnect_baseshield index 0688998..b35d7b1 100644 --- a/ppp_installer/reconnect_baseshield +++ b/ppp_installer/reconnect_baseshield @@ -1,13 +1,77 @@ -#!/bin/sh +#!/bin/env bash + +INTERVAL=60 +DOUBLE_CHECK_WAIT=10 +PING_TIMEOUT=9 + +function debug() +{ + echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" +} + +function check_network() +{ + # Check the network is ready + debug "Checking the network is ready..." + + for i in {1..600}; do + NETWORK_OK=0 + + debug "SIM Status:" + atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" + SIM_READY=$? + + debug "Network Registeration Status:" + # For super SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" + NETWORK_REG=$? + # For native SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" + NETWORK_REG_2=$? + # Combined network registeration status + NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) + + if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then + debug "Network is ready." + NETWORK_OK=1 + return 0 + break + else + printf "?" + fi + sleep 2 + done + return 1 +} + +if check_network -eq 0; then + debug "PPP chatscript is starting..."; + sudo pon; +else + debug "Network registeration is failed!"; +fi while true; do + # Checking cellular internet connection + ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1 + PINGG=$? - ping -q -I ppp0 -c 1 8.8.8.8 -s 0 >/dev/null + 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=$? - if [ $? -ne 0 ]; then - echo "Connection down, reconnecting..." - sudo pon - fi - - sleep 10 + 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 done diff --git a/ppp_installer/reconnect_cellulariot b/ppp_installer/reconnect_cellulariot index 35cf79c..53066af 100644 --- a/ppp_installer/reconnect_cellulariot +++ b/ppp_installer/reconnect_cellulariot @@ -1,31 +1,129 @@ -#!/bin/sh +#!/bin/env bash -gpio -g mode 23 in #status -gpio -g mode 24 out #powerkey -gpio -g mode 17 out #enable +# Pinout for cellulariot hat +STATUS=23 +POWERKEY=24 +ENABLE=17 -gpio -g write 17 1 -sleep 1 -gpio -g write 17 0 +# General variables +INTERVAL=60 +DOUBLE_CHECK_WAIT=10 +PING_TIMEOUT=9 + +# Configure pins +gpio -g mode $STATUS in +gpio -g mode $POWERKEY out +gpio -g mode $ENABLE out + +function debug() +{ + echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" +} + +function check_network() +{ + # Check the network is ready + debug "Checking the network is ready..." + + for i in {1..600}; do + NETWORK_OK=0 + + debug "SIM Status:" + atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" + SIM_READY=$? + + debug "Network Registeration Status:" + # For super SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" + NETWORK_REG=$? + # For native SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" + NETWORK_REG_2=$? + # Combined network registeration status + NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) + + if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then + debug "Network is ready." + NETWORK_OK=1 + return 0 + break + else + printf "?" + fi + sleep 2 + done + return 1 +} + +function power_up_module() +{ + for i in {1..20}; do + if [[ $(gpio -g read $STATUS) -eq 1 ]]; then + debug "Module is powering up..." + + gpio -g write $POWERKEY 1 + sleep 2 + gpio -g write $POWERKEY 0 + sleep 2 + + if [[ $(gpio -g read $STATUS) -eq 0 ]]; then + debug "Module is powered up." + return 0 + break + else + debug "Module couldn't be powered up!" + sleep 2 + else + debug "Module is just powered up." + return 0 + break + fi + done + return 1 +} + +function restart_power() +{ + debug "Power of the module is restarting..." + # Restart power + gpio -g write $ENABLE 1 # power is disabled + sleep 2 + gpio -g write $ENABLE 0 # power is enabled +} + +restart_power # Restart power + +# Modem power up +if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi + +if check_network -eq 0; then + debug "PPP chatscript is starting..."; + sudo pon; +else + debug "Network registeration is failed!"; +fi while true; do + # Checking cellular internet connection + ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1 + PINGG=$? - if [ $(gpio -g read 23) = "1" ]; then - echo "Power up" + 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=$? - #gpio -g write 24 0 - 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 + 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 done diff --git a/ppp_installer/reconnect_cellulariot_app b/ppp_installer/reconnect_cellulariot_app index 5633ecc..945e2fa 100644 --- a/ppp_installer/reconnect_cellulariot_app +++ b/ppp_installer/reconnect_cellulariot_app @@ -1,31 +1,130 @@ -#!/bin/sh +#!/bin/env bash -gpio -g mode 20 in -gpio -g mode 11 out -gpio -g mode 26 out +# Pinout for cellulariot app shield +STATUS=20 +POWERKEY=11 +DISABLE=26 -gpio -g write 26 0 -sleep 1 -gpio -g write 26 1 +# General variables +INTERVAL=60 +DOUBLE_CHECK_WAIT=10 +PING_TIMEOUT=9 + +# Configure pins +gpio -g mode $STATUS in +gpio -g mode $POWERKEY out +gpio -g mode $DISABLE out + +function debug() +{ + echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" +} + +function check_network() +{ + # Check the network is ready + debug "Checking the network is ready..." + + for i in {1..600}; do + NETWORK_OK=0 + + debug "SIM Status:" + atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" + SIM_READY=$? + + debug "Network Registeration Status:" + # For super SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" + NETWORK_REG=$? + # For native SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" + NETWORK_REG_2=$? + # Combined network registeration status + NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) + + if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then + debug "Network is ready." + NETWORK_OK=1 + return 0 + break + else + printf "?" + fi + sleep 2 + done + return 1 +} + +function power_up_module() +{ + for i in {1..20}; do + if [[ $(gpio -g read $STATUS) -eq 1 ]]; then + debug "Module is powering up..." + + gpio -g write $POWERKEY 0 + gpio -g write $POWERKEY 1 + sleep 2 + gpio -g write $POWERKEY 0 + sleep 2 + + if [[ $(gpio -g read $STATUS) -eq 0 ]]; then + debug "Module is powered up." + return 0 + break + else + debug "Module couldn't be powered up!" + sleep 2 + else + debug "Module is just powered up." + return 0 + break + fi + done + return 1 +} + +function restart_power() +{ + debug "Power of the module is restarting..." + # Restart power + gpio -g write $DISABLE 0 # power is disabled + sleep 2 + gpio -g write $DISABLE 1 # power is enabled +} + +restart_power # Restart power + +# Modem power up +if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi + +if check_network -eq 0; then + debug "PPP chatscript is starting..."; + sudo pon; +else + debug "Network registeration is failed!"; +fi while true; do + # Checking cellular internet connection + ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1 + PINGG=$? - if [ $(gpio -g read 20) = "1" ]; then - echo "Power up" + 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=$? - gpio -g write 11 0 - gpio -g write 11 1 - sleep 2 - gpio -g write 11 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 + 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 done diff --git a/ppp_installer/reconnect_gprsshield b/ppp_installer/reconnect_gprsshield index d68f971..644e59b 100644 --- a/ppp_installer/reconnect_gprsshield +++ b/ppp_installer/reconnect_gprsshield @@ -1,26 +1,119 @@ -#!/bin/sh +#!/bin/env bash -gpio -g mode 19 in -gpio -g mode 26 out +# Pinout for cellulariot hat +STATUS=19 +POWERKEY=26 + +# General variables +INTERVAL=60 +DOUBLE_CHECK_WAIT=10 +PING_TIMEOUT=9 + +# Configure pins +gpio -g mode $STATUS in +gpio -g mode $POWERKEY out +gpio -g mode $ENABLE out + +function debug() +{ + echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" +} + +function check_network() +{ + # Check the network is ready + debug "Checking the network is ready..." + + for i in {1..600}; do + NETWORK_OK=0 + + debug "SIM Status:" + atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" + SIM_READY=$? + + debug "Network Registeration Status:" + # For super SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" + NETWORK_REG=$? + # For native SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" + NETWORK_REG_2=$? + # Combined network registeration status + NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) + + if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then + debug "Network is ready." + NETWORK_OK=1 + return 0 + break + else + printf "?" + fi + sleep 2 + done + return 1 +} + +function power_up_module() +{ + for i in {1..20}; do + if [[ $(gpio -g read $STATUS) -eq 1 ]]; then + debug "Module is powering up..." + + gpio -g write $POWERKEY 0 + gpio -g write $POWERKEY 1 + sleep 2 + gpio -g write $POWERKEY 0 + sleep 2 + + if [[ $(gpio -g read $STATUS) -eq 0 ]]; then + debug "Module is powered up." + return 0 + break + else + debug "Module couldn't be powered up!" + sleep 2 + else + debug "Module is just powered up." + return 0 + break + fi + done + return 1 +} + + +# Modem power up +if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi + +if check_network -eq 0; then + debug "PPP chatscript is starting..."; + sudo pon; +else + debug "Network registeration is failed!"; +fi while true; do + # Checking cellular internet connection + ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1 + PINGG=$? - if [ $(gpio -g read 19) = "0" ]; then - echo "Power up" + 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=$? - gpio -g write 26 0 - gpio -g write 26 1 - sleep 2 - gpio -g write 26 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 + 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 done diff --git a/ppp_installer/reconnect_test.sh b/ppp_installer/reconnect_test.sh new file mode 100644 index 0000000..b35d7b1 --- /dev/null +++ b/ppp_installer/reconnect_test.sh @@ -0,0 +1,77 @@ +#!/bin/env bash + +INTERVAL=60 +DOUBLE_CHECK_WAIT=10 +PING_TIMEOUT=9 + +function debug() +{ + echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" +} + +function check_network() +{ + # Check the network is ready + debug "Checking the network is ready..." + + for i in {1..600}; do + NETWORK_OK=0 + + debug "SIM Status:" + atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" + SIM_READY=$? + + debug "Network Registeration Status:" + # For super SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" + NETWORK_REG=$? + # For native SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" + NETWORK_REG_2=$? + # Combined network registeration status + NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) + + if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then + debug "Network is ready." + NETWORK_OK=1 + return 0 + break + else + printf "?" + fi + sleep 2 + done + return 1 +} + +if check_network -eq 0; then + debug "PPP chatscript is starting..."; + sudo pon; +else + debug "Network registeration is failed!"; +fi + +while true; do + # Checking cellular internet connection + ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1 + PINGG=$? + + 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=$? + + 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 +done diff --git a/ppp_installer/reconnect_tracker b/ppp_installer/reconnect_tracker index faee971..05e5f3d 100644 --- a/ppp_installer/reconnect_tracker +++ b/ppp_installer/reconnect_tracker @@ -1,30 +1,131 @@ -#!/bin/sh +#!/bin/env bash -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 +# Pinout for cellulariot app shield +STATUS=23 +POWERKEY=24 +DISABLE=17 + +# General variables +INTERVAL=60 +DOUBLE_CHECK_WAIT=10 +PING_TIMEOUT=9 + +# Configure pins +gpio -g mode $STATUS in +gpio -g mode $POWERKEY out +gpio -g mode $DISABLE out + +function debug() +{ + echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" +} + +function check_network() +{ + # Check the network is ready + debug "Checking the network is ready..." + + for i in {1..600}; do + NETWORK_OK=0 + + debug "SIM Status:" + atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" + SIM_READY=$? + + debug "Network Registeration Status:" + # For super SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" + NETWORK_REG=$? + # For native SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" + NETWORK_REG_2=$? + # Combined network registeration status + NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) + + if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then + debug "Network is ready." + NETWORK_OK=1 + return 0 + break + else + printf "?" + fi + sleep 2 + done + return 1 +} + +function power_up_module() +{ + for i in {1..20}; do + if [[ $(gpio -g read $STATUS) -eq 1 ]]; then + debug "Module is powering up..." + + gpio -g write $POWERKEY 0 + gpio -g write $POWERKEY 1 + sleep 2 + gpio -g write $POWERKEY 0 + sleep 2 + + if [[ $(gpio -g read $STATUS) -eq 0 ]]; then + debug "Module is powered up." + return 0 + break + else + debug "Module couldn't be powered up!" + sleep 2 + else + debug "Module is just powered up." + return 0 + break + fi + done + return 1 +} + +function restart_power() +{ + debug "Power of the module is restarting..." + # Restart power + gpio -g write $DISABLE 0 # power is disabled + sleep 2 + gpio -g write $DISABLE 1 # power is enabled +} + +restart_power # Restart power + +# Modem power up +if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi + +if check_network -eq 0; then + debug "PPP chatscript is starting..."; + sudo pon; +else + debug "Network registeration is failed!"; +fi while true; do + # Checking cellular internet connection + ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1 + PINGG=$? - if [ $(gpio -g read 23) = "0" ]; then - echo "Power up" + 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=$? - 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 + 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 done + From 9024ad56f239cfac2c06d632297402508f7c21b6 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Tue, 17 Nov 2020 12:06:16 -0800 Subject: [PATCH 02/49] Removed "del default route" command --- ppp_installer/install.sh | 1 - ppp_installer/install_ppp_jetson.sh | 1 - 2 files changed, 2 deletions(-) diff --git a/ppp_installer/install.sh b/ppp_installer/install.sh index 579535f..6b0bf6b 100755 --- a/ppp_installer/install.sh +++ b/ppp_installer/install.sh @@ -92,7 +92,6 @@ sed -i "s/#DEVICE/$devicename/" provider mv provider /etc/ppp/peers/provider if ! (grep -q 'sudo route' /etc/ppp/ip-up ); then - echo "sudo route del default" >> /etc/ppp/ip-up echo "sudo route add default ppp0" >> /etc/ppp/ip-up fi diff --git a/ppp_installer/install_ppp_jetson.sh b/ppp_installer/install_ppp_jetson.sh index 5127f80..aa021a9 100755 --- a/ppp_installer/install_ppp_jetson.sh +++ b/ppp_installer/install_ppp_jetson.sh @@ -93,7 +93,6 @@ sed -i "s/#DEVICE/$devicename/" provider mv provider /etc/ppp/peers/provider if ! (grep -q 'sudo route' /etc/ppp/ip-up ); then - echo "sudo route del default" >> /etc/ppp/ip-up echo "sudo route add default ppp0" >> /etc/ppp/ip-up fi From 0db047c03ce4699bd2ef393cda4021bd4c118bff Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 18 Nov 2020 05:47:30 -0800 Subject: [PATCH 03/49] Functions and config is seperated from reconnect scripts --- ppp_installer/configs.sh | 5 ++++ ppp_installer/functions.sh | 43 ++++++++++++++++++++++++++++ ppp_installer/reconnect_baseshield | 45 ++---------------------------- ppp_installer/test.sh | 10 +++++++ 4 files changed, 60 insertions(+), 43 deletions(-) create mode 100644 ppp_installer/configs.sh create mode 100644 ppp_installer/functions.sh create mode 100644 ppp_installer/test.sh diff --git a/ppp_installer/configs.sh b/ppp_installer/configs.sh new file mode 100644 index 0000000..4d731e5 --- /dev/null +++ b/ppp_installer/configs.sh @@ -0,0 +1,5 @@ +#!/binenv bash + +INTERVAL=60 +DOUBLE_CHECK_WAIT=10 +PING_TIMEOUT=9 \ No newline at end of file diff --git a/ppp_installer/functions.sh b/ppp_installer/functions.sh new file mode 100644 index 0000000..9d66796 --- /dev/null +++ b/ppp_installer/functions.sh @@ -0,0 +1,43 @@ +#!/bin/env bash + +function debug() +{ + echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" +} + +function check_network() +{ + NETWORK_TIMEOUT=300 # Check network for ($NETWORK_TIMEOUT x 2 Seconds) + + # Check the network is ready + debug "Checking the network is ready..." + + for i in {1..$NETWORK_TIMEOUT}; do + NETWORK_OK=0 + + debug "SIM Status:" + atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" + SIM_READY=$? + + debug "Network Registeration Status:" + # For super SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" + NETWORK_REG=$? + # For native SIM + atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" + NETWORK_REG_2=$? + # Combined network registeration status + NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) + + if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then + debug "Network is ready." + NETWORK_OK=1 + return 0 + break + else + printf "?" + fi + sleep 2 + done + return 1 +} diff --git a/ppp_installer/reconnect_baseshield b/ppp_installer/reconnect_baseshield index b35d7b1..8e74cc1 100644 --- a/ppp_installer/reconnect_baseshield +++ b/ppp_installer/reconnect_baseshield @@ -1,48 +1,7 @@ #!/bin/env bash -INTERVAL=60 -DOUBLE_CHECK_WAIT=10 -PING_TIMEOUT=9 - -function debug() -{ - echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" -} - -function check_network() -{ - # Check the network is ready - debug "Checking the network is ready..." - - for i in {1..600}; do - NETWORK_OK=0 - - debug "SIM Status:" - atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" - SIM_READY=$? - - debug "Network Registeration Status:" - # For super SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" - NETWORK_REG=$? - # For native SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" - NETWORK_REG_2=$? - # Combined network registeration status - NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) - - if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then - debug "Network is ready." - NETWORK_OK=1 - return 0 - break - else - printf "?" - fi - sleep 2 - done - return 1 -} +source functions.sh +source configs.sh if check_network -eq 0; then debug "PPP chatscript is starting..."; diff --git a/ppp_installer/test.sh b/ppp_installer/test.sh new file mode 100644 index 0000000..b46f5ec --- /dev/null +++ b/ppp_installer/test.sh @@ -0,0 +1,10 @@ +#!/bin/env bash + +source functions.sh +source config.sh + +echo "PING TIMEOUT: " $PING_TIMEOUT +echo "DOUBLE CHECK WAIT: " $DOUBLE_CHECK_WAIT +echo "INTERVAL: " $INTERVAL + +check_network \ No newline at end of file From 7b501a02c87101047799f24fd00f6a7675fa7ec4 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 18 Nov 2020 05:52:12 -0800 Subject: [PATCH 04/49] Simplified reconnect scripts --- ppp_installer/reconnect_basehat | 49 ++----------------------- ppp_installer/reconnect_cellulariot | 47 ++---------------------- ppp_installer/reconnect_cellulariot_app | 47 ++---------------------- ppp_installer/reconnect_gprsshield | 46 ++--------------------- ppp_installer/reconnect_test.sh | 44 +--------------------- ppp_installer/reconnect_tracker | 47 ++---------------------- 6 files changed, 18 insertions(+), 262 deletions(-) diff --git a/ppp_installer/reconnect_basehat b/ppp_installer/reconnect_basehat index fd76725..9591265 100644 --- a/ppp_installer/reconnect_basehat +++ b/ppp_installer/reconnect_basehat @@ -1,54 +1,12 @@ #!/bin/env bash +source functions.sh +source configs.sh + # Pinout for base hat POWER_OFF=26 W_DISABLE=19 -# General variables -INTERVAL=60 -DOUBLE_CHECK_WAIT=10 -PING_TIMEOUT=9 - -function debug() -{ - echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" -} - -function check_network() -{ - # Check the network is ready - debug "Checking the network is ready..." - - for i in {1..600}; do - NETWORK_OK=0 - - debug "SIM Status:" - atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" - SIM_READY=$? - - debug "Network Registeration Status:" - # For super SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" - NETWORK_REG=$? - # For native SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" - NETWORK_REG_2=$? - # Combined network registeration status - NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) - - if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then - debug "Network is ready." - NETWORK_OK=1 - return 0 - break - else - printf "?" - fi - sleep 2 - done - return 1 -} - # Control pins gpio -g mode $POWER_OFF out #HAT_POWER_OFF gpio -g mode $W_DISABLE out #W_DISABLE @@ -56,6 +14,7 @@ gpio -g mode $W_DISABLE out #W_DISABLE gpio -g write $POWER_OFF 0 gpio -g write $W_DISABLE 0 + if check_network -eq 0; then debug "PPP chatscript is starting..."; sudo pon; diff --git a/ppp_installer/reconnect_cellulariot b/ppp_installer/reconnect_cellulariot index 53066af..5c0967a 100644 --- a/ppp_installer/reconnect_cellulariot +++ b/ppp_installer/reconnect_cellulariot @@ -1,59 +1,18 @@ #!/bin/env bash +source functions.sh +source configs.sh + # Pinout for cellulariot hat STATUS=23 POWERKEY=24 ENABLE=17 -# General variables -INTERVAL=60 -DOUBLE_CHECK_WAIT=10 -PING_TIMEOUT=9 - # Configure pins gpio -g mode $STATUS in gpio -g mode $POWERKEY out gpio -g mode $ENABLE out -function debug() -{ - echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" -} - -function check_network() -{ - # Check the network is ready - debug "Checking the network is ready..." - - for i in {1..600}; do - NETWORK_OK=0 - - debug "SIM Status:" - atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" - SIM_READY=$? - - debug "Network Registeration Status:" - # For super SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" - NETWORK_REG=$? - # For native SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" - NETWORK_REG_2=$? - # Combined network registeration status - NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) - - if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then - debug "Network is ready." - NETWORK_OK=1 - return 0 - break - else - printf "?" - fi - sleep 2 - done - return 1 -} function power_up_module() { diff --git a/ppp_installer/reconnect_cellulariot_app b/ppp_installer/reconnect_cellulariot_app index 945e2fa..41c2e4e 100644 --- a/ppp_installer/reconnect_cellulariot_app +++ b/ppp_installer/reconnect_cellulariot_app @@ -1,59 +1,18 @@ #!/bin/env bash +source functions.sh +source configs.sh + # Pinout for cellulariot app shield STATUS=20 POWERKEY=11 DISABLE=26 -# General variables -INTERVAL=60 -DOUBLE_CHECK_WAIT=10 -PING_TIMEOUT=9 - # Configure pins gpio -g mode $STATUS in gpio -g mode $POWERKEY out gpio -g mode $DISABLE out -function debug() -{ - echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" -} - -function check_network() -{ - # Check the network is ready - debug "Checking the network is ready..." - - for i in {1..600}; do - NETWORK_OK=0 - - debug "SIM Status:" - atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" - SIM_READY=$? - - debug "Network Registeration Status:" - # For super SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" - NETWORK_REG=$? - # For native SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" - NETWORK_REG_2=$? - # Combined network registeration status - NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) - - if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then - debug "Network is ready." - NETWORK_OK=1 - return 0 - break - else - printf "?" - fi - sleep 2 - done - return 1 -} function power_up_module() { diff --git a/ppp_installer/reconnect_gprsshield b/ppp_installer/reconnect_gprsshield index 644e59b..11698c8 100644 --- a/ppp_installer/reconnect_gprsshield +++ b/ppp_installer/reconnect_gprsshield @@ -1,58 +1,18 @@ #!/bin/env bash +source functions.sh +source configs.sh + # Pinout for cellulariot hat STATUS=19 POWERKEY=26 -# General variables -INTERVAL=60 -DOUBLE_CHECK_WAIT=10 -PING_TIMEOUT=9 # Configure pins gpio -g mode $STATUS in gpio -g mode $POWERKEY out gpio -g mode $ENABLE out -function debug() -{ - echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" -} - -function check_network() -{ - # Check the network is ready - debug "Checking the network is ready..." - - for i in {1..600}; do - NETWORK_OK=0 - - debug "SIM Status:" - atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" - SIM_READY=$? - - debug "Network Registeration Status:" - # For super SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" - NETWORK_REG=$? - # For native SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" - NETWORK_REG_2=$? - # Combined network registeration status - NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) - - if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then - debug "Network is ready." - NETWORK_OK=1 - return 0 - break - else - printf "?" - fi - sleep 2 - done - return 1 -} function power_up_module() { diff --git a/ppp_installer/reconnect_test.sh b/ppp_installer/reconnect_test.sh index b35d7b1..0f5d620 100644 --- a/ppp_installer/reconnect_test.sh +++ b/ppp_installer/reconnect_test.sh @@ -1,48 +1,8 @@ #!/bin/env bash -INTERVAL=60 -DOUBLE_CHECK_WAIT=10 -PING_TIMEOUT=9 +source functions.sh +source configs.sh -function debug() -{ - echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" -} - -function check_network() -{ - # Check the network is ready - debug "Checking the network is ready..." - - for i in {1..600}; do - NETWORK_OK=0 - - debug "SIM Status:" - atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" - SIM_READY=$? - - debug "Network Registeration Status:" - # For super SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" - NETWORK_REG=$? - # For native SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" - NETWORK_REG_2=$? - # Combined network registeration status - NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) - - if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then - debug "Network is ready." - NETWORK_OK=1 - return 0 - break - else - printf "?" - fi - sleep 2 - done - return 1 -} if check_network -eq 0; then debug "PPP chatscript is starting..."; diff --git a/ppp_installer/reconnect_tracker b/ppp_installer/reconnect_tracker index 05e5f3d..a8c0c04 100644 --- a/ppp_installer/reconnect_tracker +++ b/ppp_installer/reconnect_tracker @@ -1,59 +1,18 @@ #!/bin/env bash +source functions.sh +source configs.sh + # Pinout for cellulariot app shield STATUS=23 POWERKEY=24 DISABLE=17 -# General variables -INTERVAL=60 -DOUBLE_CHECK_WAIT=10 -PING_TIMEOUT=9 - # Configure pins gpio -g mode $STATUS in gpio -g mode $POWERKEY out gpio -g mode $DISABLE out -function debug() -{ - echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" -} - -function check_network() -{ - # Check the network is ready - debug "Checking the network is ready..." - - for i in {1..600}; do - NETWORK_OK=0 - - debug "SIM Status:" - atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" - SIM_READY=$? - - debug "Network Registeration Status:" - # For super SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" - NETWORK_REG=$? - # For native SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" - NETWORK_REG_2=$? - # Combined network registeration status - NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) - - if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then - debug "Network is ready." - NETWORK_OK=1 - return 0 - break - else - printf "?" - fi - sleep 2 - done - return 1 -} function power_up_module() { From 15537b5feb28c17a4ae7de8a713149137ad98ade Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 18 Nov 2020 09:39:01 -0800 Subject: [PATCH 05/49] chat-connect is compatible with Telit modules --- ppp_installer/chat-connect | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ppp_installer/chat-connect b/ppp_installer/chat-connect index f3e4a59..fcb6128 100644 --- a/ppp_installer/chat-connect +++ b/ppp_installer/chat-connect @@ -7,7 +7,11 @@ ABORT "NO ANSWER" TIMEOUT 30 "" AT OK ATE0 -OK ATI;+CSUB;+CSQ;+COPS?;+CGREG?;&D2 +OK AT+CPIN? +READY AT+CSQ +OK AT+CREG? +OK AT+CGREG? +OK AT+COPS? OK AT+CGDCONT=1,"IP","\T",,0,0 OK ATD*99# CONNECT From c2b58660711535f04026390e7743068b6a31b8e6 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 18 Nov 2020 09:39:54 -0800 Subject: [PATCH 06/49] Added config file for general variables --- ppp_installer/configs.sh | 9 +++++---- ppp_installer/functions.sh | 6 +++--- ppp_installer/test.sh | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ppp_installer/configs.sh b/ppp_installer/configs.sh index 4d731e5..f127ae3 100644 --- a/ppp_installer/configs.sh +++ b/ppp_installer/configs.sh @@ -1,5 +1,6 @@ -#!/binenv bash +#!/bin/env bash -INTERVAL=60 -DOUBLE_CHECK_WAIT=10 -PING_TIMEOUT=9 \ No newline at end of file +INTERVAL=60 # Seconds, Interval between two connection check of internet +DOUBLE_CHECK_WAIT=10 # Seconds, wait time for double check when the connection is down +PING_TIMEOUT=9 # Seconds, Timeout of ping command +NETWORK_CHECK_TIMEOUT=300 # Count, Check network for ($NETWORK_TIMEOUT x 2 Seconds) \ No newline at end of file diff --git a/ppp_installer/functions.sh b/ppp_installer/functions.sh index 9d66796..2a03043 100644 --- a/ppp_installer/functions.sh +++ b/ppp_installer/functions.sh @@ -1,5 +1,7 @@ #!/bin/env bash +source configs.sh + function debug() { echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" @@ -7,12 +9,10 @@ function debug() function check_network() { - NETWORK_TIMEOUT=300 # Check network for ($NETWORK_TIMEOUT x 2 Seconds) - # Check the network is ready debug "Checking the network is ready..." - for i in {1..$NETWORK_TIMEOUT}; do + for i in {1..$NETWORK_CHECK_TIMEOUT}; do NETWORK_OK=0 debug "SIM Status:" diff --git a/ppp_installer/test.sh b/ppp_installer/test.sh index b46f5ec..22d4342 100644 --- a/ppp_installer/test.sh +++ b/ppp_installer/test.sh @@ -1,7 +1,7 @@ #!/bin/env bash source functions.sh -source config.sh +source configs.sh echo "PING TIMEOUT: " $PING_TIMEOUT echo "DOUBLE CHECK WAIT: " $DOUBLE_CHECK_WAIT From 36dc0e62a3aa0267e5093d425447efa371bebfcc Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 18 Nov 2020 10:12:00 -0800 Subject: [PATCH 07/49] install.sh is converted to bash script --- ppp_installer/install.sh | 73 ++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/ppp_installer/install.sh b/ppp_installer/install.sh index 6b0bf6b..ea70860 100755 --- a/ppp_installer/install.sh +++ b/ppp_installer/install.sh @@ -1,71 +1,78 @@ -#!/bin/sh +#!/bin/bash YELLOW='\033[1;33m' RED='\033[0;31m' BLUE='\033[1;34m' SET='\033[0m' -echo "${YELLOW}Please choose your Sixfab Shield/HAT:${SET}" -echo "${YELLOW}1: GSM/GPRS Shield${SET}" -echo "${YELLOW}2: 3G, 4G/LTE Base Shield${SET}" -echo "${YELLOW}3: Cellular IoT App Shield${SET}" -echo "${YELLOW}4: Cellular IoT HAT${SET}" -echo "${YELLOW}5: Tracker HAT${SET}" -echo "${YELLOW}6: 3G/4G Base HAT${SET}" +function colored_echo +{ + COLOR=${2:-$YELLOW} + echo -e "$COLOR $1 ${SET}" +} + + +colored_echo "Please choose your Sixfab Shield/HAT:" +colored_echo "1: GSM/GPRS Shield" +colored_echo "2: 3G, 4G/LTE Base Shield" +colored_echo "3: Cellular IoT App Shield" +colored_echo "4: Cellular IoT HAT" +colored_echo "5: Tracker HAT" +colored_echo "6: 3G/4G Base HAT" read shield_hat case $shield_hat in - 1) echo "${YELLOW}You chose GSM/GPRS Shield${SET}";; - 2) echo "${YELLOW}You chose Base Shield${SET}";; - 3) echo "${YELLOW}You chose CellularIoT Shield${SET}";; - 4) echo "${YELLOW}You chose CellularIoT HAT${SET}";; - 5) echo "${YELLOW}You chose Tracker HAT${SET}";; - 6) echo "${YELLOW}You chose 3G/4G Base HAT${SET}";; - *) echo "${RED}Wrong Selection, exiting${SET}"; exit 1; + 1) colored_echo "You chose GSM/GPRS Shield";; + 2) colored_echo "You chose Base Shield";; + 3) colored_echo "You chose CellularIoT Shield";; + 4) colored_echo "You chose CellularIoT HAT";; + 5) colored_echo "You chose Tracker HAT";; + 6) colored_echo "You chose 3G/4G Base HAT";; + *) colored_echo "Wrong Selection, exiting" ${RED}; exit 1; esac -echo "${YELLOW}Downloading setup files${SET}" +colored_echo "Downloading setup files..." wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-connect -O chat-connect if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" + colored_echo "Download failed" ${RED} exit 1; fi wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-disconnect -O chat-disconnect if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" - exit 1; + colored_echo "Download failed" ${RED} + exit 1; fi wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/provider -O provider if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" - exit 1; + colored_echo "Download failed" ${RED} + exit 1; fi -echo "${YELLOW}ppp and wiringpi (gpio tool) install${SET}" -apt install ppp wiringpi -y +colored_echo "ppp and wiringpi (gpio tool) installing..." +apt-get install ppp wiringpi -y -echo "${YELLOW}What is your carrier APN?${SET}" +colored_echo "What is your carrier APN?" read carrierapn while [ 1 ] do - echo "${YELLOW}Does your carrier need username and password? [Y/n]${SET}" + colored_echo "Does your carrier need username and password? [Y/n]" read usernpass case $usernpass in [Yy]* ) while [ 1 ] do - echo "${YELLOW}Enter username${SET}" + colored_echo "Enter username" read username - echo "${YELLOW}Enter password${SET}" + colored_echo "Enter password" read password sed -i "s/noauth/#noauth\nuser \"$username\"\npassword \"$password\"/" provider break @@ -74,11 +81,11 @@ do break;; [Nn]* ) break;; - *) echo "${RED}Wrong Selection, Select among Y or n${SET}";; + *) colored_echo "Wrong Selection, Select among Y or n" ${RED};; esac done -echo "${YELLOW}What is your device communication PORT? (ttyS0/ttyUSB3/etc.)${SET}" +colored_echo "What is your device communication PORT? (ttyS0/ttyUSB3/etc.)" read devicename mkdir -p /etc/chatscripts @@ -103,11 +110,11 @@ fi while [ 1 ] do - echo "${YELLOW}Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n] ${SET}" + colored_echo "Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n]" read auto_reconnect case $auto_reconnect in - [Yy]* ) echo "${YELLOW}Downloading setup file${SET}" + [Yy]* ) colored_echo "Downloading setup file..." wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_service -O reconnect.service @@ -145,9 +152,9 @@ do break;; - [Nn]* ) echo "${YELLOW}To connect to internet run ${BLUE}\"sudo pon\"${YELLOW} and to disconnect run ${BLUE}\"sudo poff\" ${SET}" + [Nn]* ) echo -e "${YELLOW}To connect to internet run ${BLUE}\"sudo pon\"${YELLOW} and to disconnect run ${BLUE}\"sudo poff\" ${SET}" break;; - *) echo "${RED}Wrong Selection, Select among Y or n${SET}";; + *) colored_echo "Wrong Selection, Select among Y or n" ${RED};; esac done From 105e9f8f688d590666163dd2b6d6114b313daf40 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 18 Nov 2020 10:24:15 -0800 Subject: [PATCH 08/49] repo branch changed in install.sh --- ppp_installer/functions.sh | 2 +- ppp_installer/install.sh | 22 ++++++++++++---------- ppp_installer/reconnect_basehat | 2 +- ppp_installer/reconnect_baseshield | 2 +- ppp_installer/reconnect_cellulariot | 2 +- ppp_installer/reconnect_cellulariot_app | 2 +- ppp_installer/reconnect_gprsshield | 2 +- ppp_installer/reconnect_test.sh | 2 +- ppp_installer/reconnect_tracker | 2 +- 9 files changed, 20 insertions(+), 18 deletions(-) mode change 100644 => 100755 ppp_installer/reconnect_baseshield diff --git a/ppp_installer/functions.sh b/ppp_installer/functions.sh index 2a03043..89a5acd 100644 --- a/ppp_installer/functions.sh +++ b/ppp_installer/functions.sh @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/bin/bash source configs.sh diff --git a/ppp_installer/install.sh b/ppp_installer/install.sh index ea70860..8b26b22 100755 --- a/ppp_installer/install.sh +++ b/ppp_installer/install.sh @@ -5,6 +5,8 @@ RED='\033[0;31m' BLUE='\033[1;34m' SET='\033[0m' +REPO=revision + function colored_echo { COLOR=${2:-$YELLOW} @@ -33,21 +35,21 @@ case $shield_hat in esac colored_echo "Downloading setup files..." -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-connect -O chat-connect +wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/chat-connect -O chat-connect if [ $? -ne 0 ]; then colored_echo "Download failed" ${RED} exit 1; fi -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-disconnect -O chat-disconnect +wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/chat-disconnect -O chat-disconnect if [ $? -ne 0 ]; then colored_echo "Download failed" ${RED} exit 1; fi -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/provider -O provider +wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/provider -O provider if [ $? -ne 0 ]; then colored_echo "Download failed" ${RED} @@ -116,31 +118,31 @@ do case $auto_reconnect in [Yy]* ) colored_echo "Downloading setup file..." - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_service -O reconnect.service + wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_service -O reconnect.service if [ $shield_hat -eq 1 ]; then - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_gprsshield -O reconnect.sh + wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_gprsshield -O reconnect.sh elif [ $shield_hat -eq 2 ]; then - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_baseshield -O reconnect.sh + wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_baseshield -O reconnect.sh elif [ $shield_hat -eq 3 ]; then - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_cellulariot_app -O reconnect.sh + wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_cellulariot_app -O reconnect.sh elif [ $shield_hat -eq 4 ]; 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/$REPO/ppp_installer/reconnect_cellulariot -O reconnect.sh elif [ $shield_hat -eq 5 ]; then - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_tracker -O reconnect.sh + wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_tracker -O reconnect.sh elif [ $shield_hat -eq 6 ]; then - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_basehat -O reconnect.sh + wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_basehat -O reconnect.sh fi diff --git a/ppp_installer/reconnect_basehat b/ppp_installer/reconnect_basehat index 9591265..df682ff 100644 --- a/ppp_installer/reconnect_basehat +++ b/ppp_installer/reconnect_basehat @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/bin/bash source functions.sh source configs.sh diff --git a/ppp_installer/reconnect_baseshield b/ppp_installer/reconnect_baseshield old mode 100644 new mode 100755 index 8e74cc1..13fe285 --- a/ppp_installer/reconnect_baseshield +++ b/ppp_installer/reconnect_baseshield @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/bin/bash source functions.sh source configs.sh diff --git a/ppp_installer/reconnect_cellulariot b/ppp_installer/reconnect_cellulariot index 5c0967a..52c9789 100644 --- a/ppp_installer/reconnect_cellulariot +++ b/ppp_installer/reconnect_cellulariot @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/bin/bash source functions.sh source configs.sh diff --git a/ppp_installer/reconnect_cellulariot_app b/ppp_installer/reconnect_cellulariot_app index 41c2e4e..69c4d6a 100644 --- a/ppp_installer/reconnect_cellulariot_app +++ b/ppp_installer/reconnect_cellulariot_app @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/bin/bash source functions.sh source configs.sh diff --git a/ppp_installer/reconnect_gprsshield b/ppp_installer/reconnect_gprsshield index 11698c8..926d44a 100644 --- a/ppp_installer/reconnect_gprsshield +++ b/ppp_installer/reconnect_gprsshield @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/bin/bash source functions.sh source configs.sh diff --git a/ppp_installer/reconnect_test.sh b/ppp_installer/reconnect_test.sh index 0f5d620..c0a50ad 100644 --- a/ppp_installer/reconnect_test.sh +++ b/ppp_installer/reconnect_test.sh @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/bin/bash source functions.sh source configs.sh diff --git a/ppp_installer/reconnect_tracker b/ppp_installer/reconnect_tracker index a8c0c04..33b8e32 100644 --- a/ppp_installer/reconnect_tracker +++ b/ppp_installer/reconnect_tracker @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/bin/bash source functions.sh source configs.sh From b1a6f6848c4368393dbdc9d4f188d54ea6752872 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 18 Nov 2020 10:45:59 -0800 Subject: [PATCH 09/49] changed working directories --- ppp_installer/install.sh | 35 ++++++++++++++++++++++++++++++--- ppp_installer/reconnect_service | 4 ++-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/ppp_installer/install.sh b/ppp_installer/install.sh index 8b26b22..d0829dc 100755 --- a/ppp_installer/install.sh +++ b/ppp_installer/install.sh @@ -1,11 +1,18 @@ #!/bin/bash +REPO=revision +SIXFAB_PATH="/opt/sixfab" +PPP_PATH="/opt/sixfab/ppp_connection_manager" + YELLOW='\033[1;33m' RED='\033[0;31m' BLUE='\033[1;34m' SET='\033[0m' -REPO=revision +function debug() +{ + echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" +} function colored_echo { @@ -14,6 +21,23 @@ function colored_echo } +# Check Sixfab path +if [[ -e $SIXFAB_PATH ]]; then + debug "Path already exist!" +else + sudo mkdir $SIXFAB_PATH + debug "Sixfab path is created." +fi + +# Check PPP path +if [[ -e $PPP_PATH ]]; then + debug "Path already exist!" +else + sudo mkdir $PPP_PATH + debug "PPP path is created." +fi + + colored_echo "Please choose your Sixfab Shield/HAT:" colored_echo "1: GSM/GPRS Shield" colored_echo "2: 3G, 4G/LTE Base Shield" @@ -119,7 +143,10 @@ do [Yy]* ) colored_echo "Downloading setup file..." wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_service -O reconnect.service - + wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/functions.sh + wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/configs.sh + + if [ $shield_hat -eq 1 ]; then wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_gprsshield -O reconnect.sh @@ -146,7 +173,9 @@ do fi - mv reconnect.sh /usr/src/ + mv reconnect.sh $PPP_PATH + mv functions.sh $PPP_PATH + mv configs.sh $PPP_PATH mv reconnect.service /etc/systemd/system/ systemctl daemon-reload diff --git a/ppp_installer/reconnect_service b/ppp_installer/reconnect_service index c3a9d65..aed5577 100644 --- a/ppp_installer/reconnect_service +++ b/ppp_installer/reconnect_service @@ -3,8 +3,8 @@ Description=PPP Auto Connection After=network.target [Service] -ExecStart=/bin/sh /usr/src/reconnect.sh -WorkingDirectory=/usr/src/ +ExecStart=/bin/bash reconnect.sh +WorkingDirectory=/opt/sixfab/ppp_connection_manager StandardOutput=inherit StandardError=inherit Restart=always From 3811a1a043902d803870e7e0026ff5acb7fdc172 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 18 Nov 2020 10:56:11 -0800 Subject: [PATCH 10/49] removed User=pi line to provide more compatibility --- ppp_installer/reconnect_service | 1 - 1 file changed, 1 deletion(-) diff --git a/ppp_installer/reconnect_service b/ppp_installer/reconnect_service index aed5577..59d706e 100644 --- a/ppp_installer/reconnect_service +++ b/ppp_installer/reconnect_service @@ -8,7 +8,6 @@ WorkingDirectory=/opt/sixfab/ppp_connection_manager StandardOutput=inherit StandardError=inherit Restart=always -User=pi [Install] WantedBy=multi-user.target From 3c974f6dad7c73293936a306d62cbfeac611845b Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 18 Nov 2020 11:09:09 -0800 Subject: [PATCH 11/49] changed all folder structure --- ppp_installer/install.sh => install.sh | 30 +++++++++++-------- ...all_ppp_jetson.sh => install_ppp_jetson.sh | 0 ...install_supersim.sh => install_supersim.sh | 0 ppp_installer/test.sh | 10 ------- {ppp_installer => src}/chat-connect | 0 {ppp_installer => src}/chat-disconnect | 0 {ppp_installer => src}/configs.sh | 0 {ppp_installer => src}/functions.sh | 0 {ppp_installer => src}/provider | 0 .../reconnect_scripts}/reconnect_basehat | 0 .../reconnect_scripts}/reconnect_baseshield | 0 .../reconnect_scripts}/reconnect_cellulariot | 0 .../reconnect_cellulariot_app | 0 .../reconnect_scripts}/reconnect_gprsshield | 0 .../reconnect_scripts}/reconnect_test.sh | 0 .../reconnect_scripts}/reconnect_tracker | 0 {ppp_installer => src}/reconnect_service | 0 17 files changed, 17 insertions(+), 23 deletions(-) rename ppp_installer/install.sh => install.sh (68%) rename ppp_installer/install_ppp_jetson.sh => install_ppp_jetson.sh (100%) rename ppp_installer/install_supersim.sh => install_supersim.sh (100%) delete mode 100644 ppp_installer/test.sh rename {ppp_installer => src}/chat-connect (100%) rename {ppp_installer => src}/chat-disconnect (100%) rename {ppp_installer => src}/configs.sh (100%) rename {ppp_installer => src}/functions.sh (100%) rename {ppp_installer => src}/provider (100%) rename {ppp_installer => src/reconnect_scripts}/reconnect_basehat (100%) rename {ppp_installer => src/reconnect_scripts}/reconnect_baseshield (100%) rename {ppp_installer => src/reconnect_scripts}/reconnect_cellulariot (100%) rename {ppp_installer => src/reconnect_scripts}/reconnect_cellulariot_app (100%) rename {ppp_installer => src/reconnect_scripts}/reconnect_gprsshield (100%) rename {ppp_installer => src/reconnect_scripts}/reconnect_test.sh (100%) rename {ppp_installer => src/reconnect_scripts}/reconnect_tracker (100%) rename {ppp_installer => src}/reconnect_service (100%) diff --git a/ppp_installer/install.sh b/install.sh similarity index 68% rename from ppp_installer/install.sh rename to install.sh index d0829dc..d50f712 100755 --- a/ppp_installer/install.sh +++ b/install.sh @@ -1,9 +1,13 @@ #!/bin/bash -REPO=revision SIXFAB_PATH="/opt/sixfab" PPP_PATH="/opt/sixfab/ppp_connection_manager" +REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer" +BRANCH=revision +SOURCE_PATH="$REPO_PATH/$BRANCH/src" +SCRIPT_PATH="$REPO_PATH/$BRANCH/src/reconnect_scripts" + YELLOW='\033[1;33m' RED='\033[0;31m' BLUE='\033[1;34m' @@ -59,21 +63,21 @@ case $shield_hat in esac colored_echo "Downloading setup files..." -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/chat-connect -O chat-connect +wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect if [ $? -ne 0 ]; then colored_echo "Download failed" ${RED} exit 1; fi -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/chat-disconnect -O chat-disconnect +wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect if [ $? -ne 0 ]; then colored_echo "Download failed" ${RED} exit 1; fi -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/provider -O provider +wget --no-check-certificate $SOURCE_PATH/provider -O provider if [ $? -ne 0 ]; then colored_echo "Download failed" ${RED} @@ -142,34 +146,34 @@ do case $auto_reconnect in [Yy]* ) colored_echo "Downloading setup file..." - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_service -O reconnect.service - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/functions.sh - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/configs.sh + wget --no-check-certificate $SOURCE_PATH/reconnect_service -O reconnect.service + wget --no-check-certificate $SOURCE_PATH/functions.sh + wget --no-check-certificate $SOURCE_PATH/configs.sh if [ $shield_hat -eq 1 ]; then - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_gprsshield -O reconnect.sh + wget --no-check-certificate $SCRIPT_PATH/reconnect_gprsshield -O reconnect.sh elif [ $shield_hat -eq 2 ]; then - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_baseshield -O reconnect.sh + wget --no-check-certificate $SCRIPT_PATH/reconnect_baseshield -O reconnect.sh elif [ $shield_hat -eq 3 ]; then - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_cellulariot_app -O reconnect.sh + wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot_app -O reconnect.sh elif [ $shield_hat -eq 4 ]; then - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_cellulariot -O reconnect.sh + wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O reconnect.sh elif [ $shield_hat -eq 5 ]; then - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_tracker -O reconnect.sh + wget --no-check-certificate $SCRIPT_PATH/reconnect_tracker -O reconnect.sh elif [ $shield_hat -eq 6 ]; then - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/$REPO/ppp_installer/reconnect_basehat -O reconnect.sh + wget --no-check-certificate $SCRIPT_PATH/reconnect_basehat -O reconnect.sh fi diff --git a/ppp_installer/install_ppp_jetson.sh b/install_ppp_jetson.sh similarity index 100% rename from ppp_installer/install_ppp_jetson.sh rename to install_ppp_jetson.sh diff --git a/ppp_installer/install_supersim.sh b/install_supersim.sh similarity index 100% rename from ppp_installer/install_supersim.sh rename to install_supersim.sh diff --git a/ppp_installer/test.sh b/ppp_installer/test.sh deleted file mode 100644 index 22d4342..0000000 --- a/ppp_installer/test.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/env bash - -source functions.sh -source configs.sh - -echo "PING TIMEOUT: " $PING_TIMEOUT -echo "DOUBLE CHECK WAIT: " $DOUBLE_CHECK_WAIT -echo "INTERVAL: " $INTERVAL - -check_network \ No newline at end of file diff --git a/ppp_installer/chat-connect b/src/chat-connect similarity index 100% rename from ppp_installer/chat-connect rename to src/chat-connect diff --git a/ppp_installer/chat-disconnect b/src/chat-disconnect similarity index 100% rename from ppp_installer/chat-disconnect rename to src/chat-disconnect diff --git a/ppp_installer/configs.sh b/src/configs.sh similarity index 100% rename from ppp_installer/configs.sh rename to src/configs.sh diff --git a/ppp_installer/functions.sh b/src/functions.sh similarity index 100% rename from ppp_installer/functions.sh rename to src/functions.sh diff --git a/ppp_installer/provider b/src/provider similarity index 100% rename from ppp_installer/provider rename to src/provider diff --git a/ppp_installer/reconnect_basehat b/src/reconnect_scripts/reconnect_basehat similarity index 100% rename from ppp_installer/reconnect_basehat rename to src/reconnect_scripts/reconnect_basehat diff --git a/ppp_installer/reconnect_baseshield b/src/reconnect_scripts/reconnect_baseshield similarity index 100% rename from ppp_installer/reconnect_baseshield rename to src/reconnect_scripts/reconnect_baseshield diff --git a/ppp_installer/reconnect_cellulariot b/src/reconnect_scripts/reconnect_cellulariot similarity index 100% rename from ppp_installer/reconnect_cellulariot rename to src/reconnect_scripts/reconnect_cellulariot diff --git a/ppp_installer/reconnect_cellulariot_app b/src/reconnect_scripts/reconnect_cellulariot_app similarity index 100% rename from ppp_installer/reconnect_cellulariot_app rename to src/reconnect_scripts/reconnect_cellulariot_app diff --git a/ppp_installer/reconnect_gprsshield b/src/reconnect_scripts/reconnect_gprsshield similarity index 100% rename from ppp_installer/reconnect_gprsshield rename to src/reconnect_scripts/reconnect_gprsshield diff --git a/ppp_installer/reconnect_test.sh b/src/reconnect_scripts/reconnect_test.sh similarity index 100% rename from ppp_installer/reconnect_test.sh rename to src/reconnect_scripts/reconnect_test.sh diff --git a/ppp_installer/reconnect_tracker b/src/reconnect_scripts/reconnect_tracker similarity index 100% rename from ppp_installer/reconnect_tracker rename to src/reconnect_scripts/reconnect_tracker diff --git a/ppp_installer/reconnect_service b/src/reconnect_service similarity index 100% rename from ppp_installer/reconnect_service rename to src/reconnect_service From d068380cd5e08beb6dd49fde85fb4a5a22120bf0 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 18 Nov 2020 11:54:13 -0800 Subject: [PATCH 12/49] Added template of connection_manager scripts --- src/configure_modem.sh | 38 +++++++++++++++++++++++++++++++++++ src/ppp_connection_manager.sh | 32 +++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 src/configure_modem.sh create mode 100644 src/ppp_connection_manager.sh diff --git a/src/configure_modem.sh b/src/configure_modem.sh new file mode 100644 index 0000000..9867337 --- /dev/null +++ b/src/configure_modem.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +source functions.sh + +### Modem configuration for RMNET/PPP mode ################################## +debug "Checking APN and Modem Mode..." + +# APN +atcom "AT+CGDCONT?" "OK" "ERROR" 10 | grep super >> /dev/null + +if [[ $? -ne 0 ]]; then + atcom "AT+CGDCONT=1,\"IP\",\"super\"" "OK" "ERROR" 10 + debug "APN is updated." +fi + +atcom "AT#USBCFG?" "OK" "ERROR" 10 | grep 0 >> /dev/null + +if [[ $? -ne 0 ]]; then + atcom "AT#USBCFG=0" "OK" "ERROR" 10 + debug "RMNET/PPP mode is activated." + debug "Modem restarting..." + + sleep 20 + + # Check modem is started! + for i in {1..120}; do + route -n | grep wwan0 >> /dev/null + if [[ $? -eq 0 ]]; then + echo + debug "Modem is restarted." + break + fi + sleep 1 + printf "*" + done + sleep 5 # wait until modem is ready +fi +### End of Modem configuration for RMNET/PPP mode ############################ \ No newline at end of file diff --git a/src/ppp_connection_manager.sh b/src/ppp_connection_manager.sh new file mode 100644 index 0000000..3207a06 --- /dev/null +++ b/src/ppp_connection_manager.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +source functions.sh + +LOG_FOLDER="./logs" +LOG_FILE_NAME=$(date "+%Y_%m_%d_%H:%M:%S") + +if [[ -e $LOG_FOLDER ]]; then + debug "Log folder already exist!" +else + sudo mkdir $LOG_FOLDER + debug "Log folder is created." +fi + +for i in {1..120}; do + bash configure_modem.sh |& sudo tee -a ./logs/$LOG_FILE_NAME.log + MODEM_CONFIG=$? + + if [[ $MODEM_CONFIG -eq 0 ]]; then + break + fi + + sleep 1 +done + +if [[ $MODEM_CONFIG -eq 0 ]]; then + bash ./reconnect_scripts/reconnect_baseshield |& sudo tee -a ./logs/$LOG_FILE_NAME.log +else + debug "Modem configuration is failed multiple times!" + debug "Checkout other troubleshooting step on docs.sixfab.com." + exit 1 +fi From 63524e154a95ace63c07d401ebc58c63e831f933 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 19 Nov 2020 00:19:04 -0800 Subject: [PATCH 13/49] Chnaged service and script names --- install.sh | 22 ++++++++++--------- ...service => ppp_connection_manager.service} | 4 ++-- 2 files changed, 14 insertions(+), 12 deletions(-) rename src/{reconnect_service => ppp_connection_manager.service} (70%) diff --git a/install.sh b/install.sh index d50f712..a79b706 100755 --- a/install.sh +++ b/install.sh @@ -7,6 +7,8 @@ REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer" BRANCH=revision SOURCE_PATH="$REPO_PATH/$BRANCH/src" SCRIPT_PATH="$REPO_PATH/$BRANCH/src/reconnect_scripts" +SCRIPT_NAME="ppp_reconnect.sh" +SERVICE_NAME="ppp_connection_manager.service" YELLOW='\033[1;33m' RED='\033[0;31m' @@ -146,44 +148,44 @@ do case $auto_reconnect in [Yy]* ) colored_echo "Downloading setup file..." - wget --no-check-certificate $SOURCE_PATH/reconnect_service -O reconnect.service + wget --no-check-certificate $SOURCE_PATH/$SERVICE_NAME wget --no-check-certificate $SOURCE_PATH/functions.sh wget --no-check-certificate $SOURCE_PATH/configs.sh if [ $shield_hat -eq 1 ]; then - wget --no-check-certificate $SCRIPT_PATH/reconnect_gprsshield -O reconnect.sh + wget --no-check-certificate $SCRIPT_PATH/reconnect_gprsshield -O $SCRIPT_NAME elif [ $shield_hat -eq 2 ]; then - wget --no-check-certificate $SCRIPT_PATH/reconnect_baseshield -O reconnect.sh + wget --no-check-certificate $SCRIPT_PATH/reconnect_baseshield -O $SCRIPT_NAME elif [ $shield_hat -eq 3 ]; then - wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot_app -O reconnect.sh + wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot_app -O $SCRIPT_NAME elif [ $shield_hat -eq 4 ]; then - wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O reconnect.sh + wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $SCRIPT_NAME elif [ $shield_hat -eq 5 ]; then - wget --no-check-certificate $SCRIPT_PATH/reconnect_tracker -O reconnect.sh + wget --no-check-certificate $SCRIPT_PATH/reconnect_tracker -O $SCRIPT_NAME elif [ $shield_hat -eq 6 ]; then - wget --no-check-certificate $SCRIPT_PATH/reconnect_basehat -O reconnect.sh + wget --no-check-certificate $SCRIPT_PATH/reconnect_basehat -O $SCRIPT_NAME fi - mv reconnect.sh $PPP_PATH + mv $SCRIPT_NAME $PPP_PATH mv functions.sh $PPP_PATH mv configs.sh $PPP_PATH - mv reconnect.service /etc/systemd/system/ + mv $SERVICE_NAME /etc/systemd/system/ systemctl daemon-reload - systemctl enable reconnect.service + systemctl enable $SERVICE_NAME break;; diff --git a/src/reconnect_service b/src/ppp_connection_manager.service similarity index 70% rename from src/reconnect_service rename to src/ppp_connection_manager.service index 59d706e..e521796 100644 --- a/src/reconnect_service +++ b/src/ppp_connection_manager.service @@ -1,9 +1,9 @@ [Unit] -Description=PPP Auto Connection +Description=PPP Connection Manager After=network.target [Service] -ExecStart=/bin/bash reconnect.sh +ExecStart=/bin/bash ppp_connection_manager.sh WorkingDirectory=/opt/sixfab/ppp_connection_manager StandardOutput=inherit StandardError=inherit From 3f2b640779e07d573ee5f705d47b44b44593a20b Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 19 Nov 2020 01:34:16 -0800 Subject: [PATCH 14/49] Typo fixed --- install.sh | 23 ++++++++++++++--------- src/ppp_connection_manager.sh | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index a79b706..33d2cb7 100755 --- a/install.sh +++ b/install.sh @@ -7,7 +7,8 @@ REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer" BRANCH=revision SOURCE_PATH="$REPO_PATH/$BRANCH/src" SCRIPT_PATH="$REPO_PATH/$BRANCH/src/reconnect_scripts" -SCRIPT_NAME="ppp_reconnect.sh" +RECONNECT_SCRIPT_NAME="ppp_reconnect.sh" +MANAGER_SCRIPT_NAME="ppp_connection_manager.sh" SERVICE_NAME="ppp_connection_manager.service" YELLOW='\033[1;33m' @@ -151,37 +152,41 @@ do wget --no-check-certificate $SOURCE_PATH/$SERVICE_NAME wget --no-check-certificate $SOURCE_PATH/functions.sh wget --no-check-certificate $SOURCE_PATH/configs.sh + wget --no-check-certificate $SOURCE_PATH/configure_modem.sh + wget --no-check-certificate $SOURCE_PATH/$MANAGER_SCRIPT_NAME if [ $shield_hat -eq 1 ]; then - wget --no-check-certificate $SCRIPT_PATH/reconnect_gprsshield -O $SCRIPT_NAME + wget --no-check-certificate $SCRIPT_PATH/reconnect_gprsshield -O $RECONNECT_SCRIPT_NAME elif [ $shield_hat -eq 2 ]; then - wget --no-check-certificate $SCRIPT_PATH/reconnect_baseshield -O $SCRIPT_NAME + wget --no-check-certificate $SCRIPT_PATH/reconnect_baseshield -O $RECONNECT_SCRIPT_NAME elif [ $shield_hat -eq 3 ]; then - wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot_app -O $SCRIPT_NAME + wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot_app -O $RECONNECT_SCRIPT_NAME elif [ $shield_hat -eq 4 ]; then - wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $SCRIPT_NAME + wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME elif [ $shield_hat -eq 5 ]; then - wget --no-check-certificate $SCRIPT_PATH/reconnect_tracker -O $SCRIPT_NAME + wget --no-check-certificate $SCRIPT_PATH/reconnect_tracker -O $RECONNECT_SCRIPT_NAME elif [ $shield_hat -eq 6 ]; then - wget --no-check-certificate $SCRIPT_PATH/reconnect_basehat -O $SCRIPT_NAME + wget --no-check-certificate $SCRIPT_PATH/reconnect_basehat -O $RECONNECT_SCRIPT_NAME - fi + fi - mv $SCRIPT_NAME $PPP_PATH mv functions.sh $PPP_PATH mv configs.sh $PPP_PATH + mv configure_modem.sh $PPP_PATH + mv $RECONNECT_SCRIPT_NAME $PPP_PATH + mv $MANAGER_SCRIPT_NAME $PPP_PATH mv $SERVICE_NAME /etc/systemd/system/ systemctl daemon-reload diff --git a/src/ppp_connection_manager.sh b/src/ppp_connection_manager.sh index 3207a06..80d05af 100644 --- a/src/ppp_connection_manager.sh +++ b/src/ppp_connection_manager.sh @@ -24,7 +24,7 @@ for i in {1..120}; do done if [[ $MODEM_CONFIG -eq 0 ]]; then - bash ./reconnect_scripts/reconnect_baseshield |& sudo tee -a ./logs/$LOG_FILE_NAME.log + bash ppp_reconnect.sh |& sudo tee -a ./logs/$LOG_FILE_NAME.log else debug "Modem configuration is failed multiple times!" debug "Checkout other troubleshooting step on docs.sixfab.com." From 7b9687d4e735d11c6e62a0c6dd4eeed9b542ab0d Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 19 Nov 2020 03:54:45 -0800 Subject: [PATCH 15/49] Updated installer.sh files for jetson and Sixfab SIM --- install.sh | 12 ++--- install_ppp_jetson.sh | 104 ++++++++++++++++++++++++++++-------------- install_supersim.sh | 91 ++++++++++++++++++++++++++---------- 3 files changed, 140 insertions(+), 67 deletions(-) diff --git a/install.sh b/install.sh index 33d2cb7..c9771fb 100755 --- a/install.sh +++ b/install.sh @@ -16,10 +16,6 @@ RED='\033[0;31m' BLUE='\033[1;34m' SET='\033[0m' -function debug() -{ - echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" -} function colored_echo { @@ -30,18 +26,18 @@ function colored_echo # Check Sixfab path if [[ -e $SIXFAB_PATH ]]; then - debug "Path already exist!" + colored_echo "Sixfab path already exist!" ${SET} else sudo mkdir $SIXFAB_PATH - debug "Sixfab path is created." + colored_echo "Sixfab path is created." ${SET} fi # Check PPP path if [[ -e $PPP_PATH ]]; then - debug "Path already exist!" + colored_echo "PPP path already exist!" ${SET} else sudo mkdir $PPP_PATH - debug "PPP path is created." + colored_echo "PPP path is created." ${SET} fi diff --git a/install_ppp_jetson.sh b/install_ppp_jetson.sh index aa021a9..7b52ec3 100755 --- a/install_ppp_jetson.sh +++ b/install_ppp_jetson.sh @@ -1,72 +1,108 @@ -#!/bin/sh -' -Created on July 12, 2019 by Saeed Johar (saeedjohar) -' +#!/bin/bash + +# Created on July 12, 2019 by Saeed Johar (saeedjohar) +# Revised on November 19, 2020 by Yasin Kaya (selengalp) + +SIXFAB_PATH="/opt/sixfab" +PPP_PATH="/opt/sixfab/ppp_connection_manager" + +REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer" +BRANCH=revision +SOURCE_PATH="$REPO_PATH/$BRANCH/src" +SCRIPT_PATH="$REPO_PATH/$BRANCH/src/reconnect_scripts" +RECONNECT_SCRIPT_NAME="ppp_reconnect.sh" +MANAGER_SCRIPT_NAME="ppp_connection_manager.sh" +SERVICE_NAME="ppp_connection_manager.service" + YELLOW='\033[1;33m' RED='\033[0;31m' BLUE='\033[1;34m' SET='\033[0m' -echo "${YELLOW}Please choose your Sixfab Shield/HAT:${SET}" -echo "${YELLOW}1: GSM/GPRS Shield${SET}" -echo "${YELLOW}2: 3G, 4G/LTE Base Shield${SET}" -echo "${YELLOW}3: Cellular IoT App Shield${SET}" -echo "${YELLOW}4: Cellular IoT HAT${SET}" -echo "${YELLOW}5: Tracker HAT${SET}" -echo "${YELLOW}6: 3G/4G Base HAT${SET}" + +function colored_echo +{ + COLOR=${2:-$YELLOW} + echo -e "$COLOR $1 ${SET}" +} + + +# Check Sixfab path +if [[ -e $SIXFAB_PATH ]]; then + colored_echo "Sixfab path already exist!" ${SET} +else + sudo mkdir $SIXFAB_PATH + colored_echo "Sixfab path is created." ${SET} +fi + +# Check PPP path +if [[ -e $PPP_PATH ]]; then + colored_echo "PPP path already exist!" ${SET} +else + sudo mkdir $PPP_PATH + colored_echo "PPP path is created." ${SET} +fi + +colored_echo "Please choose your Sixfab Shield/HAT:" +colored_echo "1: GSM/GPRS Shield" +colored_echo "2: 3G, 4G/LTE Base Shield" +colored_echo "3: Cellular IoT App Shield" +colored_echo "4: Cellular IoT HAT" +colored_echo "5: Tracker HAT" +colored_echo "6: 3G/4G Base HAT" read shield_hat case $shield_hat in - 1) echo "${YELLOW}You chose GSM/GPRS Shield${SET}";; - 2) echo "${YELLOW}You chose Base Shield${SET}";; - 3) echo "${YELLOW}You chose CellularIoT Shield${SET}";; - 4) echo "${YELLOW}You chose CellularIoT HAT${SET}";; - 5) echo "${YELLOW}You chose Tracker HAT${SET}";; - 6) echo "${YELLOW}You chose 3G/4G Base HAT${SET}";; - *) echo "${RED}Wrong Selection, exiting${SET}"; exit 1; + 1) colored_echo "You chose GSM/GPRS Shield";; + 2) colored_echo "You chose Base Shield";; + 3) colored_echo "You chose CellularIoT Shield";; + 4) colored_echo "You chose CellularIoT HAT";; + 5) colored_echo "You chose Tracker HAT";; + 6) colored_echo "You chose 3G/4G Base HAT";; + *) colored_echo "Wrong Selection, exiting" ${RED}; exit 1; esac -echo "${YELLOW}Downloading setup files${SET}" -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-connect -O chat-connect +colored_echo "Downloading setup files..." +wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" + colored_echo "Download failed" ${RED} exit 1; fi -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-disconnect -O chat-disconnect +wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" - exit 1; + colored_echo "Download failed" ${RED} + exit 1; fi -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/provider -O provider +wget --no-check-certificate $SOURCE_PATH/provider -O provider if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" - exit 1; + colored_echo "Download failed" ${RED} + exit 1; fi -echo "${YELLOW}ppp install${SET}" +colored_echo "ppp installing" apt-get install ppp -y -echo "${YELLOW}What is your carrier APN?${SET}" +colored_echo "What is your carrier APN?" read carrierapn while [ 1 ] do - echo "${YELLOW}Does your carrier need username and password? [Y/n]${SET}" + colored_echo "Does your carrier need username and password? [Y/n]" read usernpass case $usernpass in [Yy]* ) while [ 1 ] do - echo "${YELLOW}Enter username${SET}" + colored_echo "Enter username" read username - echo "${YELLOW}Enter password${SET}" + colored_echo "Enter password" read password sed -i "s/noauth/#noauth\nuser \"$username\"\npassword \"$password\"/" provider break @@ -75,11 +111,11 @@ do break;; [Nn]* ) break;; - *) echo "${RED}Wrong Selection, Select among Y or n${SET}";; + *) colored_echo "Wrong Selection, Select among Y or n" ${RED};; esac done -echo "${YELLOW}What is your device communication PORT? (ttyS0/ttyUSB3/etc.)${SET}" +colored_echo "What is your device communication PORT? (ttyS0/ttyUSB3/etc.)" read devicename mkdir -p /etc/chatscripts diff --git a/install_supersim.sh b/install_supersim.sh index 297e239..78d242f 100644 --- a/install_supersim.sh +++ b/install_supersim.sh @@ -1,36 +1,71 @@ -#!/bin/sh +#!/bin/bash + +SIXFAB_PATH="/opt/sixfab" +PPP_PATH="/opt/sixfab/ppp_connection_manager" + +REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer" +BRANCH=revision +SOURCE_PATH="$REPO_PATH/$BRANCH/src" +SCRIPT_PATH="$REPO_PATH/$BRANCH/src/reconnect_scripts" +RECONNECT_SCRIPT_NAME="ppp_reconnect.sh" +MANAGER_SCRIPT_NAME="ppp_connection_manager.sh" +SERVICE_NAME="ppp_connection_manager.service" YELLOW='\033[1;33m' RED='\033[0;31m' BLUE='\033[1;34m' SET='\033[0m' -echo "${YELLOW}Installing PPP for Sixfab Cellular IoT Shield/HAT with Twilio Super SIM${SET}" -echo "${YELLOW}Downloading setup files${SET}" -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-connect -O chat-connect +function colored_echo +{ + COLOR=${2:-$YELLOW} + echo -e "$COLOR $1 ${SET}" +} + + +# Check Sixfab path +if [[ -e $SIXFAB_PATH ]]; then + colored_echo "Sixfab path already exist!" ${SET} +else + sudo mkdir $SIXFAB_PATH + colored_echo "Sixfab path is created." ${SET} +fi + +# Check PPP path +if [[ -e $PPP_PATH ]]; then + colored_echo "PPP path already exist!" ${SET} +else + sudo mkdir $PPP_PATH + colored_echo "PPP path is created." ${SET} +fi + +colored_echo "Installing PPP for Sixfab Cellular IoT Shield/HAT with Twilio Super SIM" + +colored_echo "Downloading setup files..." +wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" + colored_echo "Download failed" ${RED} exit 1; fi -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/chat-disconnect -O chat-disconnect +wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" - exit 1; + colored_echo "Download failed" ${RED} + exit 1; fi -wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/provider -O provider +wget --no-check-certificate $SOURCE_PATH/provider -O provider if [ $? -ne 0 ]; then - echo "${RED}Download failed${SET}" - exit 1; + colored_echo "Download failed" ${RED} + exit 1; fi -echo "${YELLOW}ppp and wiringpi (gpio tool) install${SET}" -apt install ppp wiringpi -y +colored_echo "ppp and wiringpi (gpio tool) installing..." +apt-get install ppp wiringpi -y mkdir -p /etc/chatscripts @@ -43,33 +78,39 @@ sed -i "s/#DEVICE/ttyUSB3/" provider mv provider /etc/ppp/peers/provider if ! (grep -q 'sudo route' /etc/ppp/ip-up ); then - echo "sudo route del default" >> /etc/ppp/ip-up echo "sudo route add default ppp0" >> /etc/ppp/ip-up fi while [ 1 ] do - echo "${YELLOW}Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n] ${SET}" + colored_echo "Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n]" read auto_reconnect case $auto_reconnect in - [Yy]* ) echo "${YELLOW}Downloading setup file${SET}" + [Yy]* ) colored_echo "Downloading setup file..." - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_service -O reconnect.service - - wget --no-check-certificate https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_installer/reconnect_cellulariot -O reconnect.sh - - mv reconnect.sh /usr/src/ - mv reconnect.service /etc/systemd/system/ + wget --no-check-certificate $SOURCE_PATH/$SERVICE_NAME + wget --no-check-certificate $SOURCE_PATH/functions.sh + wget --no-check-certificate $SOURCE_PATH/configs.sh + wget --no-check-certificate $SOURCE_PATH/configure_modem.sh + wget --no-check-certificate $SOURCE_PATH/$MANAGER_SCRIPT_NAME + wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME + + mv functions.sh $PPP_PATH + mv configs.sh $PPP_PATH + mv configure_modem.sh $PPP_PATH + mv $RECONNECT_SCRIPT_NAME $PPP_PATH + mv $MANAGER_SCRIPT_NAME $PPP_PATH + mv $SERVICE_NAME /etc/systemd/system/ systemctl daemon-reload - systemctl enable reconnect.service + systemctl enable $SERVICE_NAME break;; - [Nn]* ) echo "${YELLOW}To connect to internet run ${BLUE}\"sudo pon\"${YELLOW} and to disconnect run ${BLUE}\"sudo poff\" ${SET}" + [Nn]* ) echo -e "${YELLOW}To connect to internet run ${BLUE}\"sudo pon\"${YELLOW} and to disconnect run ${BLUE}\"sudo poff\" ${SET}" break;; - *) echo "${RED}Wrong Selection, Select among Y or n${SET}";; + *) colored_echo "Wrong Selection, Select among Y or n" ${RED};; esac done From e37b4d7d9e6994132386dbb9325609f054d1c26b Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 19 Nov 2020 09:51:22 -0800 Subject: [PATCH 16/49] added safe checks to wgets --- install.sh | 34 +++++++++++++++++++--------------- install_ppp_jetson.sh | 18 +++--------------- install_supersim.sh | 29 ++++++++++++++--------------- 3 files changed, 36 insertions(+), 45 deletions(-) diff --git a/install.sh b/install.sh index c9771fb..554ca8b 100755 --- a/install.sh +++ b/install.sh @@ -62,26 +62,15 @@ case $shield_hat in esac colored_echo "Downloading setup files..." -wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi wget --no-check-certificate $SOURCE_PATH/provider -O provider - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi colored_echo "ppp and wiringpi (gpio tool) installing..." apt-get install ppp wiringpi -y @@ -146,35 +135,50 @@ do [Yy]* ) colored_echo "Downloading setup file..." wget --no-check-certificate $SOURCE_PATH/$SERVICE_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/functions.sh + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/configs.sh + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/configure_modem.sh + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/$MANAGER_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi if [ $shield_hat -eq 1 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_gprsshield -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi elif [ $shield_hat -eq 2 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_baseshield -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi elif [ $shield_hat -eq 3 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot_app -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi elif [ $shield_hat -eq 4 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi elif [ $shield_hat -eq 5 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_tracker -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi elif [ $shield_hat -eq 6 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_basehat -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi fi diff --git a/install_ppp_jetson.sh b/install_ppp_jetson.sh index 7b52ec3..c01e719 100755 --- a/install_ppp_jetson.sh +++ b/install_ppp_jetson.sh @@ -64,25 +64,13 @@ esac colored_echo "Downloading setup files..." wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi wget --no-check-certificate $SOURCE_PATH/provider -O provider - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi colored_echo "ppp installing" apt-get install ppp -y diff --git a/install_supersim.sh b/install_supersim.sh index 78d242f..7006210 100644 --- a/install_supersim.sh +++ b/install_supersim.sh @@ -44,25 +44,13 @@ colored_echo "Installing PPP for Sixfab Cellular IoT Shield/HAT with Twilio Supe colored_echo "Downloading setup files..." wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi wget --no-check-certificate $SOURCE_PATH/provider -O provider - -if [ $? -ne 0 ]; then - colored_echo "Download failed" ${RED} - exit 1; -fi +if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi colored_echo "ppp and wiringpi (gpio tool) installing..." apt-get install ppp wiringpi -y @@ -90,11 +78,22 @@ do [Yy]* ) colored_echo "Downloading setup file..." wget --no-check-certificate $SOURCE_PATH/$SERVICE_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/functions.sh + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/configs.sh + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/configure_modem.sh + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SOURCE_PATH/$MANAGER_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME + if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi mv functions.sh $PPP_PATH mv configs.sh $PPP_PATH From 76fe40bdc7b6c466f946cfdbe3ee3352d09fb587 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Fri, 20 Nov 2020 04:06:57 -0800 Subject: [PATCH 17/49] atcom line updated with suitable new atcom version --- install.sh | 16 ++++++++++++++++ install_ppp_jetson.sh | 16 ++++++++++++++++ install_supersim.sh | 17 +++++++++++++++++ src/configure_modem.sh | 8 ++++---- src/functions.sh | 6 +++--- 5 files changed, 56 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 554ca8b..ab75856 100755 --- a/install.sh +++ b/install.sh @@ -61,6 +61,22 @@ case $shield_hat in *) colored_echo "Wrong Selection, exiting" ${RED}; exit 1; esac +colored_echo "Checking requiremments..." + +colored_echo "Installing python3 if it is required..." +if ! [ -x "$(command -v python3)" ]; then + sudo apt-get install python3 -y >/dev/null +fi + +colored_echo "Installing pip3 if it is required..." +if ! [ -x "$(command -v pip3)" ]; then + sudo apt-get install python3-pip -y >/dev/null +fi + +colored_echo "Installing or upgrading atcom if it is required..." +pip3 install -U atcom && source ~/.profile + + colored_echo "Downloading setup files..." wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect diff --git a/install_ppp_jetson.sh b/install_ppp_jetson.sh index c01e719..32170c4 100755 --- a/install_ppp_jetson.sh +++ b/install_ppp_jetson.sh @@ -62,6 +62,22 @@ case $shield_hat in *) colored_echo "Wrong Selection, exiting" ${RED}; exit 1; esac +colored_echo "Checking requiremments..." + +colored_echo "Installing python3 if it is required..." +if ! [ -x "$(command -v python3)" ]; then + sudo apt-get install python3 -y >/dev/null +fi + +colored_echo "Installing pip3 if it is required..." +if ! [ -x "$(command -v pip3)" ]; then + sudo apt-get install python3-pip -y >/dev/null +fi + +colored_echo "Installing or upgrading atcom if it is required..." +pip3 install -U atcom && source ~/.profile + + colored_echo "Downloading setup files..." wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi diff --git a/install_supersim.sh b/install_supersim.sh index 7006210..2f06b56 100644 --- a/install_supersim.sh +++ b/install_supersim.sh @@ -42,6 +42,23 @@ fi colored_echo "Installing PPP for Sixfab Cellular IoT Shield/HAT with Twilio Super SIM" + +colored_echo "Checking requiremments..." + +colored_echo "Installing python3 if it is required..." +if ! [ -x "$(command -v python3)" ]; then + sudo apt-get install python3 -y >/dev/null +fi + +colored_echo "Installing pip3 if it is required..." +if ! [ -x "$(command -v pip3)" ]; then + sudo apt-get install python3-pip -y >/dev/null +fi + +colored_echo "Installing or upgrading atcom if it is required..." +pip3 install -U atcom && source ~/.profile + + colored_echo "Downloading setup files..." wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi diff --git a/src/configure_modem.sh b/src/configure_modem.sh index 9867337..3c21282 100644 --- a/src/configure_modem.sh +++ b/src/configure_modem.sh @@ -6,17 +6,17 @@ source functions.sh debug "Checking APN and Modem Mode..." # APN -atcom "AT+CGDCONT?" "OK" "ERROR" 10 | grep super >> /dev/null +atcom "AT+CGDCONT?" | grep super >> /dev/null if [[ $? -ne 0 ]]; then - atcom "AT+CGDCONT=1,\"IP\",\"super\"" "OK" "ERROR" 10 + atcom "AT+CGDCONT=1,\"IP\",\"super\"" debug "APN is updated." fi -atcom "AT#USBCFG?" "OK" "ERROR" 10 | grep 0 >> /dev/null +atcom "AT#USBCFG?" | grep 0 >> /dev/null if [[ $? -ne 0 ]]; then - atcom "AT#USBCFG=0" "OK" "ERROR" 10 + atcom "AT#USBCFG=0" debug "RMNET/PPP mode is activated." debug "Modem restarting..." diff --git a/src/functions.sh b/src/functions.sh index 89a5acd..23d3885 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -16,15 +16,15 @@ function check_network() NETWORK_OK=0 debug "SIM Status:" - atcom AT+CPIN? OK ERROR 10 | grep "CPIN: READY" + atcom AT+CPIN? | grep "CPIN: READY" SIM_READY=$? debug "Network Registeration Status:" # For super SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,5" + atcom AT+CREG? | grep "CREG: 0,5" NETWORK_REG=$? # For native SIM - atcom AT+CREG? OK ERROR 10 | grep "CREG: 0,1" + atcom AT+CREG? | grep "CREG: 0,1" NETWORK_REG_2=$? # Combined network registeration status NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) From 3d966989014229833b85a21ff69aba0658c41609 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Mon, 23 Nov 2020 16:44:06 +0300 Subject: [PATCH 18/49] Added BG9X modules to configure_modem.sh Added rpi max power settings for base hat --- install.sh | 2 +- src/configure_modem.sh | 137 ++++++++++++++++++++++++++++++++++------- 2 files changed, 117 insertions(+), 22 deletions(-) diff --git a/install.sh b/install.sh index ab75856..8f67bd1 100755 --- a/install.sh +++ b/install.sh @@ -136,7 +136,7 @@ if ! (grep -q 'sudo route' /etc/ppp/ip-up ); then echo "sudo route add default ppp0" >> /etc/ppp/ip-up fi -if [ $shield_hat -eq 2 ]; then +if [[ $shield_hat -eq 2 ]] || [[ $shield_hat -eq 6 ]]; then if ! (grep -q 'max_usb_current' /boot/config.txt ); then echo "max_usb_current=1" >> /boot/config.txt fi diff --git a/src/configure_modem.sh b/src/configure_modem.sh index 3c21282..7b272a0 100644 --- a/src/configure_modem.sh +++ b/src/configure_modem.sh @@ -2,37 +2,132 @@ source functions.sh +# Check the vendor +lsusb | grep Quectel >> /dev/null +IS_QUECTEL=$? + +lsusb | grep Telit >> /dev/null +IS_TELIT=$? + + ### Modem configuration for RMNET/PPP mode ################################## debug "Checking APN and Modem Mode..." -# APN +# APN Configuration +# ----------------- atcom "AT+CGDCONT?" | grep super >> /dev/null if [[ $? -ne 0 ]]; then - atcom "AT+CGDCONT=1,\"IP\",\"super\"" + atcom "AT+CGDCONT=1,\"IPV4V6\",\"super\"" debug "APN is updated." fi -atcom "AT#USBCFG?" | grep 0 >> /dev/null +# Modem Mode Configuration +# ------------------------ +# For Quectel +if [[ $IS_QUECTEL -eq 0 ]]; then -if [[ $? -ne 0 ]]; then - atcom "AT#USBCFG=0" - debug "RMNET/PPP mode is activated." - debug "Modem restarting..." + lsusb | grep BG9 > /dev/null + MODEL_BG9X=$? - sleep 20 - - # Check modem is started! - for i in {1..120}; do - route -n | grep wwan0 >> /dev/null - if [[ $? -eq 0 ]]; then - echo - debug "Modem is restarted." - break + if [[ $MODEL_BG9X -eq 0 ]]; then + # BG95 and BG96 + + # RAT Searching Sequence + atcom "AT+QCFG=\"nwscanseq\"" | grep 000201 >> /dev/null + + if [[ $? -ne 0 ]]; then + atcom "AT+QCFG=\"nwscanseq\",00" + debug "Configure RAT Searching Sequence is updated." fi - sleep 1 - printf "*" - done - sleep 5 # wait until modem is ready + + # RAT(s) to be Searched + atcom "AT+QCFG=\"nwscanmode\"" | grep 0 >> /dev/null + + if [[ $? -ne 0 ]]; then + atcom "AT+QCFG=\"nwscanmode\",0" + debug "RAT(s) to be Searched is updated." + fi + + # Network Category to be Searched under LTE RAT + atcom "AT+QCFG=\"iotopmode\"" | grep 0 >> /dev/null + + if [[ $? -ne 0 ]]; then + atcom "AT+QCFG=\"iotopmode\",0" + debug "Network Category to be Searched under LTE RAT is updated." + fi + + # end of configuraiton for BG95/6 + else + # EC25 or derives. + atcom "AT+QCFG=\"usbnet\"" | grep 0 >> /dev/null + + if [[ $? -ne 0 ]]; then + atcom "AT+QCFG=\"usbnet\",0" + debug "PPP mode is activated." + debug "Modem restarting..." + + sleep 20 + + # Check modem is started + route -n | grep wwan0 >> /dev/null + if [[ $? -eq 0 ]]; then + echo + else + # If modem don't reboot automatically, reset manually + atcom "AT+CFUN=1,1" # rebooting modem + sleep 20 + fi + + # Check modem is started! + for i in {1..120}; do + route -n | grep wwan0 >> /dev/null + if [[ $? -eq 0 ]]; then + echo + debug "Modem is restarted." + break + fi + sleep 1 + printf "*" + done + sleep 5 # wait until modem is ready + fi + fi + +# For Telit +elif [[ $IS_TELIT -eq 0 ]]; then + atcom "AT#USBCFG?" | grep 4 >> /dev/null + + if [[ $? -ne 0 ]]; then + atcom "AT#USBCFG=4" + debug "ECM mode is activated." + debug "Modem restarting..." + + sleep 20 + + # Check modem is started! + for i in {1..120}; do + route -n | grep wwan0 >> /dev/null + if [[ $? -eq 0 ]]; then + echo + debug "Modem is restarted." + break + fi + sleep 1 + printf "*" + done + sleep 5 # wait until modem is ready + fi + +# Unknown +else + debug "The cellular module couldn't be detected!" + exit 1 fi -### End of Modem configuration for RMNET/PPP mode ############################ \ No newline at end of file +### End of Modem configuration for ECM mode ############################ + + +# Check the network is ready +# -------------------------- +if check_network -eq 0; then exit 0; else debug "Network registeration is failed!"; exit 1; fi + From 94763c8aef9d34dc8a8dc9aea6835c4a4c2840fb Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 25 Nov 2020 14:42:04 +0300 Subject: [PATCH 19/49] Added colored debug messages --- src/functions.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/functions.sh b/src/functions.sh index 23d3885..f54d7cd 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -2,9 +2,10 @@ source configs.sh -function debug() +function debug { - echo $(date "+%Y/%m/%d - %H:%M:%S :") "$1" + ECHO_PARAM=${2:-''} + echo -e $ECHO_PARAM ${GREEN}$(date "+%Y/%m/%d->${BLUE}%H:%M:%S") ${SET} "$1" } function check_network() From 20bc66dfbcb247fbeedd619f16d8348ddd7e5669 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 25 Nov 2020 14:51:06 +0300 Subject: [PATCH 20/49] Added colors to function.sh --- src/functions.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/functions.sh b/src/functions.sh index f54d7cd..6bf19b1 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -2,6 +2,14 @@ source configs.sh +YELLOW='\033[1;33m' +RED='\033[0;31m' +BLUE='\033[1;34m' +GREEN='\033[0;32m' +CYAN='\033[0;36m' +PURPLE='\033[0;35m' +SET='\033[0m' + function debug { ECHO_PARAM=${2:-''} From 28efbe726468bf1d19021c0e03a2806c51cb6832 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 25 Nov 2020 15:02:00 +0300 Subject: [PATCH 21/49] Fixed bug on modem mode configuration --- src/configure_modem.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/configure_modem.sh b/src/configure_modem.sh index 7b272a0..2196842 100644 --- a/src/configure_modem.sh +++ b/src/configure_modem.sh @@ -96,11 +96,11 @@ if [[ $IS_QUECTEL -eq 0 ]]; then # For Telit elif [[ $IS_TELIT -eq 0 ]]; then - atcom "AT#USBCFG?" | grep 4 >> /dev/null + atcom "AT#USBCFG?" | grep 0 >> /dev/null if [[ $? -ne 0 ]]; then - atcom "AT#USBCFG=4" - debug "ECM mode is activated." + atcom "AT#USBCFG=0" + debug "PPP mode is activated." debug "Modem restarting..." sleep 20 From 9e10f431a8630f68c386633919ad75e11089abe4 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 25 Nov 2020 16:03:27 +0300 Subject: [PATCH 22/49] Deleted install_supersim.sh --- install_supersim.sh | 134 -------------------------------------------- 1 file changed, 134 deletions(-) delete mode 100644 install_supersim.sh diff --git a/install_supersim.sh b/install_supersim.sh deleted file mode 100644 index 2f06b56..0000000 --- a/install_supersim.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash - -SIXFAB_PATH="/opt/sixfab" -PPP_PATH="/opt/sixfab/ppp_connection_manager" - -REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer" -BRANCH=revision -SOURCE_PATH="$REPO_PATH/$BRANCH/src" -SCRIPT_PATH="$REPO_PATH/$BRANCH/src/reconnect_scripts" -RECONNECT_SCRIPT_NAME="ppp_reconnect.sh" -MANAGER_SCRIPT_NAME="ppp_connection_manager.sh" -SERVICE_NAME="ppp_connection_manager.service" - -YELLOW='\033[1;33m' -RED='\033[0;31m' -BLUE='\033[1;34m' -SET='\033[0m' - - -function colored_echo -{ - COLOR=${2:-$YELLOW} - echo -e "$COLOR $1 ${SET}" -} - - -# Check Sixfab path -if [[ -e $SIXFAB_PATH ]]; then - colored_echo "Sixfab path already exist!" ${SET} -else - sudo mkdir $SIXFAB_PATH - colored_echo "Sixfab path is created." ${SET} -fi - -# Check PPP path -if [[ -e $PPP_PATH ]]; then - colored_echo "PPP path already exist!" ${SET} -else - sudo mkdir $PPP_PATH - colored_echo "PPP path is created." ${SET} -fi - -colored_echo "Installing PPP for Sixfab Cellular IoT Shield/HAT with Twilio Super SIM" - - -colored_echo "Checking requiremments..." - -colored_echo "Installing python3 if it is required..." -if ! [ -x "$(command -v python3)" ]; then - sudo apt-get install python3 -y >/dev/null -fi - -colored_echo "Installing pip3 if it is required..." -if ! [ -x "$(command -v pip3)" ]; then - sudo apt-get install python3-pip -y >/dev/null -fi - -colored_echo "Installing or upgrading atcom if it is required..." -pip3 install -U atcom && source ~/.profile - - -colored_echo "Downloading setup files..." -wget --no-check-certificate $SOURCE_PATH/chat-connect -O chat-connect -if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi - -wget --no-check-certificate $SOURCE_PATH/chat-disconnect -O chat-disconnect -if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi - -wget --no-check-certificate $SOURCE_PATH/provider -O provider -if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi - -colored_echo "ppp and wiringpi (gpio tool) installing..." -apt-get install ppp wiringpi -y - -mkdir -p /etc/chatscripts - -mv chat-connect /etc/chatscripts/ -mv chat-disconnect /etc/chatscripts/ - -mkdir -p /etc/ppp/peers -sed -i "s/#APN/super/" provider -sed -i "s/#DEVICE/ttyUSB3/" provider -mv provider /etc/ppp/peers/provider - -if ! (grep -q 'sudo route' /etc/ppp/ip-up ); then - echo "sudo route add default ppp0" >> /etc/ppp/ip-up -fi - -while [ 1 ] -do - colored_echo "Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n]" - read auto_reconnect - - case $auto_reconnect in - [Yy]* ) colored_echo "Downloading setup file..." - - wget --no-check-certificate $SOURCE_PATH/$SERVICE_NAME - if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi - - wget --no-check-certificate $SOURCE_PATH/functions.sh - if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi - - wget --no-check-certificate $SOURCE_PATH/configs.sh - if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi - - wget --no-check-certificate $SOURCE_PATH/configure_modem.sh - if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi - - wget --no-check-certificate $SOURCE_PATH/$MANAGER_SCRIPT_NAME - if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi - - wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME - if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi - - mv functions.sh $PPP_PATH - mv configs.sh $PPP_PATH - mv configure_modem.sh $PPP_PATH - mv $RECONNECT_SCRIPT_NAME $PPP_PATH - mv $MANAGER_SCRIPT_NAME $PPP_PATH - mv $SERVICE_NAME /etc/systemd/system/ - - systemctl daemon-reload - systemctl enable $SERVICE_NAME - - break;; - - [Nn]* ) echo -e "${YELLOW}To connect to internet run ${BLUE}\"sudo pon\"${YELLOW} and to disconnect run ${BLUE}\"sudo poff\" ${SET}" - break;; - *) colored_echo "Wrong Selection, Select among Y or n" ${RED};; - esac -done - -read -p "Press ENTER key to reboot" ENTER -reboot From a9c531a5764a17c967e474f19515bbf8c1f7e199 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 25 Nov 2020 16:59:31 +0300 Subject: [PATCH 23/49] Added feedback of user inputs to install.sh --- install.sh | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 8f67bd1..ea8ee18 100755 --- a/install.sh +++ b/install.sh @@ -14,6 +14,7 @@ SERVICE_NAME="ppp_connection_manager.service" YELLOW='\033[1;33m' RED='\033[0;31m' BLUE='\033[1;34m' +GREEN='\033[0;32m' SET='\033[0m' @@ -52,12 +53,12 @@ colored_echo "6: 3G/4G Base HAT" read shield_hat case $shield_hat in - 1) colored_echo "You chose GSM/GPRS Shield";; - 2) colored_echo "You chose Base Shield";; - 3) colored_echo "You chose CellularIoT Shield";; - 4) colored_echo "You chose CellularIoT HAT";; - 5) colored_echo "You chose Tracker HAT";; - 6) colored_echo "You chose 3G/4G Base HAT";; + 1) colored_echo "You chose GSM/GPRS Shield" ${GREEN};; + 2) colored_echo "You chose Base Shield" ${GREEN};; + 3) colored_echo "You chose CellularIoT Shield" ${GREEN};; + 4) colored_echo "You chose CellularIoT HAT" ${GREEN};; + 5) colored_echo "You chose Tracker HAT" ${GREEN};; + 6) colored_echo "You chose 3G/4G Base HAT" ${GREEN};; *) colored_echo "Wrong Selection, exiting" ${RED}; exit 1; esac @@ -65,16 +66,17 @@ colored_echo "Checking requiremments..." colored_echo "Installing python3 if it is required..." if ! [ -x "$(command -v python3)" ]; then - sudo apt-get install python3 -y >/dev/null + sudo apt-get install python3 -y fi colored_echo "Installing pip3 if it is required..." if ! [ -x "$(command -v pip3)" ]; then - sudo apt-get install python3-pip -y >/dev/null + sudo apt-get install python3-pip -y fi colored_echo "Installing or upgrading atcom if it is required..." -pip3 install -U atcom && source ~/.profile +pip3 install -U atcom +source ~/.profile colored_echo "Downloading setup files..." @@ -94,20 +96,31 @@ apt-get install ppp wiringpi -y colored_echo "What is your carrier APN?" read carrierapn +colored_echo "Your Input is : $carrierapn" ${GREEN} + while [ 1 ] do colored_echo "Does your carrier need username and password? [Y/n]" read usernpass + colored_echo "You chose $usernpass" ${GREEN} + case $usernpass in - [Yy]* ) while [ 1 ] + [Yy]* ) + + while [ 1 ] do colored_echo "Enter username" read username + colored_echo "Your Input is : $username" ${GREEN} + colored_echo "Enter password" read password + + colored_echo "Your Input is : $password" ${GREEN} + sed -i "s/noauth/#noauth\nuser \"$username\"\npassword \"$password\"/" provider break done @@ -122,6 +135,8 @@ done colored_echo "What is your device communication PORT? (ttyS0/ttyUSB3/etc.)" read devicename +colored_echo "Your input is: $devicename" ${GREEN} + mkdir -p /etc/chatscripts mv chat-connect /etc/chatscripts/ @@ -147,6 +162,8 @@ do colored_echo "Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n]" read auto_reconnect + colored_echo "You chose $auto_reconnect" ${GREEN} + case $auto_reconnect in [Yy]* ) colored_echo "Downloading setup file..." @@ -217,4 +234,6 @@ do done read -p "Press ENTER key to reboot" ENTER + +colored_echo "Rebooting..." ${GREEN} reboot From c037d1e5f405623474255c77570013db3c574a34 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 25 Nov 2020 17:06:15 +0300 Subject: [PATCH 24/49] Added new preventions to provide robust installation --- install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/install.sh b/install.sh index ea8ee18..cbac3cb 100755 --- a/install.sh +++ b/install.sh @@ -67,16 +67,22 @@ colored_echo "Checking requiremments..." colored_echo "Installing python3 if it is required..." if ! [ -x "$(command -v python3)" ]; then sudo apt-get install python3 -y + if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi fi colored_echo "Installing pip3 if it is required..." if ! [ -x "$(command -v pip3)" ]; then sudo apt-get install python3-pip -y + if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi fi colored_echo "Installing or upgrading atcom if it is required..." + pip3 install -U atcom +if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi + source ~/.profile +if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi colored_echo "Downloading setup files..." @@ -92,6 +98,7 @@ if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi colored_echo "ppp and wiringpi (gpio tool) installing..." apt-get install ppp wiringpi -y +if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi colored_echo "What is your carrier APN?" read carrierapn From 492fb87636c723b16bbd90685e556641e87977a0 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 25 Nov 2020 17:09:14 +0300 Subject: [PATCH 25/49] fixed apt header bug --- install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.sh b/install.sh index cbac3cb..ea944cd 100755 --- a/install.sh +++ b/install.sh @@ -64,6 +64,9 @@ esac colored_echo "Checking requiremments..." +colored_echo "Updating headers..." +sudo apt-get update + colored_echo "Installing python3 if it is required..." if ! [ -x "$(command -v python3)" ]; then sudo apt-get install python3 -y From d78caf5054088a71f14f8de7fff3e3b08b02ae6b Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Wed, 25 Nov 2020 17:11:58 +0300 Subject: [PATCH 26/49] fixed typo --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index ea944cd..3b7e98d 100755 --- a/install.sh +++ b/install.sh @@ -62,7 +62,7 @@ case $shield_hat in *) colored_echo "Wrong Selection, exiting" ${RED}; exit 1; esac -colored_echo "Checking requiremments..." +colored_echo "Checking requirements..." colored_echo "Updating headers..." sudo apt-get update From 76fe62a8625bb6fa5c5ca76973a181117689456d Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 26 Nov 2020 01:50:37 +0300 Subject: [PATCH 27/49] Added powerup mechansm to configure_modem.sh --- install.sh | 34 ++++++++++++++ src/configure_modem.sh | 46 +++++++++++++++++++ src/reconnect_scripts/reconnect_cellulariot | 1 + .../reconnect_cellulariot_app | 1 + src/reconnect_scripts/reconnect_gprsshield | 1 + src/reconnect_scripts/reconnect_tracker | 1 + 6 files changed, 84 insertions(+) diff --git a/install.sh b/install.sh index 3b7e98d..566b75b 100755 --- a/install.sh +++ b/install.sh @@ -17,6 +17,20 @@ BLUE='\033[1;34m' GREEN='\033[0;32m' SET='\033[0m' +# Global Varibales +POWERUP_REQ=1 +POWERUP_NOT_REQ=0 + +STATUS_GPRS=19 +STATUS_CELL_IOT_APP=20 +STATUS_CELL_IOT=23 +STATUS_TRACKER=23 + +POWERKEY_GPRS=26 +POWERKEY_CELL_IOT_APP=11 +POWERKEY_CELL_IOT=24 +POWERKEY_TRACKER=24 + function colored_echo { @@ -197,32 +211,52 @@ do wget --no-check-certificate $SCRIPT_PATH/reconnect_gprsshield -O $RECONNECT_SCRIPT_NAME if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + + sed -i "s/STATUS_PIN/$STATUS_GPRS/" configure_modem.sh + sed -i "s/POWERKEY_PIN/$POWERKEY_GPRS/" configure_modem.sh + sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh elif [ $shield_hat -eq 2 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_baseshield -O $RECONNECT_SCRIPT_NAME if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + + sed -i "s/POWERUP_FLAG/$POWERUP_NOT_REQ/" configure_modem.sh elif [ $shield_hat -eq 3 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot_app -O $RECONNECT_SCRIPT_NAME if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + + sed -i "s/STATUS_PIN/$STATUS_CELL_IOT_APP/" configure_modem.sh + sed -i "s/POWERKEY_PIN/$POWERKEY_CELL_IOT_APP/" configure_modem.sh + sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh elif [ $shield_hat -eq 4 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + + sed -i "s/STATUS_PIN/$STATUS_CELL_IOT/" configure_modem.sh + sed -i "s/POWERKEY_PIN/$POWERKEY_CELL_IOT/" configure_modem.sh + sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh elif [ $shield_hat -eq 5 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_tracker -O $RECONNECT_SCRIPT_NAME if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + sed -i "s/STATUS_PIN/$STATUS_TRACKER/" configure_modem.sh + sed -i "s/POWERKEY_PIN/$POWERKEY_TRACKER/" configure_modem.sh + sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh + elif [ $shield_hat -eq 6 ]; then wget --no-check-certificate $SCRIPT_PATH/reconnect_basehat -O $RECONNECT_SCRIPT_NAME if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + sed -i "s/POWERUP_FLAG/$POWERUP_NOT_REQ/" configure_modem.sh + fi mv functions.sh $PPP_PATH diff --git a/src/configure_modem.sh b/src/configure_modem.sh index 2196842..bc72afd 100644 --- a/src/configure_modem.sh +++ b/src/configure_modem.sh @@ -2,6 +2,46 @@ source functions.sh +# default pins set for cellulariot hat +STATUS=${STATUS_PIN:-23} +POWERKEY=${POWERKEY_PIN:-24} +POWER_UP_REQUIRED=${POWERUP_FLAG:-1} + +# 1 : STATUS +# 2 : POWERKEY +function power_up_module +{ + # Configure pins + gpio -g mode $STATUS in + gpio -g mode $POWERKEY out + + for i in {1..20}; do + if [[ $(gpio -g read $STATUS) -eq 1 ]]; then + debug "Module is powering up..." + + gpio -g write $POWERKEY 0 + gpio -g write $POWERKEY 1 + sleep 2 + gpio -g write $POWERKEY 0 + sleep 2 + + if [[ $(gpio -g read $STATUS) -eq 0 ]]; then + debug "Module is powered up." + return 0 + break + else + debug "Module couldn't be powered up!" + sleep 2 + fi + else + debug "Module is just powered up." + return 0 + break + fi + done + return 1 +} + # Check the vendor lsusb | grep Quectel >> /dev/null IS_QUECTEL=$? @@ -10,6 +50,12 @@ lsusb | grep Telit >> /dev/null IS_TELIT=$? +if [[ $POWER_UP_REQUIRED -eq 1 ]]; then + if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi +else + debug "Power up is not required." +fi + ### Modem configuration for RMNET/PPP mode ################################## debug "Checking APN and Modem Mode..." diff --git a/src/reconnect_scripts/reconnect_cellulariot b/src/reconnect_scripts/reconnect_cellulariot index 52c9789..300d4ff 100644 --- a/src/reconnect_scripts/reconnect_cellulariot +++ b/src/reconnect_scripts/reconnect_cellulariot @@ -32,6 +32,7 @@ function power_up_module() else debug "Module couldn't be powered up!" sleep 2 + fi else debug "Module is just powered up." return 0 diff --git a/src/reconnect_scripts/reconnect_cellulariot_app b/src/reconnect_scripts/reconnect_cellulariot_app index 69c4d6a..f2391f5 100644 --- a/src/reconnect_scripts/reconnect_cellulariot_app +++ b/src/reconnect_scripts/reconnect_cellulariot_app @@ -33,6 +33,7 @@ function power_up_module() else debug "Module couldn't be powered up!" sleep 2 + fi else debug "Module is just powered up." return 0 diff --git a/src/reconnect_scripts/reconnect_gprsshield b/src/reconnect_scripts/reconnect_gprsshield index 926d44a..ca12a04 100644 --- a/src/reconnect_scripts/reconnect_gprsshield +++ b/src/reconnect_scripts/reconnect_gprsshield @@ -33,6 +33,7 @@ function power_up_module() else debug "Module couldn't be powered up!" sleep 2 + fi else debug "Module is just powered up." return 0 diff --git a/src/reconnect_scripts/reconnect_tracker b/src/reconnect_scripts/reconnect_tracker index 33b8e32..cb78212 100644 --- a/src/reconnect_scripts/reconnect_tracker +++ b/src/reconnect_scripts/reconnect_tracker @@ -33,6 +33,7 @@ function power_up_module() else debug "Module couldn't be powered up!" sleep 2 + fi else debug "Module is just powered up." return 0 From 77fe6ab6d416421d344bad4f457146565df77f46 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 26 Nov 2020 02:09:42 +0300 Subject: [PATCH 28/49] fixed viringpi issue --- install.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/install.sh b/install.sh index 566b75b..f3d61fe 100755 --- a/install.sh +++ b/install.sh @@ -117,6 +117,14 @@ colored_echo "ppp and wiringpi (gpio tool) installing..." apt-get install ppp wiringpi -y if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi +# test wiringpi and fix if there is any issue +gpio readall | grep Oops > /dev/null +if [[ $? -ne 1 ]]; then + colored_echo "Known wiringpi issue is detected! Wiringpi is updating..." + wget https://project-downloads.drogon.net/wiringpi-latest.deb + sudo dpkg -i wiringpi-latest.deb +fi + colored_echo "What is your carrier APN?" read carrierapn From cb81caf18fe245ab9d8be1f91b4945ccbba37794 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 26 Nov 2020 11:17:07 +0000 Subject: [PATCH 29/49] Fixed powerup and detecting module issue on BG9X --- src/configure_modem.sh | 34 ++++++++++++++++++---------------- src/functions.sh | 16 +++++++++++----- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/configure_modem.sh b/src/configure_modem.sh index bc72afd..3975f81 100644 --- a/src/configure_modem.sh +++ b/src/configure_modem.sh @@ -7,6 +7,9 @@ STATUS=${STATUS_PIN:-23} POWERKEY=${POWERKEY_PIN:-24} POWER_UP_REQUIRED=${POWERUP_FLAG:-1} +# default arguments +APN=${SIM_APN:-super} + # 1 : STATUS # 2 : POWERKEY function power_up_module @@ -23,7 +26,7 @@ function power_up_module gpio -g write $POWERKEY 1 sleep 2 gpio -g write $POWERKEY 0 - sleep 2 + sleep 5 if [[ $(gpio -g read $STATUS) -eq 0 ]]; then debug "Module is powered up." @@ -42,14 +45,6 @@ function power_up_module return 1 } -# Check the vendor -lsusb | grep Quectel >> /dev/null -IS_QUECTEL=$? - -lsusb | grep Telit >> /dev/null -IS_TELIT=$? - - if [[ $POWER_UP_REQUIRED -eq 1 ]]; then if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi else @@ -61,13 +56,20 @@ debug "Checking APN and Modem Mode..." # APN Configuration # ----------------- -atcom "AT+CGDCONT?" | grep super >> /dev/null +atcom "AT+CGDCONT?" | grep $APN > /dev/null if [[ $? -ne 0 ]]; then - atcom "AT+CGDCONT=1,\"IPV4V6\",\"super\"" + atcom "AT+CGDCONT=1,\"IPV4V6\",\"$APN\"" debug "APN is updated." fi +# Check the vendor +lsusb | grep Quectel >> /dev/null +IS_QUECTEL=$? + +lsusb | grep Telit >> /dev/null +IS_TELIT=$? + # Modem Mode Configuration # ------------------------ # For Quectel @@ -80,7 +82,7 @@ if [[ $IS_QUECTEL -eq 0 ]]; then # BG95 and BG96 # RAT Searching Sequence - atcom "AT+QCFG=\"nwscanseq\"" | grep 000201 >> /dev/null + atcom "AT+QCFG=\"nwscanseq\"" | grep 020301 > /dev/null if [[ $? -ne 0 ]]; then atcom "AT+QCFG=\"nwscanseq\",00" @@ -88,7 +90,7 @@ if [[ $IS_QUECTEL -eq 0 ]]; then fi # RAT(s) to be Searched - atcom "AT+QCFG=\"nwscanmode\"" | grep 0 >> /dev/null + atcom "AT+QCFG=\"nwscanmode\"" | grep 0 > /dev/null if [[ $? -ne 0 ]]; then atcom "AT+QCFG=\"nwscanmode\",0" @@ -96,7 +98,7 @@ if [[ $IS_QUECTEL -eq 0 ]]; then fi # Network Category to be Searched under LTE RAT - atcom "AT+QCFG=\"iotopmode\"" | grep 0 >> /dev/null + atcom "AT+QCFG=\"iotopmode\"" | grep 0 > /dev/null if [[ $? -ne 0 ]]; then atcom "AT+QCFG=\"iotopmode\",0" @@ -106,7 +108,7 @@ if [[ $IS_QUECTEL -eq 0 ]]; then # end of configuraiton for BG95/6 else # EC25 or derives. - atcom "AT+QCFG=\"usbnet\"" | grep 0 >> /dev/null + atcom "AT+QCFG=\"usbnet\"" | grep 0 > /dev/null if [[ $? -ne 0 ]]; then atcom "AT+QCFG=\"usbnet\",0" @@ -170,7 +172,7 @@ else debug "The cellular module couldn't be detected!" exit 1 fi -### End of Modem configuration for ECM mode ############################ +### End of Modem configuration for RMNET/PPP mode ############################ # Check the network is ready diff --git a/src/functions.sh b/src/functions.sh index 6bf19b1..8f4c418 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -24,29 +24,35 @@ function check_network() for i in {1..$NETWORK_CHECK_TIMEOUT}; do NETWORK_OK=0 - debug "SIM Status:" + debug "SIM Status: " "-n" # no line break atcom AT+CPIN? | grep "CPIN: READY" SIM_READY=$? - debug "Network Registeration Status:" + if [[ $SIM_READY -ne 0 ]]; then atcom AT+CPIN? | grep "CPIN:"; fi + + + debug "Network Registeration Status: " "-n" # no line break # For super SIM - atcom AT+CREG? | grep "CREG: 0,5" + atcom AT+CREG? | grep "CREG: 0,5" > /dev/null NETWORK_REG=$? # For native SIM - atcom AT+CREG? | grep "CREG: 0,1" + atcom AT+CREG? | grep "CREG: 0,1" > /dev/null NETWORK_REG_2=$? # Combined network registeration status NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) + if [[ $NETWORK_REG -ne 0 ]] || [[ $NETWORK_REG_2 -ne 0 ]]; then atcom AT+CREG? | grep "CREG:"; fi + if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then debug "Network is ready." NETWORK_OK=1 return 0 break else - printf "?" + debug "Retrying network registeration..." fi sleep 2 done + debug "Retwork registeration is failed! Please check SIM card, data plan, antennas etc." return 1 } From b53f7ffcbf7899f9638ee607ca276d0144a1b431 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 26 Nov 2020 11:20:04 +0000 Subject: [PATCH 30/49] added APN config for configure_modem.sh to install.sh --- install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.sh b/install.sh index f3d61fe..7937b01 100755 --- a/install.sh +++ b/install.sh @@ -214,6 +214,8 @@ do wget --no-check-certificate $SOURCE_PATH/$MANAGER_SCRIPT_NAME if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi + # APN Configuration + sed -i "s/SIM_APN/$carrierapn/" configure_modem.sh if [ $shield_hat -eq 1 ]; then @@ -223,6 +225,7 @@ do sed -i "s/STATUS_PIN/$STATUS_GPRS/" configure_modem.sh sed -i "s/POWERKEY_PIN/$POWERKEY_GPRS/" configure_modem.sh sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh + elif [ $shield_hat -eq 2 ]; then From 763b8c6802393235e8681987179ef374184d67d2 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 26 Nov 2020 11:22:36 +0000 Subject: [PATCH 31/49] Changed power up sleep time to fix power up issue on reconnect scripts --- src/reconnect_scripts/reconnect_cellulariot | 2 +- src/reconnect_scripts/reconnect_cellulariot_app | 2 +- src/reconnect_scripts/reconnect_gprsshield | 2 +- src/reconnect_scripts/reconnect_tracker | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/reconnect_scripts/reconnect_cellulariot b/src/reconnect_scripts/reconnect_cellulariot index 300d4ff..dce0948 100644 --- a/src/reconnect_scripts/reconnect_cellulariot +++ b/src/reconnect_scripts/reconnect_cellulariot @@ -23,7 +23,7 @@ function power_up_module() gpio -g write $POWERKEY 1 sleep 2 gpio -g write $POWERKEY 0 - sleep 2 + sleep 5 if [[ $(gpio -g read $STATUS) -eq 0 ]]; then debug "Module is powered up." diff --git a/src/reconnect_scripts/reconnect_cellulariot_app b/src/reconnect_scripts/reconnect_cellulariot_app index f2391f5..83173c8 100644 --- a/src/reconnect_scripts/reconnect_cellulariot_app +++ b/src/reconnect_scripts/reconnect_cellulariot_app @@ -24,7 +24,7 @@ function power_up_module() gpio -g write $POWERKEY 1 sleep 2 gpio -g write $POWERKEY 0 - sleep 2 + sleep 5 if [[ $(gpio -g read $STATUS) -eq 0 ]]; then debug "Module is powered up." diff --git a/src/reconnect_scripts/reconnect_gprsshield b/src/reconnect_scripts/reconnect_gprsshield index ca12a04..50fbdec 100644 --- a/src/reconnect_scripts/reconnect_gprsshield +++ b/src/reconnect_scripts/reconnect_gprsshield @@ -24,7 +24,7 @@ function power_up_module() gpio -g write $POWERKEY 1 sleep 2 gpio -g write $POWERKEY 0 - sleep 2 + sleep 5 if [[ $(gpio -g read $STATUS) -eq 0 ]]; then debug "Module is powered up." diff --git a/src/reconnect_scripts/reconnect_tracker b/src/reconnect_scripts/reconnect_tracker index cb78212..11b2300 100644 --- a/src/reconnect_scripts/reconnect_tracker +++ b/src/reconnect_scripts/reconnect_tracker @@ -24,7 +24,7 @@ function power_up_module() gpio -g write $POWERKEY 1 sleep 2 gpio -g write $POWERKEY 0 - sleep 2 + sleep 5 if [[ $(gpio -g read $STATUS) -eq 0 ]]; then debug "Module is powered up." From e0c6edf84776f357c5e43db8ded9313081696a21 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 26 Nov 2020 12:59:34 +0000 Subject: [PATCH 32/49] Fixed network reg. problem on ppp_connection_manager --- src/configs.sh | 2 +- src/configure_modem.sh | 4 ++-- src/functions.sh | 13 +++++++------ src/ppp_connection_manager.sh | 7 +++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/configs.sh b/src/configs.sh index f127ae3..9f7cceb 100644 --- a/src/configs.sh +++ b/src/configs.sh @@ -3,4 +3,4 @@ INTERVAL=60 # Seconds, Interval between two connection check of internet DOUBLE_CHECK_WAIT=10 # Seconds, wait time for double check when the connection is down PING_TIMEOUT=9 # Seconds, Timeout of ping command -NETWORK_CHECK_TIMEOUT=300 # Count, Check network for ($NETWORK_TIMEOUT x 2 Seconds) \ No newline at end of file +NETWORK_CHECK_TIMEOUT=150 # Count, Check network for ($NETWORK_TIMEOUT x 2 Seconds) \ No newline at end of file diff --git a/src/configure_modem.sh b/src/configure_modem.sh index 3975f81..3d3b251 100644 --- a/src/configure_modem.sh +++ b/src/configure_modem.sh @@ -52,7 +52,7 @@ else fi ### Modem configuration for RMNET/PPP mode ################################## -debug "Checking APN and Modem Mode..." +debug "Checking APN and Modem Modem..." # APN Configuration # ----------------- @@ -177,5 +177,5 @@ fi # Check the network is ready # -------------------------- -if check_network -eq 0; then exit 0; else debug "Network registeration is failed!"; exit 1; fi +if check_network -eq 0; then exit 0; else debug "Network registeration is failed!. Modem configuration is unsuccesfully ended!"; exit 1; fi diff --git a/src/functions.sh b/src/functions.sh index 8f4c418..035f191 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -21,7 +21,7 @@ function check_network() # Check the network is ready debug "Checking the network is ready..." - for i in {1..$NETWORK_CHECK_TIMEOUT}; do + for n in $(seq 1 $NETWORK_CHECK_TIMEOUT); do NETWORK_OK=0 debug "SIM Status: " "-n" # no line break @@ -32,17 +32,18 @@ function check_network() debug "Network Registeration Status: " "-n" # no line break + NR_TEXT=`atcom AT+CREG? | grep "CREG:"` + echo $NR_TEXT + # For super SIM - atcom AT+CREG? | grep "CREG: 0,5" > /dev/null + echo $NR_TEXT | grep "CREG: 0,5" > /dev/null NETWORK_REG=$? # For native SIM - atcom AT+CREG? | grep "CREG: 0,1" > /dev/null + echo $NR_TEXT | grep "CREG: 0,1" > /dev/null NETWORK_REG_2=$? # Combined network registeration status NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2)) - if [[ $NETWORK_REG -ne 0 ]] || [[ $NETWORK_REG_2 -ne 0 ]]; then atcom AT+CREG? | grep "CREG:"; fi - if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then debug "Network is ready." NETWORK_OK=1 @@ -53,6 +54,6 @@ function check_network() fi sleep 2 done - debug "Retwork registeration is failed! Please check SIM card, data plan, antennas etc." + debug "Network registeration is failed! Please check SIM card, data plan, antennas etc." return 1 } diff --git a/src/ppp_connection_manager.sh b/src/ppp_connection_manager.sh index 80d05af..43fa8bb 100644 --- a/src/ppp_connection_manager.sh +++ b/src/ppp_connection_manager.sh @@ -12,14 +12,13 @@ else debug "Log folder is created." fi -for i in {1..120}; do +for i in {1..4}; do bash configure_modem.sh |& sudo tee -a ./logs/$LOG_FILE_NAME.log - MODEM_CONFIG=$? + MODEM_CONFIG=${PIPESTATUS[0]} # compatible with only bash if [[ $MODEM_CONFIG -eq 0 ]]; then break fi - sleep 1 done @@ -27,6 +26,6 @@ if [[ $MODEM_CONFIG -eq 0 ]]; then bash ppp_reconnect.sh |& sudo tee -a ./logs/$LOG_FILE_NAME.log else debug "Modem configuration is failed multiple times!" - debug "Checkout other troubleshooting step on docs.sixfab.com." + debug "Checkout other troubleshooting steps on docs.sixfab.com." exit 1 fi From 0f93aaa4a198006487ccf5331c68c288d6621637 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 26 Nov 2020 13:51:56 +0000 Subject: [PATCH 33/49] Added checking ppp is default route to service scripts --- src/reconnect_scripts/reconnect_basehat | 10 +++++ src/reconnect_scripts/reconnect_baseshield | 10 +++++ src/reconnect_scripts/reconnect_cellulariot | 11 ++++++ .../reconnect_cellulariot_app | 10 +++++ src/reconnect_scripts/reconnect_gprsshield | 10 +++++ src/reconnect_scripts/reconnect_test.sh | 37 ------------------- src/reconnect_scripts/reconnect_tracker | 10 +++++ 7 files changed, 61 insertions(+), 37 deletions(-) delete mode 100644 src/reconnect_scripts/reconnect_test.sh diff --git a/src/reconnect_scripts/reconnect_basehat b/src/reconnect_scripts/reconnect_basehat index df682ff..9da6c33 100644 --- a/src/reconnect_scripts/reconnect_basehat +++ b/src/reconnect_scripts/reconnect_basehat @@ -18,6 +18,11 @@ gpio -g write $W_DISABLE 0 if check_network -eq 0; then debug "PPP chatscript is starting..."; sudo pon; + + # check default interface + route | grep ppp | grep default > /dev/null + PPP_IS_DEFAULT=$? + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi else debug "Network registeration is failed!"; fi @@ -42,6 +47,11 @@ while true; do debug "Connection is down, reconnecting..." if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi sudo pon + + # check default interface + route | grep ppp | grep default > /dev/null + PPP_IS_DEFAULT=$? + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi fi fi sleep $INTERVAL diff --git a/src/reconnect_scripts/reconnect_baseshield b/src/reconnect_scripts/reconnect_baseshield index 13fe285..7cd7b8c 100755 --- a/src/reconnect_scripts/reconnect_baseshield +++ b/src/reconnect_scripts/reconnect_baseshield @@ -6,6 +6,11 @@ source configs.sh if check_network -eq 0; then debug "PPP chatscript is starting..."; sudo pon; + + # check default interface + route | grep ppp | grep default > /dev/null + PPP_IS_DEFAULT=$? + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi else debug "Network registeration is failed!"; fi @@ -30,6 +35,11 @@ while true; do debug "Connection is down, reconnecting..." if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi sudo pon + + # check default interface + route | grep ppp | grep default > /dev/null + PPP_IS_DEFAULT=$? + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi fi fi sleep $INTERVAL diff --git a/src/reconnect_scripts/reconnect_cellulariot b/src/reconnect_scripts/reconnect_cellulariot index dce0948..a272dec 100644 --- a/src/reconnect_scripts/reconnect_cellulariot +++ b/src/reconnect_scripts/reconnect_cellulariot @@ -59,6 +59,12 @@ if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powere if check_network -eq 0; then debug "PPP chatscript is starting..."; sudo pon; + + # check default interface + route | grep ppp | grep default > /dev/null + PPP_IS_DEFAULT=$? + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi + else debug "Network registeration is failed!"; fi @@ -83,6 +89,11 @@ while true; do debug "Connection is down, reconnecting..." if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi sudo pon + + # check default interface + route | grep ppp | grep default > /dev/null + PPP_IS_DEFAULT=$? + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi fi fi sleep $INTERVAL diff --git a/src/reconnect_scripts/reconnect_cellulariot_app b/src/reconnect_scripts/reconnect_cellulariot_app index 83173c8..27100fc 100644 --- a/src/reconnect_scripts/reconnect_cellulariot_app +++ b/src/reconnect_scripts/reconnect_cellulariot_app @@ -60,6 +60,11 @@ if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powere if check_network -eq 0; then debug "PPP chatscript is starting..."; sudo pon; + + # check default interface + route | grep ppp | grep default > /dev/null + PPP_IS_DEFAULT=$? + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi else debug "Network registeration is failed!"; fi @@ -84,6 +89,11 @@ while true; do debug "Connection is down, reconnecting..." if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi sudo pon + + # check default interface + route | grep ppp | grep default > /dev/null + PPP_IS_DEFAULT=$? + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi fi fi sleep $INTERVAL diff --git a/src/reconnect_scripts/reconnect_gprsshield b/src/reconnect_scripts/reconnect_gprsshield index 50fbdec..a8fdb67 100644 --- a/src/reconnect_scripts/reconnect_gprsshield +++ b/src/reconnect_scripts/reconnect_gprsshield @@ -50,6 +50,11 @@ if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powere if check_network -eq 0; then debug "PPP chatscript is starting..."; sudo pon; + + # check default interface + route | grep ppp | grep default > /dev/null + PPP_IS_DEFAULT=$? + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi else debug "Network registeration is failed!"; fi @@ -74,6 +79,11 @@ while true; do debug "Connection is down, reconnecting..." if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi sudo pon + + # check default interface + route | grep ppp | grep default > /dev/null + PPP_IS_DEFAULT=$? + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi fi fi sleep $INTERVAL diff --git a/src/reconnect_scripts/reconnect_test.sh b/src/reconnect_scripts/reconnect_test.sh deleted file mode 100644 index c0a50ad..0000000 --- a/src/reconnect_scripts/reconnect_test.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -source functions.sh -source configs.sh - - -if check_network -eq 0; then - debug "PPP chatscript is starting..."; - sudo pon; -else - debug "Network registeration is failed!"; -fi - -while true; do - # Checking cellular internet connection - ping -q -c 1 -s 0 -w $PING_TIMEOUT -I ppp0 8.8.8.8 > /dev/null 2>&1 - PINGG=$? - - 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=$? - - 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 -done diff --git a/src/reconnect_scripts/reconnect_tracker b/src/reconnect_scripts/reconnect_tracker index 11b2300..451c4fe 100644 --- a/src/reconnect_scripts/reconnect_tracker +++ b/src/reconnect_scripts/reconnect_tracker @@ -60,6 +60,11 @@ if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powere if check_network -eq 0; then debug "PPP chatscript is starting..."; sudo pon; + + # check default interface + route | grep ppp | grep default > /dev/null + PPP_IS_DEFAULT=$? + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi else debug "Network registeration is failed!"; fi @@ -84,6 +89,11 @@ while true; do debug "Connection is down, reconnecting..." if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi sudo pon + + # check default interface + route | grep ppp | grep default > /dev/null + PPP_IS_DEFAULT=$? + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi fi fi sleep $INTERVAL From ed281a616ef84ee3e23d803ff01b70942ac88bce Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 26 Nov 2020 14:02:00 +0000 Subject: [PATCH 34/49] fiex typo --- src/reconnect_scripts/reconnect_basehat | 4 ++-- src/reconnect_scripts/reconnect_baseshield | 4 ++-- src/reconnect_scripts/reconnect_cellulariot | 4 ++-- src/reconnect_scripts/reconnect_cellulariot_app | 4 ++-- src/reconnect_scripts/reconnect_gprsshield | 5 ++--- src/reconnect_scripts/reconnect_tracker | 4 ++-- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/reconnect_scripts/reconnect_basehat b/src/reconnect_scripts/reconnect_basehat index 9da6c33..6593766 100644 --- a/src/reconnect_scripts/reconnect_basehat +++ b/src/reconnect_scripts/reconnect_basehat @@ -22,7 +22,7 @@ if check_network -eq 0; then # check default interface route | grep ppp | grep default > /dev/null PPP_IS_DEFAULT=$? - if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi else debug "Network registeration is failed!"; fi @@ -51,7 +51,7 @@ while true; do # check default interface route | grep ppp | grep default > /dev/null PPP_IS_DEFAULT=$? - if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi fi fi sleep $INTERVAL diff --git a/src/reconnect_scripts/reconnect_baseshield b/src/reconnect_scripts/reconnect_baseshield index 7cd7b8c..00f80c7 100755 --- a/src/reconnect_scripts/reconnect_baseshield +++ b/src/reconnect_scripts/reconnect_baseshield @@ -10,7 +10,7 @@ if check_network -eq 0; then # check default interface route | grep ppp | grep default > /dev/null PPP_IS_DEFAULT=$? - if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi else debug "Network registeration is failed!"; fi @@ -39,7 +39,7 @@ while true; do # check default interface route | grep ppp | grep default > /dev/null PPP_IS_DEFAULT=$? - if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi fi fi sleep $INTERVAL diff --git a/src/reconnect_scripts/reconnect_cellulariot b/src/reconnect_scripts/reconnect_cellulariot index a272dec..0436f42 100644 --- a/src/reconnect_scripts/reconnect_cellulariot +++ b/src/reconnect_scripts/reconnect_cellulariot @@ -63,7 +63,7 @@ if check_network -eq 0; then # check default interface route | grep ppp | grep default > /dev/null PPP_IS_DEFAULT=$? - if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi else debug "Network registeration is failed!"; @@ -93,7 +93,7 @@ while true; do # check default interface route | grep ppp | grep default > /dev/null PPP_IS_DEFAULT=$? - if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi fi fi sleep $INTERVAL diff --git a/src/reconnect_scripts/reconnect_cellulariot_app b/src/reconnect_scripts/reconnect_cellulariot_app index 27100fc..d62c779 100644 --- a/src/reconnect_scripts/reconnect_cellulariot_app +++ b/src/reconnect_scripts/reconnect_cellulariot_app @@ -64,7 +64,7 @@ if check_network -eq 0; then # check default interface route | grep ppp | grep default > /dev/null PPP_IS_DEFAULT=$? - if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi else debug "Network registeration is failed!"; fi @@ -93,7 +93,7 @@ while true; do # check default interface route | grep ppp | grep default > /dev/null PPP_IS_DEFAULT=$? - if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi fi fi sleep $INTERVAL diff --git a/src/reconnect_scripts/reconnect_gprsshield b/src/reconnect_scripts/reconnect_gprsshield index a8fdb67..a630ff2 100644 --- a/src/reconnect_scripts/reconnect_gprsshield +++ b/src/reconnect_scripts/reconnect_gprsshield @@ -43,7 +43,6 @@ function power_up_module() return 1 } - # Modem power up if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi @@ -54,7 +53,7 @@ if check_network -eq 0; then # check default interface route | grep ppp | grep default > /dev/null PPP_IS_DEFAULT=$? - if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi else debug "Network registeration is failed!"; fi @@ -83,7 +82,7 @@ while true; do # check default interface route | grep ppp | grep default > /dev/null PPP_IS_DEFAULT=$? - if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi fi fi sleep $INTERVAL diff --git a/src/reconnect_scripts/reconnect_tracker b/src/reconnect_scripts/reconnect_tracker index 451c4fe..8fb3a36 100644 --- a/src/reconnect_scripts/reconnect_tracker +++ b/src/reconnect_scripts/reconnect_tracker @@ -64,7 +64,7 @@ if check_network -eq 0; then # check default interface route | grep ppp | grep default > /dev/null PPP_IS_DEFAULT=$? - if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi else debug "Network registeration is failed!"; fi @@ -93,7 +93,7 @@ while true; do # check default interface route | grep ppp | grep default > /dev/null PPP_IS_DEFAULT=$? - if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually." fi + if [[ $PPP_IS_DEFAULT -ne 0 ]]; then sudo route add default ppp0; debug "ppp0 is added as default interface manually."; fi fi fi sleep $INTERVAL From 44f62e6c226d9887d3e88004f0ba4407b83b8028 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 26 Nov 2020 14:39:54 +0000 Subject: [PATCH 35/49] Added reset power and power up steps to conneciton recovery sequence --- src/reconnect_scripts/reconnect_cellulariot | 4 +++- src/reconnect_scripts/reconnect_cellulariot_app | 2 ++ src/reconnect_scripts/reconnect_tracker | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/reconnect_scripts/reconnect_cellulariot b/src/reconnect_scripts/reconnect_cellulariot index 0436f42..a6fed87 100644 --- a/src/reconnect_scripts/reconnect_cellulariot +++ b/src/reconnect_scripts/reconnect_cellulariot @@ -86,7 +86,9 @@ while true; do if [[ $PINGG -eq 0 ]]; then printf "+" else - debug "Connection is down, reconnecting..." + debug "Connection is down, reconnecting..." + restart_power + if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi sudo pon diff --git a/src/reconnect_scripts/reconnect_cellulariot_app b/src/reconnect_scripts/reconnect_cellulariot_app index d62c779..45963f2 100644 --- a/src/reconnect_scripts/reconnect_cellulariot_app +++ b/src/reconnect_scripts/reconnect_cellulariot_app @@ -87,6 +87,8 @@ while true; do printf "+" else debug "Connection is down, reconnecting..." + restart_power + if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi sudo pon diff --git a/src/reconnect_scripts/reconnect_tracker b/src/reconnect_scripts/reconnect_tracker index 8fb3a36..3cd3d01 100644 --- a/src/reconnect_scripts/reconnect_tracker +++ b/src/reconnect_scripts/reconnect_tracker @@ -87,6 +87,8 @@ while true; do printf "+" else debug "Connection is down, reconnecting..." + restart_power + if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi if check_network -eq 0; then sleep 0.1; else debug "Network registeration is failed!"; fi sudo pon From 7f9e5d3709bc694b98c3d9cd9512ed8727772725 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 26 Nov 2020 14:45:08 +0000 Subject: [PATCH 36/49] Deleted restart power functions at the beginning of scripts --- src/reconnect_scripts/reconnect_cellulariot | 2 +- src/reconnect_scripts/reconnect_cellulariot_app | 2 +- src/reconnect_scripts/reconnect_tracker | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/reconnect_scripts/reconnect_cellulariot b/src/reconnect_scripts/reconnect_cellulariot index a6fed87..be9d093 100644 --- a/src/reconnect_scripts/reconnect_cellulariot +++ b/src/reconnect_scripts/reconnect_cellulariot @@ -51,7 +51,7 @@ function restart_power() gpio -g write $ENABLE 0 # power is enabled } -restart_power # Restart power +#restart_power # Modem power up if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi diff --git a/src/reconnect_scripts/reconnect_cellulariot_app b/src/reconnect_scripts/reconnect_cellulariot_app index 45963f2..b1053f1 100644 --- a/src/reconnect_scripts/reconnect_cellulariot_app +++ b/src/reconnect_scripts/reconnect_cellulariot_app @@ -52,7 +52,7 @@ function restart_power() gpio -g write $DISABLE 1 # power is enabled } -restart_power # Restart power +#restart_power # Modem power up if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi diff --git a/src/reconnect_scripts/reconnect_tracker b/src/reconnect_scripts/reconnect_tracker index 3cd3d01..cda4543 100644 --- a/src/reconnect_scripts/reconnect_tracker +++ b/src/reconnect_scripts/reconnect_tracker @@ -52,7 +52,7 @@ function restart_power() gpio -g write $DISABLE 1 # power is enabled } -restart_power # Restart power +#restart_power # Modem power up if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi From e3a7715949151f34fd23abc20e3ce9e3e47ad512 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Thu, 26 Nov 2020 15:22:19 +0000 Subject: [PATCH 37/49] Added ttyS0 config for atcom to installer --- install.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/install.sh b/install.sh index 7937b01..e2d63f4 100755 --- a/install.sh +++ b/install.sh @@ -169,6 +169,17 @@ read devicename colored_echo "Your input is: $devicename" ${GREEN} +if grep -q "ttyS0" <<<"$devicename"; then + debug "Doing atcom configuration for ttyS0 serial..." + # create atcom config + echo port: "/dev/ttyS0" > configs.yml + mv configs.yml $PPP_PATH +else + # delete atcom config + ls $PPP_PATH | grep configs.yml > /dev/null + if [[ $? -eq 0 ]]; then rm $PPP_PATH/configs.yml; fi +fi + mkdir -p /etc/chatscripts mv chat-connect /etc/chatscripts/ From 69a94b0e73a1897a4c1a44a1d0c7b9c410fadcbb Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Fri, 27 Nov 2020 09:46:03 +0000 Subject: [PATCH 38/49] fixed bug on BG96 module connection --- src/chat-connect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chat-connect b/src/chat-connect index fcb6128..f25e9a5 100644 --- a/src/chat-connect +++ b/src/chat-connect @@ -8,7 +8,7 @@ TIMEOUT 30 "" AT OK ATE0 OK AT+CPIN? -READY AT+CSQ +OK AT+CSQ OK AT+CREG? OK AT+CGREG? OK AT+COPS? From 85f55031745524d9df28415a3386411ff3702866 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Fri, 27 Nov 2020 09:48:41 +0000 Subject: [PATCH 39/49] isnatll script is compatible with miniuart (ttyS0 port) --- install.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e2d63f4..4299b2f 100755 --- a/install.sh +++ b/install.sh @@ -170,7 +170,25 @@ read devicename colored_echo "Your input is: $devicename" ${GREEN} if grep -q "ttyS0" <<<"$devicename"; then - debug "Doing atcom configuration for ttyS0 serial..." + colored_echo "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-" ${BLUE} + colored_echo "REMINDER!" ${BLUE} + colored_echo "- Disable serial console and enable miniuart to use ttyS0 as the serial interface." ${SET} + colored_echo "✔ If your ttyS0 (miniuart) port is enabled, press ENTER and continue to installation." ${SET} + colored_echo "✘ If not, please follow the instructions to enable ttyS0 interface on Raspberry Pi" ${SET} + echo -e " + 1. Start raspi-config: ${BLUE}sudo raspi-config${SET}. + 2. Select option 3 - ${BLUE}Interface Options${SET}. + 3. Select option P6 - ${BLUE}Serial Port${SET}. + 4. ${BLUE}At the prompt Would you like a login shell to be accessible over serial?${SET} answer ${BLUE}'No'${SET} + 5. ${BLUE}At the prompt Would you like the serial port hardware to be enabled?${SET} answer ${BLUE}'Yes'${SET} + 6. Exit raspi-config and ${BLUE}reboot${SET} the Pi for changes to take effect. + " + colored_echo "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-" ${BLUE} + echo + echo -e "Press ${BLUE}ENTER${SET} key to continue to installation or press ${BLUE}CTRL^C${SET} to abort installation and enable ttyS0 serial interface." + read -p "" ENTER + + colored_echo "Doing atcom configuration for ttyS0 serial..." # create atcom config echo port: "/dev/ttyS0" > configs.yml mv configs.yml $PPP_PATH From 51908bc379ff3fe3b5595ebf4c6ad30136c28b07 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Fri, 27 Nov 2020 10:02:36 +0000 Subject: [PATCH 40/49] Arranged install.sh files --- ppp_install.sh | 303 ++++++++++++++++++ ...all_ppp_jetson.sh => ppp_install_jetson.sh | 0 install.sh => ppp_install_standalone.sh | 0 3 files changed, 303 insertions(+) create mode 100755 ppp_install.sh rename install_ppp_jetson.sh => ppp_install_jetson.sh (100%) rename install.sh => ppp_install_standalone.sh (100%) diff --git a/ppp_install.sh b/ppp_install.sh new file mode 100755 index 0000000..dc57091 --- /dev/null +++ b/ppp_install.sh @@ -0,0 +1,303 @@ +#!/bin/bash + +SIXFAB_PATH="/opt/sixfab" +PPP_PATH="/opt/sixfab/ppp_connection_manager" + +REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer" +BRANCH=revision +SOURCE_PATH="./src" +SCRIPT_PATH="./src/reconnect_scripts" +RECONNECT_SCRIPT_NAME="ppp_reconnect.sh" +MANAGER_SCRIPT_NAME="ppp_connection_manager.sh" +SERVICE_NAME="ppp_connection_manager.service" + +YELLOW='\033[1;33m' +RED='\033[0;31m' +BLUE='\033[1;34m' +GREEN='\033[0;32m' +SET='\033[0m' + +# Global Varibales +POWERUP_REQ=1 +POWERUP_NOT_REQ=0 + +STATUS_GPRS=19 +STATUS_CELL_IOT_APP=20 +STATUS_CELL_IOT=23 +STATUS_TRACKER=23 + +POWERKEY_GPRS=26 +POWERKEY_CELL_IOT_APP=11 +POWERKEY_CELL_IOT=24 +POWERKEY_TRACKER=24 + + +function colored_echo +{ + COLOR=${2:-$YELLOW} + echo -e "$COLOR $1 ${SET}" +} + + +# Check Sixfab path +if [[ -e $SIXFAB_PATH ]]; then + colored_echo "Sixfab path already exist!" ${SET} +else + sudo mkdir $SIXFAB_PATH + colored_echo "Sixfab path is created." ${SET} +fi + +# Check PPP path +if [[ -e $PPP_PATH ]]; then + colored_echo "PPP path already exist!" ${SET} +else + sudo mkdir $PPP_PATH + colored_echo "PPP path is created." ${SET} +fi + + +colored_echo "Please choose your Sixfab Shield/HAT:" +colored_echo "1: GSM/GPRS Shield" +colored_echo "2: 3G, 4G/LTE Base Shield" +colored_echo "3: Cellular IoT App Shield" +colored_echo "4: Cellular IoT HAT" +colored_echo "5: Tracker HAT" +colored_echo "6: 3G/4G Base HAT" + + +read shield_hat +case $shield_hat in + 1) colored_echo "You chose GSM/GPRS Shield" ${GREEN};; + 2) colored_echo "You chose Base Shield" ${GREEN};; + 3) colored_echo "You chose CellularIoT Shield" ${GREEN};; + 4) colored_echo "You chose CellularIoT HAT" ${GREEN};; + 5) colored_echo "You chose Tracker HAT" ${GREEN};; + 6) colored_echo "You chose 3G/4G Base HAT" ${GREEN};; + *) colored_echo "Wrong Selection, exiting" ${RED}; exit 1; +esac + +colored_echo "Checking requirements..." + +colored_echo "Updating headers..." +sudo apt-get update + +colored_echo "Installing python3 if it is required..." +if ! [ -x "$(command -v python3)" ]; then + sudo apt-get install python3 -y + if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi +fi + +colored_echo "Installing pip3 if it is required..." +if ! [ -x "$(command -v pip3)" ]; then + sudo apt-get install python3-pip -y + if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi +fi + +colored_echo "Installing or upgrading atcom if it is required..." + +pip3 install -U atcom +if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi + +source ~/.profile +if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi + + +colored_echo "Copying setup files..." + +cp $SOURCE_PATH/chat-connect -O chat-connect +cp $SOURCE_PATH/chat-disconnect -O chat-disconnect +cp $SOURCE_PATH/provider -O provider + +colored_echo "ppp and wiringpi (gpio tool) installing..." +apt-get install ppp wiringpi -y +if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi + +# test wiringpi and fix if there is any issue +gpio readall | grep Oops > /dev/null +if [[ $? -ne 1 ]]; then + colored_echo "Known wiringpi issue is detected! Wiringpi is updating..." + wget https://project-downloads.drogon.net/wiringpi-latest.deb + sudo dpkg -i wiringpi-latest.deb +fi + +colored_echo "What is your carrier APN?" +read carrierapn + +colored_echo "Your Input is : $carrierapn" ${GREEN} + +while [ 1 ] +do + colored_echo "Does your carrier need username and password? [Y/n]" + read usernpass + + colored_echo "You chose $usernpass" ${GREEN} + + case $usernpass in + [Yy]* ) + + while [ 1 ] + do + + colored_echo "Enter username" + read username + + colored_echo "Your Input is : $username" ${GREEN} + + colored_echo "Enter password" + read password + + colored_echo "Your Input is : $password" ${GREEN} + + sed -i "s/noauth/#noauth\nuser \"$username\"\npassword \"$password\"/" provider + break + done + + break;; + + [Nn]* ) break;; + *) colored_echo "Wrong Selection, Select among Y or n" ${RED};; + esac +done + +colored_echo "What is your device communication PORT? (ttyS0/ttyUSB3/etc.)" +read devicename + +colored_echo "Your input is: $devicename" ${GREEN} + +if grep -q "ttyS0" <<<"$devicename"; then + colored_echo "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-" ${BLUE} + colored_echo "REMINDER!" ${BLUE} + colored_echo "- Disable serial console and enable miniuart to use ttyS0 as the serial interface." ${SET} + colored_echo "✔ If your ttyS0 (miniuart) port is enabled, press ENTER and continue to installation." ${SET} + colored_echo "✘ If not, please follow the instructions to enable ttyS0 interface on Raspberry Pi" ${SET} + echo -e " + 1. Start raspi-config: ${BLUE}sudo raspi-config${SET}. + 2. Select option 3 - ${BLUE}Interface Options${SET}. + 3. Select option P6 - ${BLUE}Serial Port${SET}. + 4. ${BLUE}At the prompt Would you like a login shell to be accessible over serial?${SET} answer ${BLUE}'No'${SET} + 5. ${BLUE}At the prompt Would you like the serial port hardware to be enabled?${SET} answer ${BLUE}'Yes'${SET} + 6. Exit raspi-config and ${BLUE}reboot${SET} the Pi for changes to take effect. + " + colored_echo "*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-" ${BLUE} + echo + echo -e "Press ${BLUE}ENTER${SET} key to continue to installation or press ${BLUE}CTRL^C${SET} to abort installation and enable ttyS0 serial interface." + read -p "" ENTER + + colored_echo "Doing atcom configuration for ttyS0 serial..." + # create atcom config + echo port: "/dev/ttyS0" > configs.yml + mv configs.yml $PPP_PATH +else + # delete atcom config + ls $PPP_PATH | grep configs.yml > /dev/null + if [[ $? -eq 0 ]]; then rm $PPP_PATH/configs.yml; fi +fi + +mkdir -p /etc/chatscripts + +mv chat-connect /etc/chatscripts/ +mv chat-disconnect /etc/chatscripts/ + +mkdir -p /etc/ppp/peers +sed -i "s/#APN/$carrierapn/" provider +sed -i "s/#DEVICE/$devicename/" provider +mv provider /etc/ppp/peers/provider + +if ! (grep -q 'sudo route' /etc/ppp/ip-up ); then + echo "sudo route add default ppp0" >> /etc/ppp/ip-up +fi + +if [[ $shield_hat -eq 2 ]] || [[ $shield_hat -eq 6 ]]; then + if ! (grep -q 'max_usb_current' /boot/config.txt ); then + echo "max_usb_current=1" >> /boot/config.txt + fi +fi + +while [ 1 ] +do + colored_echo "Do you want to activate auto connect/reconnect service at R.Pi boot up? [Y/n]" + read auto_reconnect + + colored_echo "You chose $auto_reconnect" ${GREEN} + + case $auto_reconnect in + [Yy]* ) colored_echo "Copying setup file..." + + cp $SOURCE_PATH/$SERVICE_NAME + cp $SOURCE_PATH/functions.sh + cp $SOURCE_PATH/configs.sh + cp $SOURCE_PATH/configure_modem.sh + cp $SOURCE_PATH/$MANAGER_SCRIPT_NAME + + # APN Configuration + sed -i "s/SIM_APN/$carrierapn/" configure_modem.sh + + if [ $shield_hat -eq 1 ]; then + + cp $SCRIPT_PATH/reconnect_gprsshield -O $RECONNECT_SCRIPT_NAME + + sed -i "s/STATUS_PIN/$STATUS_GPRS/" configure_modem.sh + sed -i "s/POWERKEY_PIN/$POWERKEY_GPRS/" configure_modem.sh + sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh + + + elif [ $shield_hat -eq 2 ]; then + + cp $SCRIPT_PATH/reconnect_baseshield -O $RECONNECT_SCRIPT_NAME + + sed -i "s/POWERUP_FLAG/$POWERUP_NOT_REQ/" configure_modem.sh + + elif [ $shield_hat -eq 3 ]; then + + cp $SCRIPT_PATH/reconnect_cellulariot_app -O $RECONNECT_SCRIPT_NAME + + sed -i "s/STATUS_PIN/$STATUS_CELL_IOT_APP/" configure_modem.sh + sed -i "s/POWERKEY_PIN/$POWERKEY_CELL_IOT_APP/" configure_modem.sh + sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh + + elif [ $shield_hat -eq 4 ]; then + + cp $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME + + sed -i "s/STATUS_PIN/$STATUS_CELL_IOT/" configure_modem.sh + sed -i "s/POWERKEY_PIN/$POWERKEY_CELL_IOT/" configure_modem.sh + sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh + + elif [ $shield_hat -eq 5 ]; then + + cp $SCRIPT_PATH/reconnect_tracker -O $RECONNECT_SCRIPT_NAME + + sed -i "s/STATUS_PIN/$STATUS_TRACKER/" configure_modem.sh + sed -i "s/POWERKEY_PIN/$POWERKEY_TRACKER/" configure_modem.sh + sed -i "s/POWERUP_FLAG/$POWERUP_REQ/" configure_modem.sh + + elif [ $shield_hat -eq 6 ]; then + + cp $SCRIPT_PATH/reconnect_basehat -O $RECONNECT_SCRIPT_NAME + + sed -i "s/POWERUP_FLAG/$POWERUP_NOT_REQ/" configure_modem.sh + + fi + + mv functions.sh $PPP_PATH + mv configs.sh $PPP_PATH + mv configure_modem.sh $PPP_PATH + mv $RECONNECT_SCRIPT_NAME $PPP_PATH + mv $MANAGER_SCRIPT_NAME $PPP_PATH + mv $SERVICE_NAME /etc/systemd/system/ + + systemctl daemon-reload + systemctl enable $SERVICE_NAME + + break;; + + [Nn]* ) echo -e "${YELLOW}To connect to internet run ${BLUE}\"sudo pon\"${YELLOW} and to disconnect run ${BLUE}\"sudo poff\" ${SET}" + break;; + *) colored_echo "Wrong Selection, Select among Y or n" ${RED};; + esac +done + +read -p "Press ENTER key to reboot" ENTER + +colored_echo "Rebooting..." ${GREEN} +reboot diff --git a/install_ppp_jetson.sh b/ppp_install_jetson.sh similarity index 100% rename from install_ppp_jetson.sh rename to ppp_install_jetson.sh diff --git a/install.sh b/ppp_install_standalone.sh similarity index 100% rename from install.sh rename to ppp_install_standalone.sh From 30f0a1d48bea23120959ee8e39b53e4eec08f066 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Fri, 27 Nov 2020 10:07:47 +0000 Subject: [PATCH 41/49] fixed typo --- ppp_install.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ppp_install.sh b/ppp_install.sh index dc57091..baf6989 100755 --- a/ppp_install.sh +++ b/ppp_install.sh @@ -104,9 +104,9 @@ if [[ $? -ne 0 ]]; then colored_echo "Process failed" ${RED}; exit 1; fi colored_echo "Copying setup files..." -cp $SOURCE_PATH/chat-connect -O chat-connect -cp $SOURCE_PATH/chat-disconnect -O chat-disconnect -cp $SOURCE_PATH/provider -O provider +cp $SOURCE_PATH/chat-connect chat-connect +cp $SOURCE_PATH/chat-disconnect chat-disconnect +cp $SOURCE_PATH/provider provider colored_echo "ppp and wiringpi (gpio tool) installing..." apt-get install ppp wiringpi -y @@ -234,7 +234,7 @@ do if [ $shield_hat -eq 1 ]; then - cp $SCRIPT_PATH/reconnect_gprsshield -O $RECONNECT_SCRIPT_NAME + cp $SCRIPT_PATH/reconnect_gprsshield $RECONNECT_SCRIPT_NAME sed -i "s/STATUS_PIN/$STATUS_GPRS/" configure_modem.sh sed -i "s/POWERKEY_PIN/$POWERKEY_GPRS/" configure_modem.sh @@ -243,13 +243,13 @@ do elif [ $shield_hat -eq 2 ]; then - cp $SCRIPT_PATH/reconnect_baseshield -O $RECONNECT_SCRIPT_NAME + cp $SCRIPT_PATH/reconnect_baseshield $RECONNECT_SCRIPT_NAME sed -i "s/POWERUP_FLAG/$POWERUP_NOT_REQ/" configure_modem.sh elif [ $shield_hat -eq 3 ]; then - cp $SCRIPT_PATH/reconnect_cellulariot_app -O $RECONNECT_SCRIPT_NAME + cp $SCRIPT_PATH/reconnect_cellulariot_app $RECONNECT_SCRIPT_NAME sed -i "s/STATUS_PIN/$STATUS_CELL_IOT_APP/" configure_modem.sh sed -i "s/POWERKEY_PIN/$POWERKEY_CELL_IOT_APP/" configure_modem.sh @@ -257,7 +257,7 @@ do elif [ $shield_hat -eq 4 ]; then - cp $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME + cp $SCRIPT_PATH/reconnect_cellulariot $RECONNECT_SCRIPT_NAME sed -i "s/STATUS_PIN/$STATUS_CELL_IOT/" configure_modem.sh sed -i "s/POWERKEY_PIN/$POWERKEY_CELL_IOT/" configure_modem.sh @@ -265,7 +265,7 @@ do elif [ $shield_hat -eq 5 ]; then - cp $SCRIPT_PATH/reconnect_tracker -O $RECONNECT_SCRIPT_NAME + cp $SCRIPT_PATH/reconnect_tracker $RECONNECT_SCRIPT_NAME sed -i "s/STATUS_PIN/$STATUS_TRACKER/" configure_modem.sh sed -i "s/POWERKEY_PIN/$POWERKEY_TRACKER/" configure_modem.sh @@ -273,7 +273,7 @@ do elif [ $shield_hat -eq 6 ]; then - cp $SCRIPT_PATH/reconnect_basehat -O $RECONNECT_SCRIPT_NAME + cp $SCRIPT_PATH/reconnect_basehat $RECONNECT_SCRIPT_NAME sed -i "s/POWERUP_FLAG/$POWERUP_NOT_REQ/" configure_modem.sh From f800fcf47c9b9788846b5c3064cf19218992d40c Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Fri, 27 Nov 2020 10:16:25 +0000 Subject: [PATCH 42/49] fixed ppp_install.sh issue --- ppp_install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ppp_install.sh b/ppp_install.sh index baf6989..dc4e19f 100755 --- a/ppp_install.sh +++ b/ppp_install.sh @@ -223,11 +223,11 @@ do case $auto_reconnect in [Yy]* ) colored_echo "Copying setup file..." - cp $SOURCE_PATH/$SERVICE_NAME - cp $SOURCE_PATH/functions.sh - cp $SOURCE_PATH/configs.sh - cp $SOURCE_PATH/configure_modem.sh - cp $SOURCE_PATH/$MANAGER_SCRIPT_NAME + cp $SOURCE_PATH/$SERVICE_NAME $SERVICE_NAME + cp $SOURCE_PATH/functions.sh functions.sh + cp $SOURCE_PATH/configs.sh configs.sh + cp $SOURCE_PATH/configure_modem.sh configure_modem.sh + cp $SOURCE_PATH/$MANAGER_SCRIPT_NAME $MANAGER_SCRIPT_NAME # APN Configuration sed -i "s/SIM_APN/$carrierapn/" configure_modem.sh From 4c523c38ecbdc6c7b01b53b38f6e6cb391069e57 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Fri, 27 Nov 2020 10:19:32 +0000 Subject: [PATCH 43/49] Added dates --- ppp_install.sh | 2 ++ ppp_install_standalone.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ppp_install.sh b/ppp_install.sh index dc4e19f..b64d701 100755 --- a/ppp_install.sh +++ b/ppp_install.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Created on November 27, 2020 by Yasin Kaya (selengalp) + SIXFAB_PATH="/opt/sixfab" PPP_PATH="/opt/sixfab/ppp_connection_manager" diff --git a/ppp_install_standalone.sh b/ppp_install_standalone.sh index 4299b2f..15b51cd 100755 --- a/ppp_install_standalone.sh +++ b/ppp_install_standalone.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Re-created on November 27, 2020 by Yasin Kaya (selengalp) + SIXFAB_PATH="/opt/sixfab" PPP_PATH="/opt/sixfab/ppp_connection_manager" From 75bb2889da580daf0c6ddcfe18e0d0b9f254cbad Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Fri, 27 Nov 2020 10:47:16 +0000 Subject: [PATCH 44/49] Updated readme file --- README.md | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a5fce33..f6ef700 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,16 @@ Each of these shield can be connected to Internet via PPP(Point to Point Protoco Without further ado let us jump into the installation process: +## Standalone Installation + +All source files are downloded from internet in this method. It is enough to download **ppp_install_standalone.sh** and run it. + +`wget https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_install_standalone.sh` +`sudo chmod +x ppp_install_standalone.sh` +`sudo ./ppp_install_standalone.sh` + +## Installation with repository + Clone the repository `git clone https://github.com/sixfab/Sixfab_PPP_Installer.git` @@ -26,14 +36,16 @@ Clone the repository Now change the permission of the downloaded script. ``` -cd Sixfab_PPP_Installer/ppp_installer -chmod +x install.sh +cd Sixfab_PPP_Installer +chmod +x ppp_install.sh ``` Now install the script -`sudo ./install.sh` - +`sudo ./ppp_install.sh` + + +## After running installation file It will ask several questions, just answer them accordingly to complete the installation process. The questions are: `Please choose your Sixfab Shield/HAT` @@ -43,7 +55,7 @@ Then it installs ppp.  `What is your carrier APN?` -Here, it asks for your carrier's APN. For me it is hologram. +Here, it asks for your carrier's APN. For me it is **super**. Because I use Sixfab SIM. Please search it on your SIM provider documentations. You can reach the information by using **WHAT IS [YOUR PROVIDER NAME]'s APN** keywords probably. `Does your carrier need username and password? [Y/n]` @@ -55,11 +67,9 @@ If yes then it will ask for user name. `Enter password` Then it will ask for password. -Once you type the username asks for password. - `What is your device communication PORT? (ttyS0/ttyUSB3/etc.` -In this step you will enter your PORT. e.g For 3G, 4G/LTE Base Shield it will be ttyUSB3. +In this step you will enter your PORT. e.g For 3G, 4G/LTE Base Shield it will be ttyUSB3. `Do you want to activate auto connect/reconnect service at R.Pi boot up?` From a6fc2e3a90b7756d227f994259ec44a007bb11e7 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Fri, 27 Nov 2020 10:50:33 +0000 Subject: [PATCH 45/49] updated readme --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f6ef700..f0f7a0f 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,13 @@ Without further ado let us jump into the installation process: All source files are downloded from internet in this method. It is enough to download **ppp_install_standalone.sh** and run it. -`wget https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_install_standalone.sh` -`sudo chmod +x ppp_install_standalone.sh` -`sudo ./ppp_install_standalone.sh` +``` +wget https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer/master/ppp_install_standalone.sh +sudo chmod +x ppp_install_standalone.sh +sudo ./ppp_install_standalone.sh +``` -## Installation with repository +## Installation by using repository Clone the repository From 07e1d68d1e70ebdc13f8467aa88af7dc13b700fe Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Fri, 27 Nov 2020 10:52:14 +0000 Subject: [PATCH 46/49] updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f0f7a0f..ac61e0a 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Then it installs ppp.  `What is your carrier APN?` -Here, it asks for your carrier's APN. For me it is **super**. Because I use Sixfab SIM. Please search it on your SIM provider documentations. You can reach the information by using **WHAT IS [YOUR PROVIDER NAME]'s APN** keywords probably. +Here, it asks for your carrier's APN. For me it is `super`. Because I use Sixfab SIM. Please search it on your SIM provider documentations. You can reach the information by using `WHAT IS [YOUR PROVIDER NAME]'s APN` keywords probably. `Does your carrier need username and password? [Y/n]` From 01c4aa76cb86c2e85af9b04c282a190d76e65406 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Fri, 27 Nov 2020 10:54:53 +0000 Subject: [PATCH 47/49] updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac61e0a..68a3402 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Then it installs ppp.  `What is your carrier APN?` -Here, it asks for your carrier's APN. For me it is `super`. Because I use Sixfab SIM. Please search it on your SIM provider documentations. You can reach the information by using `WHAT IS [YOUR PROVIDER NAME]'s APN` keywords probably. +Here, it asks for your carrier's APN. For me it is `super`. Because I use Sixfab SIM. Please search it on documentations of your SIM provider . You can reach the information by using `WHAT IS [YOUR PROVIDER NAME]'s APN` keywords probably. `Does your carrier need username and password? [Y/n]` From ceab6577ee0009a734d9a4d54ca5433ff69093c0 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Fri, 27 Nov 2020 11:05:58 +0000 Subject: [PATCH 48/49] Updated readme --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 68a3402..b756b6b 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,12 @@ Each of these shield can be connected to Internet via PPP(Point to Point Protoco Without further ado let us jump into the installation process: +There are two method to installation. +1. Standalone installation +2. Installation by using repository + +You can choose one of them and go on the installation. + ## Standalone Installation All source files are downloded from internet in this method. It is enough to download **ppp_install_standalone.sh** and run it. @@ -47,7 +53,7 @@ Now install the script `sudo ./ppp_install.sh` -## After running installation file +## After running installation script It will ask several questions, just answer them accordingly to complete the installation process. The questions are: `Please choose your Sixfab Shield/HAT` From e14cb35112c3f80af6b5fcfd7e8f0f855ea58358 Mon Sep 17 00:00:00 2001 From: Yasin Kaya Date: Tue, 26 Jan 2021 08:38:34 +0300 Subject: [PATCH 49/49] get ready to production --- ppp_install.sh | 4 ++-- ppp_install_jetson.sh | 4 ++-- ppp_install_standalone.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ppp_install.sh b/ppp_install.sh index b64d701..c9a2054 100755 --- a/ppp_install.sh +++ b/ppp_install.sh @@ -6,7 +6,7 @@ SIXFAB_PATH="/opt/sixfab" PPP_PATH="/opt/sixfab/ppp_connection_manager" REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer" -BRANCH=revision +BRANCH=master SOURCE_PATH="./src" SCRIPT_PATH="./src/reconnect_scripts" RECONNECT_SCRIPT_NAME="ppp_reconnect.sh" @@ -37,7 +37,7 @@ POWERKEY_TRACKER=24 function colored_echo { COLOR=${2:-$YELLOW} - echo -e "$COLOR $1 ${SET}" + echo -e "$COLOR$1 ${SET}" } diff --git a/ppp_install_jetson.sh b/ppp_install_jetson.sh index 32170c4..9db430c 100755 --- a/ppp_install_jetson.sh +++ b/ppp_install_jetson.sh @@ -7,7 +7,7 @@ SIXFAB_PATH="/opt/sixfab" PPP_PATH="/opt/sixfab/ppp_connection_manager" REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer" -BRANCH=revision +BRANCH=master SOURCE_PATH="$REPO_PATH/$BRANCH/src" SCRIPT_PATH="$REPO_PATH/$BRANCH/src/reconnect_scripts" RECONNECT_SCRIPT_NAME="ppp_reconnect.sh" @@ -23,7 +23,7 @@ SET='\033[0m' function colored_echo { COLOR=${2:-$YELLOW} - echo -e "$COLOR $1 ${SET}" + echo -e "$COLOR$1 ${SET}" } diff --git a/ppp_install_standalone.sh b/ppp_install_standalone.sh index 15b51cd..fc25a5d 100755 --- a/ppp_install_standalone.sh +++ b/ppp_install_standalone.sh @@ -6,7 +6,7 @@ SIXFAB_PATH="/opt/sixfab" PPP_PATH="/opt/sixfab/ppp_connection_manager" REPO_PATH="https://raw.githubusercontent.com/sixfab/Sixfab_PPP_Installer" -BRANCH=revision +BRANCH=master SOURCE_PATH="$REPO_PATH/$BRANCH/src" SCRIPT_PATH="$REPO_PATH/$BRANCH/src/reconnect_scripts" RECONNECT_SCRIPT_NAME="ppp_reconnect.sh" @@ -37,7 +37,7 @@ POWERKEY_TRACKER=24 function colored_echo { COLOR=${2:-$YELLOW} - echo -e "$COLOR $1 ${SET}" + echo -e "$COLOR$1 ${SET}" }