summaryrefslogtreecommitdiff
path: root/recipes-core/multitech/config/chat_wrapper
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2019-08-14 18:04:07 -0500
committerJohn Klug <john.klug@multitech.com>2019-08-14 18:04:07 -0500
commit1eea5c652209d93746318e80a48d178ffd2905ac (patch)
treef297bf73453119910afd8d8be450e95d7763d1da /recipes-core/multitech/config/chat_wrapper
parent4c8903bbf55d210ad59a817fc755926b265c1539 (diff)
downloadmeta-mlinux-1eea5c652209d93746318e80a48d178ffd2905ac.tar.gz
meta-mlinux-1eea5c652209d93746318e80a48d178ffd2905ac.tar.bz2
meta-mlinux-1eea5c652209d93746318e80a48d178ffd2905ac.zip
Move to L4N1 and L4E1 support, temporarily on gitlab
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)