Added powerup mechansm to configure_modem.sh

This commit is contained in:
Yasin Kaya 2020-11-26 01:50:37 +03:00
parent d78caf5054
commit 76fe62a862
6 changed files with 84 additions and 0 deletions

View File

@ -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

View File

@ -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..."

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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