mirror of
https://github.com/sixfab/Sixfab_PPP_Installer
synced 2024-11-25 04:14:53 +00:00
Fixed powerup and detecting module issue on BG9X
This commit is contained in:
parent
77fe6ab6d4
commit
cb81caf18f
@ -7,6 +7,9 @@ STATUS=${STATUS_PIN:-23}
|
|||||||
POWERKEY=${POWERKEY_PIN:-24}
|
POWERKEY=${POWERKEY_PIN:-24}
|
||||||
POWER_UP_REQUIRED=${POWERUP_FLAG:-1}
|
POWER_UP_REQUIRED=${POWERUP_FLAG:-1}
|
||||||
|
|
||||||
|
# default arguments
|
||||||
|
APN=${SIM_APN:-super}
|
||||||
|
|
||||||
# 1 : STATUS
|
# 1 : STATUS
|
||||||
# 2 : POWERKEY
|
# 2 : POWERKEY
|
||||||
function power_up_module
|
function power_up_module
|
||||||
@ -23,7 +26,7 @@ function power_up_module
|
|||||||
gpio -g write $POWERKEY 1
|
gpio -g write $POWERKEY 1
|
||||||
sleep 2
|
sleep 2
|
||||||
gpio -g write $POWERKEY 0
|
gpio -g write $POWERKEY 0
|
||||||
sleep 2
|
sleep 5
|
||||||
|
|
||||||
if [[ $(gpio -g read $STATUS) -eq 0 ]]; then
|
if [[ $(gpio -g read $STATUS) -eq 0 ]]; then
|
||||||
debug "Module is powered up."
|
debug "Module is powered up."
|
||||||
@ -42,14 +45,6 @@ function power_up_module
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check the vendor
|
|
||||||
lsusb | grep Quectel >> /dev/null
|
|
||||||
IS_QUECTEL=$?
|
|
||||||
|
|
||||||
lsusb | grep Telit >> /dev/null
|
|
||||||
IS_TELIT=$?
|
|
||||||
|
|
||||||
|
|
||||||
if [[ $POWER_UP_REQUIRED -eq 1 ]]; then
|
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
|
if power_up_module -eq 0 ; then sleep 0.1; else debug "Module couldn't be powered up! Check the hardware setup!"; fi
|
||||||
else
|
else
|
||||||
@ -61,13 +56,20 @@ debug "Checking APN and Modem Mode..."
|
|||||||
|
|
||||||
# APN Configuration
|
# APN Configuration
|
||||||
# -----------------
|
# -----------------
|
||||||
atcom "AT+CGDCONT?" | grep super >> /dev/null
|
atcom "AT+CGDCONT?" | grep $APN > /dev/null
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
atcom "AT+CGDCONT=1,\"IPV4V6\",\"super\""
|
atcom "AT+CGDCONT=1,\"IPV4V6\",\"$APN\""
|
||||||
debug "APN is updated."
|
debug "APN is updated."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check the vendor
|
||||||
|
lsusb | grep Quectel >> /dev/null
|
||||||
|
IS_QUECTEL=$?
|
||||||
|
|
||||||
|
lsusb | grep Telit >> /dev/null
|
||||||
|
IS_TELIT=$?
|
||||||
|
|
||||||
# Modem Mode Configuration
|
# Modem Mode Configuration
|
||||||
# ------------------------
|
# ------------------------
|
||||||
# For Quectel
|
# For Quectel
|
||||||
@ -80,7 +82,7 @@ if [[ $IS_QUECTEL -eq 0 ]]; then
|
|||||||
# BG95 and BG96
|
# BG95 and BG96
|
||||||
|
|
||||||
# RAT Searching Sequence
|
# RAT Searching Sequence
|
||||||
atcom "AT+QCFG=\"nwscanseq\"" | grep 000201 >> /dev/null
|
atcom "AT+QCFG=\"nwscanseq\"" | grep 020301 > /dev/null
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
atcom "AT+QCFG=\"nwscanseq\",00"
|
atcom "AT+QCFG=\"nwscanseq\",00"
|
||||||
@ -88,7 +90,7 @@ if [[ $IS_QUECTEL -eq 0 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# RAT(s) to be Searched
|
# RAT(s) to be Searched
|
||||||
atcom "AT+QCFG=\"nwscanmode\"" | grep 0 >> /dev/null
|
atcom "AT+QCFG=\"nwscanmode\"" | grep 0 > /dev/null
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
atcom "AT+QCFG=\"nwscanmode\",0"
|
atcom "AT+QCFG=\"nwscanmode\",0"
|
||||||
@ -96,7 +98,7 @@ if [[ $IS_QUECTEL -eq 0 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Network Category to be Searched under LTE RAT
|
# Network Category to be Searched under LTE RAT
|
||||||
atcom "AT+QCFG=\"iotopmode\"" | grep 0 >> /dev/null
|
atcom "AT+QCFG=\"iotopmode\"" | grep 0 > /dev/null
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
atcom "AT+QCFG=\"iotopmode\",0"
|
atcom "AT+QCFG=\"iotopmode\",0"
|
||||||
@ -106,7 +108,7 @@ if [[ $IS_QUECTEL -eq 0 ]]; then
|
|||||||
# end of configuraiton for BG95/6
|
# end of configuraiton for BG95/6
|
||||||
else
|
else
|
||||||
# EC25 or derives.
|
# EC25 or derives.
|
||||||
atcom "AT+QCFG=\"usbnet\"" | grep 0 >> /dev/null
|
atcom "AT+QCFG=\"usbnet\"" | grep 0 > /dev/null
|
||||||
|
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
atcom "AT+QCFG=\"usbnet\",0"
|
atcom "AT+QCFG=\"usbnet\",0"
|
||||||
@ -170,7 +172,7 @@ else
|
|||||||
debug "The cellular module couldn't be detected!"
|
debug "The cellular module couldn't be detected!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
### End of Modem configuration for ECM mode ############################
|
### End of Modem configuration for RMNET/PPP mode ############################
|
||||||
|
|
||||||
|
|
||||||
# Check the network is ready
|
# Check the network is ready
|
||||||
|
@ -24,29 +24,35 @@ function check_network()
|
|||||||
for i in {1..$NETWORK_CHECK_TIMEOUT}; do
|
for i in {1..$NETWORK_CHECK_TIMEOUT}; do
|
||||||
NETWORK_OK=0
|
NETWORK_OK=0
|
||||||
|
|
||||||
debug "SIM Status:"
|
debug "SIM Status: " "-n" # no line break
|
||||||
atcom AT+CPIN? | grep "CPIN: READY"
|
atcom AT+CPIN? | grep "CPIN: READY"
|
||||||
SIM_READY=$?
|
SIM_READY=$?
|
||||||
|
|
||||||
debug "Network Registeration Status:"
|
if [[ $SIM_READY -ne 0 ]]; then atcom AT+CPIN? | grep "CPIN:"; fi
|
||||||
|
|
||||||
|
|
||||||
|
debug "Network Registeration Status: " "-n" # no line break
|
||||||
# For super SIM
|
# For super SIM
|
||||||
atcom AT+CREG? | grep "CREG: 0,5"
|
atcom AT+CREG? | grep "CREG: 0,5" > /dev/null
|
||||||
NETWORK_REG=$?
|
NETWORK_REG=$?
|
||||||
# For native SIM
|
# For native SIM
|
||||||
atcom AT+CREG? | grep "CREG: 0,1"
|
atcom AT+CREG? | grep "CREG: 0,1" > /dev/null
|
||||||
NETWORK_REG_2=$?
|
NETWORK_REG_2=$?
|
||||||
# Combined network registeration status
|
# Combined network registeration status
|
||||||
NETWORK_REG=$((NETWORK_REG+NETWORK_REG_2))
|
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
|
if [[ $SIM_READY -eq 0 ]] && [[ $NETWORK_REG -le 1 ]]; then
|
||||||
debug "Network is ready."
|
debug "Network is ready."
|
||||||
NETWORK_OK=1
|
NETWORK_OK=1
|
||||||
return 0
|
return 0
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
printf "?"
|
debug "Retrying network registeration..."
|
||||||
fi
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
debug "Retwork registeration is failed! Please check SIM card, data plan, antennas etc."
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user