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>
This commit is contained in:
		| @@ -86,10 +86,25 @@ proto_ncm_setup() { | ||||
| 		return 1 | ||||
| 	} | ||||
|  | ||||
| 	[ -n "$delay" ] && sleep "$delay" | ||||
|  | ||||
| 	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; }') | ||||
| 	[ $? -ne 0 -o -z "$manufacturer" ] && { | ||||
| 		[ "$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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Mike Wilson
					Mike Wilson