summaryrefslogtreecommitdiff
path: root/recipes-core/multitech/config/chat_wrapper
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2019-10-18 16:53:50 -0500
committerJohn Klug <john.klug@multitech.com>2019-10-18 16:53:50 -0500
commit8e7bf688d8b90e2f8ac61404b02499246c61c7f3 (patch)
tree42abb83c2840787520ec2ae945445ffbb97b3450 /recipes-core/multitech/config/chat_wrapper
parent0237133f16f4efe07e558f6061447805328d3c2c (diff)
downloadmeta-mlinux-8e7bf688d8b90e2f8ac61404b02499246c61c7f3.tar.gz
meta-mlinux-8e7bf688d8b90e2f8ac61404b02499246c61c7f3.tar.bz2
meta-mlinux-8e7bf688d8b90e2f8ac61404b02499246c61c7f3.zip
Do not use "" for empty network addresses in AT+CGDCONT specifications
Diffstat (limited to 'recipes-core/multitech/config/chat_wrapper')
-rwxr-xr-xrecipes-core/multitech/config/chat_wrapper40
1 files changed, 35 insertions, 5 deletions
diff --git a/recipes-core/multitech/config/chat_wrapper b/recipes-core/multitech/config/chat_wrapper
index bb25d38..f1fd30c 100755
--- a/recipes-core/multitech/config/chat_wrapper
+++ b/recipes-core/multitech/config/chat_wrapper
@@ -111,7 +111,7 @@ if [[ $MPDP != $PDP ]] || [[ $MAPN != $APN ]] || \
[[ $MADDR != $ADDR ]] || ((MDCOMP != DCOMP)) || \
((MHCOMP != HCOMP)) ; then
${LOG} "Modem context $MPDP,$MAPN,$MADDR,$MDCOMP,$MHCOMP does not match chat script"
- ${LOG} "Modem context $PDP,$APN,$ADDR,$DCOMP,$HCOMP does not match chat script"
+ ${LOG} "Chat script context $PDP,$APN,$ADDR,$DCOMP,$HCOMP does not match the modem"
if [[ $MPDP != $PDP ]] ; then
${LOG} "PDP mismatch"
fi
@@ -138,15 +138,45 @@ if [[ $MPDP != $PDP ]] || [[ $MAPN != $APN ]] || \
${LOG} "Dropping registration with carrier to set context"
# Need to deregister
/usr/bin/radio-cmd ${RADIOOPTION} -t10000 'AT+COPS=2'
- CMDSTR="AT+CGDCONT=${CONTEXTNUM},${PDP},${APN},${ADDR},$DCOMP,${HCOMP}${FULLBOAT}"
+ # H5 radios do not like addresses that are empty with ""
+ if ((${#ADDR} == 0)) ; then
+ CMDSTR="AT+CGDCONT=${CONTEXTNUM},\"${PDP}\",\"${APN}\",,$DCOMP,${HCOMP}${FULLBOAT}"
+ else
+ CMDSTR="AT+CGDCONT=${CONTEXTNUM},\"${PDP}\",\"${APN}\",\"${ADDR}\",$DCOMP,${HCOMP}${FULLBOAT}"
+ fi
${LOG} "Issued command /usr/bin/radio-cmd ${RADIOOPTION} -t10000 ..."
${LOG} "... ${CMDSTR}"
- LOGMSG=$(/usr/bin/radio-cmd ${RADIOOPTION} -t10000 "${CMDSTR}" 2>&1)
- ${LOG} "Got response ${LOGMSG}"
+
+ # If we fail to set the APN, sleep and try it again for up to 10 seconds.
+ result=1
+ count=10
+ while ((result != 0)) && ((count > 0)) ; do
+ ((count--)) || true
+ LOGMSG=$(/usr/bin/radio-cmd ${RADIOOPTION} -t10000 "${CMDSTR}" 2>&1)
+ result=$?
+ ${LOG} "Result ${result}, Got response ${LOGMSG}"
+ if [[ $LOGMSG =~ ERROR ]] ; then
+ result=1
+ fi
+ sleep 1
+ done
+
+ # re-enable the modem to defaults.
/usr/bin/radio-cmd ${RADIOOPTION} -t10000 'AT+COPS=0'
sleep 1
+
+ # Some older modems will not re-register after the COPS
+ # command if you do not reset them using CFUN.
/usr/bin/radio-cmd ${RADIOOPTION} -t10000 'AT+CFUN=0'
/usr/bin/radio-cmd ${RADIOOPTION} -t10000 'AT+CFUN=1'
+
+ # Abort PPP if the Context is not correct. We don't want
+ # to cause the carrier to disable the account by dialing
+ # out with a bad APN.
+ if ((result != 0)) ; then
+ ${LOG} "AT+CGDCONT failed, aborting"
+ exit $result
+ fi
sleep 1
${LOG} "New context is set. Wait up to $REGWAITTIME seconds to register"
# Wait for registration
@@ -166,7 +196,7 @@ if [[ $MPDP != $PDP ]] || [[ $MAPN != $APN ]] || \
uptime=$(cat /proc/uptime)
[[ $uptime =~ ^([^\.]*) ]]
t1=${BASH_REMATCH[1]}
- ${LOG} "Re-registered in $((t1-t0)) seconds -- wait 5 more seconds"
+ ${LOG} "Re-registered in $((t1-t0)) seconds -- wait ${FINALWAIT} more seconds"
sleep $FINALWAIT
else
${LOG} "Context $CONTEXTNUM matches and nothing to do."