From 1eea5c652209d93746318e80a48d178ffd2905ac Mon Sep 17 00:00:00 2001 From: John Klug Date: Wed, 14 Aug 2019 18:04:07 -0500 Subject: Move to L4N1 and L4E1 support, temporarily on gitlab --- recipes-core/multitech/config/chat_wrapper | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'recipes-core/multitech/config/chat_wrapper') 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) -- cgit v1.2.3