summaryrefslogtreecommitdiff
path: root/recipes-core
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-10-12 14:07:23 -0500
commit316e231e95b878fd1dec887a000d5e7e68c06ed6 (patch)
tree4a84eddca73326a85c6c40318b0f031d740f9ecd /recipes-core
parent1569d915e6d65355f78a9bce4dc7502c02cca034 (diff)
downloadmeta-mlinux-316e231e95b878fd1dec887a000d5e7e68c06ed6.tar.gz
meta-mlinux-316e231e95b878fd1dec887a000d5e7e68c06ed6.tar.bz2
meta-mlinux-316e231e95b878fd1dec887a000d5e7e68c06ed6.zip
Add SIM detection code
Diffstat (limited to 'recipes-core')
-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)