diff options
author | Max Wölfing | 2019-03-14 14:44:26 +0100 |
---|---|---|
committer | Max Wölfing | 2019-03-14 14:44:26 +0100 |
commit | 7393d625994b467c47c209d604f3adf2370a1026 (patch) | |
tree | e801ea5476a350277b7e70d0d96b94b133d65a5f | |
parent | 440033614f7fa8c4551d2075106658a3a0654330 (diff) | |
download | aur-7393d625994b467c47c209d604f3adf2370a1026.tar.gz |
'TimeoutConnect' increases the chance of getting the bearer_interface even if the modem came up slowly
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 4 | ||||
-rw-r--r-- | mobile_mm | 20 |
3 files changed, 19 insertions, 9 deletions
@@ -1,6 +1,6 @@ pkgbase = netctl-mm pkgdesc = Mobile broadband support for netctl using ModemManager - pkgver = 0.0.6 + pkgver = 0.0.7 pkgrel = 1 arch = any license = GPL @@ -9,7 +9,7 @@ pkgbase = netctl-mm source = mobile_mm.profile source = mobile_mm md5sums = ccad269de8f7c0d0cb89d3112849023d - md5sums = 67b54403ec1f95330ffc11c35fb722c3 + md5sums = 340792cd0b9f6f7452bbd96ca45a41a4 pkgname = netctl-mm @@ -1,6 +1,6 @@ # Maintainer: Max Wölfing <ff0x@infr.cat> pkgname=netctl-mm -pkgver=0.0.6 +pkgver=0.0.7 pkgrel=1 pkgdesc="Mobile broadband support for netctl using ModemManager" arch=(any) @@ -8,7 +8,7 @@ license=('GPL') depends=(netctl modemmanager) source=(mobile_mm.profile mobile_mm) md5sums=('ccad269de8f7c0d0cb89d3112849023d' - '67b54403ec1f95330ffc11c35fb722c3') + '340792cd0b9f6f7452bbd96ca45a41a4') package() { install -Dm644 "$srcdir/mobile_mm.profile" "$pkgdir/etc/netctl/examples/mobile_mm" diff --git a/mobile_mm b/mobile_mm index 219790cc1436..d30de6c8ed03 100644 --- a/mobile_mm +++ b/mobile_mm @@ -1,5 +1,5 @@ # Contributed by Max Wölfing <ff0x@infr.cat> -# Version: 0.0.6 +# Version: 0.0.7 # KNOWN BUGS: # - After suspend/hibernate the mobile broadband connection is not going to reconnect automatically (that's probably ok) @@ -116,14 +116,24 @@ function mobile_mm_up { Mode="4G" fi - report_debug "Full connect string: $__MMCLI -m $MODEM --timeout ${TimeoutConnect:-60} --set-allowed-modes=ANY --set-preferred-mode=${Mode} --simple-connect=$connect_args" - $__MMCLI -m "$MODEM" --set-allowed-modes=ANY --timeout ${TimeoutConnect:-60} --set-preferred-mode="${Mode}" --simple-connect="$connect_args" $(if [ "$NETCTL_DEBUG" == 'yes' ]; then echo '2>/dev/null'; fi) + report_debug "Full connect string: $__MMCLI -m $MODEM --set-allowed-modes=ANY --set-preferred-mode=${Mode} --simple-connect=$connect_args" + $__MMCLI -m "$MODEM" --set-allowed-modes=ANY --set-preferred-mode="${Mode}" --simple-connect="$connect_args" $(if [ "$NETCTL_DEBUG" == 'yes' ]; then echo '2>/dev/null'; fi) local bearer bearer_interface bearer=$($__MMCLI -m "$MODEM" $(if [ "$NETCTL_DEBUG" == 'yes' ]; then echo '2>/dev/null'; fi) | sed -n 's#.*\(/org/.*/Bearer/[0-9]\+\).*#\1#p') - bearer_interface=$($__MMCLI -m "$MODEM" -b "$bearer" $(if [ "$NETCTL_DEBUG" == 'yes' ]; then echo '2>/dev/null'; fi) | sed -n "s/.*interface: \(.*\)/\1/p") + + get_bearer_interface="$__MMCLI -m $MODEM -b $bearer | awk '/Status/ {for(i=1; i<5; i++) {getline; if ($2=="interface:") {gsub("\047","",$3); print $3}}}'" + + # Some modems need some time for the initialisation the connection + TIMEOUT_CONNECTION=${TimeoutConnect:-30} + until [[ $($__MMCLI -m $MODEM -b $bearer | awk '/Status/ {for(i=1; i<5; i++) {getline; if ($2=="interface:") {gsub("\047","",$3); print $3}}}') ]] || [ $TIMEOUT_CONNECTION -eq 0 ]; do + sleep 1 + ((TIMEOUT_CONNECTION--)) + done + + bearer_interface=$($__MMCLI -m "$MODEM" -b "$bearer" $(if [ "$NETCTL_DEBUG" == 'yes' ]; then echo '2>/dev/null'; fi) | awk '/Status/ {for(i=1; i<5; i++) {getline; if ($2=="interface:") {gsub("\047","",$3); print $3}}}') if [[ -z "$bearer_interface" ]]; then - report_error "No bearer interface found" + report_error "No bearer interface found. Consider increasing \$TimeoutConnect a bit." return 1 fi if [[ "$bearer_interface" != "$Interface" ]]; then |