summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2020-10-12 14:07:23 -0500
committerJohn Klug <john.klug@multitech.com>2020-12-07 15:20:17 -0600
commitf23ab3c0f3af198788e7998e9ad7beda6cb7ffa9 (patch)
tree8c8e9460e2a756b366ef368f042bd281f430d9b7
parent741cc162ccb373c811a257f28d91b86b2e29ae59 (diff)
downloadmeta-mlinux-f23ab3c0f3af198788e7998e9ad7beda6cb7ffa9.tar.gz
meta-mlinux-f23ab3c0f3af198788e7998e9ad7beda6cb7ffa9.tar.bz2
meta-mlinux-f23ab3c0f3af198788e7998e9ad7beda6cb7ffa9.zip
Add SIM detection code
-rwxr-xr-xrecipes-core/multitech/config/chat_wrapper32
1 files changed, 22 insertions, 10 deletions
diff --git a/recipes-core/multitech/config/chat_wrapper b/recipes-core/multitech/config/chat_wrapper
index dae3183..04ea17f 100755
--- a/recipes-core/multitech/config/chat_wrapper
+++ b/recipes-core/multitech/config/chat_wrapper
@@ -26,7 +26,7 @@
NAME=chat_wrapper
CONFIG=/etc/default/${NAME}
CHAT_WRAPPER_RECURSION=/run/chat_wrapper_recursion
-
+RQCMD="/usr/bin/radio-query ${RADIOOPTION}"
function finish
{
${LOG} "Launch:" "$@"
@@ -44,9 +44,12 @@ function finish
# the best thing to try.
function sanity
{
- if ! log=$(stty 2>&1) || ! [[ $(radio-cmd -t10000 'AT') =~ ^OK ]]; then
- ${LOG} "Modem has issues, so see if we can try again"
- ${LOG} "stty error: $(log)"
+ id="^[0-9][0-9][0-9][0-9][0-9][0-9]"
+ if ! log=$(stty 2>&1) || ! [[ $($RQCMD --iccid) =~ $id ]] ; then
+ ${LOG} "Modem has response issues, so see if we can try again"
+ if ((${#log} > 0)); then
+ ${LOG} "stty error: $(log)"
+ fi
array=( )
# our parent is PPID, which is pppd. Get the pppd
# parameter list.
@@ -66,11 +69,12 @@ function sanity
# Break any recursion loop.
if [[ -f ${CHAT_WRAPPER_RECURSION} ]] ; then
${LOG} "Failure: modem is still unresponsive after reset"
+ ${LOG} "Failure: Verify that modem and SIM are in place"
rm -f ${CHAT_WRAPPER_RECURSION}
exit 1
fi
touch ${CHAT_WRAPPER_RECURSION}
- ${LOG} "Bad TTY, possibly due to modem in bad state"
+ ${LOG} "Bad TTY, possibly due to modem in bad state/no SIM detected"
${LOG} "Reset modem, and we relaunch pppd"
# Our terminal is the modem. When we reset the modem,
# we will be sent a SIGHUP. Ignore it (:).
@@ -105,6 +109,7 @@ function sanity
fi
done
${LOG} "ERROR: After five minutes the modem is still not ready"
+ ${LOG} "ERROR: Verify that SIM is in place"
exit 1
fi
return 0
@@ -170,14 +175,21 @@ ${LOG} "Using Context ${CONTEXTNUM} based on chat script: ${CONTEXT}"
# Get Modem's context settings
MCONTEXT=$(/usr/bin/radio-cmd ${RADIOOPTION} -t10000 'AT+CGDCONT?' 2>&1 | tr -d '\r')
-if [[ $MCONTEXT =~ [Ee][Rr][Rr][Oo][Rr] ]] ; then
+if [[ $MCONTEXT =~ ^[Ee][Rr][Rr][Oo][Rr] ]] ; then
RADIOOPTION="${RADIOOPTION2}"
+ sleep 1
MCONTEXT=$(/usr/bin/radio-cmd ${RADIOOPTION} -t10000 'AT+CGDCONT?' 2>&1 | tr -d '\r')
+ CRESULT=$?
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
+ echo "Result is $CRESULT" | logger -s -p daemon.error
+ if [[ $MCONTEXT =~ ^[Ee][Rr][Rr][Oo][Rr] ]] ; then
+ logger -s -p daemon.error "Context query response error. Diagnose ..."
+ sanity
+ fi
fi
MPDP="${BASH_REMATCH[1]}"
@@ -219,7 +231,7 @@ if [[ $MADDR != $ADDR ]] ; then
ADDRMATCH=1
fi
fi
-fi
+fi
# Only update context on a mismatch between chat and modem.
if [[ $MPDP != $PDP ]] || [[ $MAPN != $APN ]] || \
@@ -258,7 +270,7 @@ if [[ $MPDP != $PDP ]] || [[ $MAPN != $APN ]] || \
/usr/bin/radio-cmd ${RADIOOPTION} -t10000 'AT+COPS=2'
count=10
- while ((count > 0)) && ! [[ $(/usr/bin/radio-query ${RADIOOPTION} --netreg) =~ ^NOT\ REGISTERED$ ]] ; do
+ while ((count > 0)) && ! [[ $($RQCMD --netreg) =~ ^NOT\ REGISTERED$ ]] ; do
sleep 2
((count--))
done
@@ -326,7 +338,7 @@ fi
uptime=$(cat /proc/uptime)
[[ $uptime =~ ^([^\.]*) ]]
t0=${BASH_REMATCH[1]}
-while ! [[ $(/usr/bin/radio-query ${RADIOOPTION} --netreg) =~ ^(REGISTERED|ROAMING)$ ]] ; do
+while ! [[ $($RQCMD --netreg) =~ ^(REGISTERED|ROAMING)$ ]] ; do
sleep 5
((WAITREG++))
uptime=$(cat /proc/uptime)