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