mirror of
https://github.com/sixfab/Sixfab_PPP_Installer
synced 2024-11-14 23:24:55 +00:00
Added powerup mechansm to configure_modem.sh
This commit is contained in:
parent
d78caf5054
commit
76fe62a862
34
install.sh
34
install.sh
@ -17,6 +17,20 @@ BLUE='\033[1;34m'
|
|||||||
GREEN='\033[0;32m'
|
GREEN='\033[0;32m'
|
||||||
SET='\033[0m'
|
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
|
function colored_echo
|
||||||
{
|
{
|
||||||
@ -198,31 +212,51 @@ do
|
|||||||
wget --no-check-certificate $SCRIPT_PATH/reconnect_gprsshield -O $RECONNECT_SCRIPT_NAME
|
wget --no-check-certificate $SCRIPT_PATH/reconnect_gprsshield -O $RECONNECT_SCRIPT_NAME
|
||||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
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
|
elif [ $shield_hat -eq 2 ]; then
|
||||||
|
|
||||||
wget --no-check-certificate $SCRIPT_PATH/reconnect_baseshield -O $RECONNECT_SCRIPT_NAME
|
wget --no-check-certificate $SCRIPT_PATH/reconnect_baseshield -O $RECONNECT_SCRIPT_NAME
|
||||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
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
|
elif [ $shield_hat -eq 3 ]; then
|
||||||
|
|
||||||
wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot_app -O $RECONNECT_SCRIPT_NAME
|
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
|
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
|
elif [ $shield_hat -eq 4 ]; then
|
||||||
|
|
||||||
wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME
|
wget --no-check-certificate $SCRIPT_PATH/reconnect_cellulariot -O $RECONNECT_SCRIPT_NAME
|
||||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
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
|
elif [ $shield_hat -eq 5 ]; then
|
||||||
|
|
||||||
wget --no-check-certificate $SCRIPT_PATH/reconnect_tracker -O $RECONNECT_SCRIPT_NAME
|
wget --no-check-certificate $SCRIPT_PATH/reconnect_tracker -O $RECONNECT_SCRIPT_NAME
|
||||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
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
|
elif [ $shield_hat -eq 6 ]; then
|
||||||
|
|
||||||
wget --no-check-certificate $SCRIPT_PATH/reconnect_basehat -O $RECONNECT_SCRIPT_NAME
|
wget --no-check-certificate $SCRIPT_PATH/reconnect_basehat -O $RECONNECT_SCRIPT_NAME
|
||||||
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
if [[ $? -ne 0 ]]; then colored_echo "Download failed" ${RED}; exit 1; fi
|
||||||
|
|
||||||
|
sed -i "s/POWERUP_FLAG/$POWERUP_NOT_REQ/" configure_modem.sh
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mv functions.sh $PPP_PATH
|
mv functions.sh $PPP_PATH
|
||||||
|
@ -2,6 +2,46 @@
|
|||||||
|
|
||||||
source functions.sh
|
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
|
# Check the vendor
|
||||||
lsusb | grep Quectel >> /dev/null
|
lsusb | grep Quectel >> /dev/null
|
||||||
IS_QUECTEL=$?
|
IS_QUECTEL=$?
|
||||||
@ -10,6 +50,12 @@ lsusb | grep Telit >> /dev/null
|
|||||||
IS_TELIT=$?
|
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 ##################################
|
### Modem configuration for RMNET/PPP mode ##################################
|
||||||
debug "Checking APN and Modem Mode..."
|
debug "Checking APN and Modem Mode..."
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ function power_up_module()
|
|||||||
else
|
else
|
||||||
debug "Module couldn't be powered up!"
|
debug "Module couldn't be powered up!"
|
||||||
sleep 2
|
sleep 2
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
debug "Module is just powered up."
|
debug "Module is just powered up."
|
||||||
return 0
|
return 0
|
||||||
|
@ -33,6 +33,7 @@ function power_up_module()
|
|||||||
else
|
else
|
||||||
debug "Module couldn't be powered up!"
|
debug "Module couldn't be powered up!"
|
||||||
sleep 2
|
sleep 2
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
debug "Module is just powered up."
|
debug "Module is just powered up."
|
||||||
return 0
|
return 0
|
||||||
|
@ -33,6 +33,7 @@ function power_up_module()
|
|||||||
else
|
else
|
||||||
debug "Module couldn't be powered up!"
|
debug "Module couldn't be powered up!"
|
||||||
sleep 2
|
sleep 2
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
debug "Module is just powered up."
|
debug "Module is just powered up."
|
||||||
return 0
|
return 0
|
||||||
|
@ -33,6 +33,7 @@ function power_up_module()
|
|||||||
else
|
else
|
||||||
debug "Module couldn't be powered up!"
|
debug "Module couldn't be powered up!"
|
||||||
sleep 2
|
sleep 2
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
debug "Module is just powered up."
|
debug "Module is just powered up."
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user