summaryrefslogtreecommitdiff
path: root/recipes-core/multitech/config/chat_wrapper
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-core/multitech/config/chat_wrapper')
-rwxr-xr-xrecipes-core/multitech/config/chat_wrapper21
1 files changed, 15 insertions, 6 deletions
diff --git a/recipes-core/multitech/config/chat_wrapper b/recipes-core/multitech/config/chat_wrapper
index 9db3188..51f8cc1 100755
--- a/recipes-core/multitech/config/chat_wrapper
+++ b/recipes-core/multitech/config/chat_wrapper
@@ -66,8 +66,16 @@ ${LOG} "Using Context ${CONTEXTNUM} based on chat script: ${CONTEXT}"
# At this point if there is no context number, we can skip everything else.
# Get Modem's context settings
-MCONTEXT=$(/usr/bin/radio-cmd -t10 'AT+CGDCONT?' 2>&1 | tr -d '\r')
-[[ $MCONTEXT =~ \+CGDCONT:[[:space:]]+${CONTEXTNUM},\"([^\"]*)\",\"([^\"]*)\",\"([^\"]*)\",([0-9]+),([0-9]+)([^$'\n']*) ]]
+MCONTEXT=$(/usr/bin/radio-cmd ${RADIOOPTION} -t10 'AT+CGDCONT?' 2>&1 | tr -d '\r')
+if [[ $MCONTEXT =~ [Ee][Rr][Rr][Oo][Rr] ]] ; then
+ RADIOOPTION="${RADIOOPTION2}"
+ MCONTEXT=$(/usr/bin/radio-cmd ${RADIOOPTION} -t10 'AT+CGDCONT?' 2>&1 | tr -d '\r')
+fi
+
+if ! [[ $MCONTEXT =~ \+CGDCONT:[[:space:]]+${CONTEXTNUM},\"([^\"]*)\",\"([^\"]*)\",\"([^\"]*)\",([0-9]+),([0-9]+)([^$'\n']*) ]] ; then
+ logger -s -p daemon.error "No valid context in modem. Is it ready?"
+ echo "$MCONTEXT" | logger -s -p daemon.error
+fi
MPDP="${BASH_REMATCH[1]}"
MAPN="${BASH_REMATCH[2]}"
@@ -100,21 +108,22 @@ if [[ $MPDP != $PDP ]] || [[ $MAPN != $APN ]] || \
${LOG} "$MCONTEXT"
${LOG} "Dropping registration with carrier to set context"
# Need to deregister
- /usr/bin/radio-cmd -t10 'AT+COPS=2'
- /usr/bin/radio-cmd -t10 "AT+CGDCONT=${CONTEXTNUM},\"${PDP}\",\"${APN}\",\"${ADDR}\",$DCOMP,${HCOMP}${FULLBOAT}"
- /usr/bin/radio-cmd -t10 'AT+COPS=0'
+ /usr/bin/radio-cmd ${RADIOOPTION} -t10 'AT+COPS=2'
+ /usr/bin/radio-cmd ${RADIOOPTION} -t10 "AT+CGDCONT=${CONTEXTNUM},\"${PDP}\",\"${APN}\",\"${ADDR}\",$DCOMP,${HCOMP}${FULLBOAT}"
+ /usr/bin/radio-cmd ${RADIOOPTION} -t10 'AT+COPS=0'
${LOG} "New context is set. Wait up to $REGWAITTIME seconds to register"
# Wait for registration
uptime=$(cat /proc/uptime)
[[ $uptime =~ ^([^\.]*) ]]
t0=${BASH_REMATCH[1]}
- while ! [[ $(/usr/bin/radio-query --netreg) =~ ^REGISTERED$ ]] ; do
+ while ! [[ $(/usr/bin/radio-query ${RADIOOPTION} --netreg) =~ ^REGISTERED$ ]] ; do
sleep 5
uptime=$(cat /proc/uptime)
[[ $uptime =~ ^([^\.]*) ]]
t1=${BASH_REMATCH[1]}
if ((t1-t0 > REGWAITTIME)) ; then
${LOG} "$((t1-t0)) seconds has expired"
+ exit 1
fi
done
uptime=$(cat /proc/uptime)