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