aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-09 20:27:58 +0100
committerDanilo M. <danix@danix.xyz>2026-11-09 20:27:58 +0100
commitf59efbd2df7b33ea8d8320b6cd29792986ea8023 (patch)
treeed27718f71e9cd3530dd195bd36df6fc8f168ffd
parentdccb95bfc2c15495136441765dbc7633ded5b62e (diff)
downloaddeck-it-f59efbd2df7b33ea8d8320b6cd29792986ea8023.tar.gz
deck-it-f59efbd2df7b33ea8d8320b6cd29792986ea8023.zip
fix: wifi uses an explicit address and survives adb without mDNS
-rwxr-xr-xdeck-it17
1 files changed, 14 insertions, 3 deletions
diff --git a/deck-it b/deck-it
index dd434ff..1ce6390 100755
--- a/deck-it
+++ b/deck-it
@@ -64,11 +64,14 @@ alive() {
wifi_connect() {
local addr
- # An existing TCP connection first: mDNS is not always advertising.
- for addr in $(adb devices | awk 'NR > 1 && $2 == "device" && $1 ~ /:/ {print $1}'); do
+ # An explicit address, or the last one used. Never "any TCP device": a TV
+ # or another device with ADB on the network would be picked instead.
+ for addr in ${WIFI_ADDR:-} $(cat "$RUN/serial" 2>/dev/null); do
+ [ -n "$addr" ] || continue
+ timeout 5 adb connect "$addr" 2>/dev/null | grep -q '^connected\|already connected' || true
alive "$addr" && { echo "$addr"; return 0; }
done
- for addr in $(adb mdns services | awk '/_adb-tls-connect/ {print $NF}' | sort -u); do
+ for addr in $(adb mdns services 2>/dev/null | awk '/_adb-tls-connect/ {print $NF}' | sort -u); do
timeout 5 adb connect "$addr" 2>/dev/null | grep -q '^connected\|already connected' &&
alive "$addr" && { echo "$addr"; return 0; }
done
@@ -90,6 +93,13 @@ teardown)
exit 0
;;
pair)
+ if ! adb mdns services >/dev/null 2>&1; then
+ echo "This adb has no mDNS discovery. Pair from the tablet instead:"
+ echo " Developer options > Wireless debugging > Pair device with pairing code"
+ echo " adb pair <ip>:<pair-port> <code>"
+ echo " adb connect <ip>:<connect-port>"
+ exit 1
+ fi
command -v qrencode >/dev/null || { echo "Install qrencode first"; exit 1; }
name="deck-it-$(tr -dc a-z0-9 </dev/urandom | head -c 8)"
pass=$(tr -dc 0-9 </dev/urandom | head -c 8)
@@ -151,6 +161,7 @@ watch-usb)
done
;;
wifi)
+ if [[ "${2:-}" == *:* ]]; then WIFI_ADDR="$2"; fi
echo "Looking for the tablet on Wi-Fi..."
while :; do
[[ "${2:-}" == --wait ]] && usb_present && { echo "Tablet is on USB, leaving it to the USB start"; exit 0; }