Added BG9X modules to configure_modem.sh

Added rpi max power settings for base hat
This commit is contained in:
Yasin Kaya 2020-11-23 16:44:06 +03:00
parent 76fe40bdc7
commit 3d96698901
2 changed files with 117 additions and 22 deletions

View File

@ -136,7 +136,7 @@ if ! (grep -q 'sudo route' /etc/ppp/ip-up ); then
echo "sudo route add default ppp0" >> /etc/ppp/ip-up echo "sudo route add default ppp0" >> /etc/ppp/ip-up
fi fi
if [ $shield_hat -eq 2 ]; then if [[ $shield_hat -eq 2 ]] || [[ $shield_hat -eq 6 ]]; then
if ! (grep -q 'max_usb_current' /boot/config.txt ); then if ! (grep -q 'max_usb_current' /boot/config.txt ); then
echo "max_usb_current=1" >> /boot/config.txt echo "max_usb_current=1" >> /boot/config.txt
fi fi

View File

@ -2,37 +2,132 @@
source functions.sh source functions.sh
# Check the vendor
lsusb | grep Quectel >> /dev/null
IS_QUECTEL=$?
lsusb | grep Telit >> /dev/null
IS_TELIT=$?
### Modem configuration for RMNET/PPP mode ################################## ### Modem configuration for RMNET/PPP mode ##################################
debug "Checking APN and Modem Mode..." debug "Checking APN and Modem Mode..."
# APN # APN Configuration
# -----------------
atcom "AT+CGDCONT?" | grep super >> /dev/null atcom "AT+CGDCONT?" | grep super >> /dev/null
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
atcom "AT+CGDCONT=1,\"IP\",\"super\"" atcom "AT+CGDCONT=1,\"IPV4V6\",\"super\""
debug "APN is updated." debug "APN is updated."
fi fi
atcom "AT#USBCFG?" | grep 0 >> /dev/null # Modem Mode Configuration
# ------------------------
# For Quectel
if [[ $IS_QUECTEL -eq 0 ]]; then
if [[ $? -ne 0 ]]; then lsusb | grep BG9 > /dev/null
atcom "AT#USBCFG=0" MODEL_BG9X=$?
debug "RMNET/PPP mode is activated."
debug "Modem restarting..."
sleep 20 if [[ $MODEL_BG9X -eq 0 ]]; then
# BG95 and BG96
# Check modem is started!
for i in {1..120}; do # RAT Searching Sequence
route -n | grep wwan0 >> /dev/null atcom "AT+QCFG=\"nwscanseq\"" | grep 000201 >> /dev/null
if [[ $? -eq 0 ]]; then
echo if [[ $? -ne 0 ]]; then
debug "Modem is restarted." atcom "AT+QCFG=\"nwscanseq\",00"
break debug "Configure RAT Searching Sequence is updated."
fi fi
sleep 1
printf "*" # RAT(s) to be Searched
done atcom "AT+QCFG=\"nwscanmode\"" | grep 0 >> /dev/null
sleep 5 # wait until modem is ready
if [[ $? -ne 0 ]]; then
atcom "AT+QCFG=\"nwscanmode\",0"
debug "RAT(s) to be Searched is updated."
fi
# Network Category to be Searched under LTE RAT
atcom "AT+QCFG=\"iotopmode\"" | grep 0 >> /dev/null
if [[ $? -ne 0 ]]; then
atcom "AT+QCFG=\"iotopmode\",0"
debug "Network Category to be Searched under LTE RAT is updated."
fi
# end of configuraiton for BG95/6
else
# EC25 or derives.
atcom "AT+QCFG=\"usbnet\"" | grep 0 >> /dev/null
if [[ $? -ne 0 ]]; then
atcom "AT+QCFG=\"usbnet\",0"
debug "PPP mode is activated."
debug "Modem restarting..."
sleep 20
# Check modem is started
route -n | grep wwan0 >> /dev/null
if [[ $? -eq 0 ]]; then
echo
else
# If modem don't reboot automatically, reset manually
atcom "AT+CFUN=1,1" # rebooting modem
sleep 20
fi
# 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
fi
# For Telit
elif [[ $IS_TELIT -eq 0 ]]; then
atcom "AT#USBCFG?" | grep 4 >> /dev/null
if [[ $? -ne 0 ]]; then
atcom "AT#USBCFG=4"
debug "ECM 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
# Unknown
else
debug "The cellular module couldn't be detected!"
exit 1
fi fi
### End of Modem configuration for RMNET/PPP mode ############################ ### End of Modem configuration for ECM mode ############################
# Check the network is ready
# --------------------------
if check_network -eq 0; then exit 0; else debug "Network registeration is failed!"; exit 1; fi