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() {