summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrecipes-core/multitech/config/chat_wrapper40
-rw-r--r--recipes-core/multitech/config_2.3.bb2
2 files changed, 36 insertions, 6 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."
diff --git a/recipes-core/multitech/config_2.3.bb b/recipes-core/multitech/config_2.3.bb
index 84721a7..3e9733a 100644
--- a/recipes-core/multitech/config_2.3.bb
+++ b/recipes-core/multitech/config_2.3.bb
@@ -4,7 +4,7 @@ LICENSE = "MIT"
RDEPENDS_${PN} += "bash"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
PACKAGE_ARCH = "all"
-PR = "r6"
+PR = "r7"
PACKAGES =+ "${PN}-mths"
inherit update-rc.d