Poll up to 45s for the tether after Connect instead of a fixed 4s sleep
First plug-in after a reboot takes iOS 20-30s to bring the interface up and complete DHCP; the 4s sleep reported false 'enable hotspot' advice when the hotspot was already on. Also broadens the failure advice (unlock once after phone restart, replug as last resort). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
7356dce619
commit
1eb5e17ee7
1 changed files with 26 additions and 6 deletions
32
omatether.sh
32
omatether.sh
|
|
@ -71,6 +71,21 @@ net_test() {
|
||||||
curl -sf --interface "$iface" --max-time 5 -o /dev/null https://www.google.com
|
curl -sf --interface "$iface" --max-time 5 -o /dev/null https://www.google.com
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Poll until the tether has an IP and working internet, or time out (arg:
|
||||||
|
# seconds). First plug-in after a reboot can take 20-30s before iOS brings
|
||||||
|
# the interface up and DHCP completes — a fixed short sleep reports false
|
||||||
|
# "enable hotspot" advice.
|
||||||
|
tether_wait() {
|
||||||
|
local deadline=$(( SECONDS + ${1:-45} )) iface
|
||||||
|
while (( SECONDS < deadline )); do
|
||||||
|
if iface=$(tether_iface) && [[ -n $(tether_ip "$iface") ]] && net_test "$iface"; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# usbmuxd drops devices that were plugged in before it started
|
# usbmuxd drops devices that were plugged in before it started
|
||||||
# ("device unconfigured") — a restart rescans the bus.
|
# ("device unconfigured") — a restart rescans the bus.
|
||||||
revive_usbmuxd() {
|
revive_usbmuxd() {
|
||||||
|
|
@ -382,14 +397,19 @@ tui_connect() {
|
||||||
ok "Paired with $(phone_name)"
|
ok "Paired with $(phone_name)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Give networkd a moment to DHCP the freshly-authorised interface.
|
# Poll for the connection — first plug-in after a reboot can take 20-30s
|
||||||
|
# (functions exported so the gum spin child shell can run them).
|
||||||
local iface=""
|
local iface=""
|
||||||
gum spin --title "Bringing the connection up…" -- sleep 4 || true
|
export -f tether_wait tether_iface tether_ip net_test
|
||||||
if iface=$(tether_iface) && [[ -n $(tether_ip "$iface") ]] && net_test "$iface"; then
|
if gum spin --title "Bringing the connection up… (can take ~30s after a reboot)" -- \
|
||||||
ok "Connected — internet available through the phone ($iface)"
|
bash -c 'tether_wait 45'; then
|
||||||
|
iface=$(tether_iface || true)
|
||||||
|
ok "Connected — internet available through the phone (${iface:-tether})"
|
||||||
else
|
else
|
||||||
warn "Paired, but no connection yet. On the phone enable:"
|
warn "Paired, but the phone hasn't offered a connection yet. Check:"
|
||||||
say " Settings → Personal Hotspot → Allow Others to Join: ON"
|
say " • Settings → Personal Hotspot → Allow Others to Join: ON"
|
||||||
|
say " • Unlock the phone once (needed after a phone restart)"
|
||||||
|
say " • Still nothing? Unplug and replug the cable, then Connect again."
|
||||||
fi
|
fi
|
||||||
pause
|
pause
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue