diff options
author | Mike Wilson <mikewse@hotmail.com> | 2020-07-20 22:25:33 +0200 |
---|---|---|
committer | David Bauer <mail@david-bauer.net> | 2023-03-30 02:03:32 +0200 |
commit | b573a785e0c53d710b8bd6637c7d5ba73fe6839c (patch) | |
tree | 2bf016155a034721d1e0c0a311aad94cabc1e73e | |
parent | f61c5cf76b9d13d9cc5962c4640ba14f28800215 (diff) | |
download | upstream-b573a785e0c53d710b8bd6637c7d5ba73fe6839c.tar.gz upstream-b573a785e0c53d710b8bd6637c7d5ba73fe6839c.tar.bz2 upstream-b573a785e0c53d710b8bd6637c7d5ba73fe6839c.zip |
ncm: add error check and retry mechanism for gcom call
This patch solves the problem of receiving "error" responses when
initially calling gcom. This avoids unnecessary NO_DEVICE failures.
A retry loop retries the call after an "error" response within the
specified delay. A successful response will continue with the connection
immediately without waiting for max specified delay, bringing the
interface up sooner.
Signed-off-by: Mike Wilson <mikewse@hotmail.com>
(cherry picked from commit 8f27093ce784daad5a9b1c89f51d0a76a8bbb07b)
-rw-r--r-- | package/network/utils/comgt/files/ncm.sh | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/package/network/utils/comgt/files/ncm.sh b/package/network/utils/comgt/files/ncm.sh index 2f36697487..dec058712d 100644 --- a/package/network/utils/comgt/files/ncm.sh +++ b/package/network/utils/comgt/files/ncm.sh @@ -86,10 +86,25 @@ proto_ncm_setup() { return 1 } - [ -n "$delay" ] && sleep "$delay" - - manufacturer=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk 'NF && $0 !~ /AT\+CGMI/ { sub(/\+CGMI: /,""); print tolower($1); exit; }') - [ $? -ne 0 -o -z "$manufacturer" ] && { + start=$(date +%s) + while true; do + manufacturer=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk 'NF && $0 !~ /AT\+CGMI/ { sub(/\+CGMI: /,""); print tolower($1); exit; }') + [ "$manufacturer" = "error" ] && { + manufacturer="" + } + [ -n "$manufacturer" ] && { + break + } + [ -z "$delay" ] && { + break + } + sleep 1 + elapsed=$(($(date +%s) - start)) + [ "$elapsed" -gt "$delay" ] && { + break + } + done + [ -z "$manufacturer" ] && { echo "Failed to get modem information" proto_notify_error "$interface" GETINFO_FAILED return 1 |