Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.os.linux > #82802
| From | Maria Sophia <mariasophia@comprehension.com> |
|---|---|
| Newsgroups | alt.os.linux, comp.mobile.android, alt.comp.os.windows-10 |
| Subject | Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing |
| Date | 2026-06-13 11:31 -0500 |
| Organization | BWH Usenet Archive (https://usenet.blueworldhosting.com) |
| Message-ID | <110k0lo$1ecm$1@nnrp.usenet.blueworldhosting.com> (permalink) |
| References | <110b60u$25n1$1@nnrp.usenet.blueworldhosting.com> <110fs49$lu4$1@nnrp.usenet.blueworldhosting.com> <110ht1h$27co$1@nnrp.usenet.blueworldhosting.com> <110htt5$2groe$1@dont-email.me> |
Cross-posted to 3 groups.
UPDATE:
Since others may be using this script, I updated it to ask for the LAN IP
address and I converted it to a Linux script (which needs to be tested).
:: adbconnect.bat
:: No-USB, Wi-Fi only, adb/scrcpy static IP and static 5555 port connect
:: v1p5 20260613 Added query asking for the LAN IP address of the phone
:: Reordered comments to allow the current version to be obvious
:: v1p4 20260612 divorced the console from the mirrored Android image
:: so that either can be killed by the user and the other will remain
:: v1p3 20260612 moved the pipe outside the FOR command for reliability
:: v1p2 20260611 further reliability improvements added to v1p1
:: Use separate retry counters for pair/connect to avoid loop
:: interference (ATTEMPTS_PAIR, ATTEMPTS_CONN)
:: Added fail-fast with clear error codes and user hints after retry
:: exhaustion
:: Added a detection of the device id after initial connect
:: (handles ephemeral adb ports like 192.168.1.4:54321)
:: Use DEVICE_ID for subsequent -s tcpip command (quoted)
:: to avoid parsing issues with colons
:: Fallback device-id lookup when initial pattern match fails
:: (robust parsing of "adb devices")
:: Consistent quoting of %ADB% and device identifiers to avoid
:: CMD parsing errors
:: v1p1 20260611 reliability improvements added to v1p0
:: Added better device lookup (skip header,ignore blanks,avoid false matches)
:: Added retry logic for adb pair & adb connect (for when phone not ready)
:: Improved polish (consistent quoting, stable scrcpy launch)
:: v1p0 20260611 converted adbconnect.vbs to adbconnect.bat
:: Connects desktop & phone over adb & mirrors phone on the monitor
:: No USB cord is used in this process as it's all done over Wi-Fi
:: Should work even if either the PC and/or the phone is rebooted
:: The script will ask only for the minimum amount of data needed
:: Change the phone static IP address as needed to fit your LAN IP address
@echo off
setlocal enabledelayedexpansion
:: For phones with static IP addresses, change the next line
set PHONE_IP=192.168.1.4
set SCRCPY_OPTS=--keyboard=sdk --always-on-top
echo.
echo === ADB Wireless Auto-Connect ===
echo === [Developer options > Wireless debugging > on] ===
echo.
REM 1. Find adb
for /f "delims=" %%A in ('where adb 2^>nul') do (
if not defined ADB set ADB=%%A
)
if not defined ADB (
echo [ERROR] adb.exe not found.
exit /b
)
REM Ensure .exe extension
if /i not "%ADB:~-4%"==".exe" set ADB=%ADB%.exe
echo Using ADB: "%ADB%"
echo.
REM 2. Check if already connected
echo Checking existing ADB devices...
REM v1p1 fixed device lookup:
REM a. skip header line
REM b. ignore blank lines
REM c. only process lines containing digits
REM d. avoid CMD parser bugs by NOT piping inside the FOR command
REM v1p3 moved pipe OUTSIDE the for loop
:: for /f "skip=1 tokens=1" %%D in ('"%ADB%" devices') do (
set DEVICE_ID=
for /f "skip=1 tokens=1" %%I in ('"%ADB%" devices') do (
echo %%I | findstr /R "[0-9]" >nul && (
echo %%I | findstr /I "%PHONE_IP%" >nul && (
if not defined DEVICE_ID set DEVICE_ID=%%I
)
)
)
if defined DEVICE_ID (
echo Already connected on %DEVICE_ID%
goto RUN_TCPIP
)
echo %%D | findstr /R "[0-9]" >nul && (
echo %%D | findstr /i "%PHONE_IP%" >nul && (
echo Already connected on %%D
set DEVICE_ID=%%D
goto RUN_TCPIP
)
)
)
echo Not connected. Need to pair.
echo.
REM 3. Ask user for pairing info
echo Necessary pairing information will be shown on the phone:
set /p PHONE_IP=Enter phone IP [%PHONE_IP%] :
set /p PAIR_PORT=Enter Wireless debugging pairing port (shown on phone):
set /p PAIR_CODE=Enter Wireless debugging pairing code (shown on phone):
set /p DEBUG_PORT=Enter Wireless debugging debug port (shown on phone):
echo.
echo Pairing with: %PHONE_IP%:%PAIR_PORT%
REM Retry logic for adb pair (3 attempts)
set ATTEMPTS_PAIR=0
:PAIR_RETRY
set /a ATTEMPTS_PAIR+=1
"%ADB%" pair %PHONE_IP%:%PAIR_PORT% %PAIR_CODE%
if errorlevel 1 (
if !ATTEMPTS_PAIR! lss 3 (
echo Pair failed, retrying...
timeout /t 2 >nul
goto PAIR_RETRY
) else (
echo [ERROR] adb pair failed after %ATTEMPTS_PAIR% attempts.
echo Hint: Open Wireless debugging -> "Pair device with pairing code" on the phone, then re-run this script.
exit /b 1
)
)
echo.
echo Connecting to debug port: %PHONE_IP%:%DEBUG_PORT%
REM Retry logic for adb connect (3 attempts)
set ATTEMPTS_CONN=0
:CONNECT_RETRY
set /a ATTEMPTS_CONN+=1
"%ADB%" connect %PHONE_IP%:%DEBUG_PORT%
if errorlevel 1 (
if !ATTEMPTS_CONN! lss 3 (
echo Connect failed, retrying...
timeout /t 2 >nul
goto CONNECT_RETRY
) else (
echo [ERROR] adb connect %PHONE_IP%:%DEBUG_PORT% failed after %ATTEMPTS_CONN% attempts.
echo Hint: Ensure phone is on the same Wi-Fi and Wireless debugging pairing UI is active.
exit /b 2
)
)
echo.
REM After connect, get the actual device id reported by adb (handles ephemeral ports)
set DEVICE_ID=
for /f "tokens=1" %%I in ('"%ADB%" devices ^| findstr /R /C:"%PHONE_IP%[: ]"') do (
if not defined DEVICE_ID set DEVICE_ID=%%I
)
if not defined DEVICE_ID (
REM fallback: try to find any non-empty device id line
for /f "skip=1 tokens=1" %%I in ('"%ADB%" devices') do (
echo %%I | findstr /R "[0-9]" >nul && if not defined DEVICE_ID set DEVICE_ID=%%I
)
)
if defined DEVICE_ID (
echo Found device id: "%DEVICE_ID%"
) else (
echo [WARN] No device id found after connect. Continuing using %PHONE_IP%:%DEBUG_PORT% for tcpip attempt.
set DEVICE_ID=%PHONE_IP%:%DEBUG_PORT%
)
echo Switching to TCP/IP 5555...
"%ADB%" -s "%DEVICE_ID%" tcpip 5555
echo.
echo Connecting final port: %PHONE_IP%:5555
"%ADB%" connect %PHONE_IP%:5555
echo.
set DEVICE_ID=%PHONE_IP%:5555
goto RUN_SCRCPY
:RUN_TCPIP
echo Switching device !DEVICE_ID! to TCP/IP 5555...
"%ADB%" -s "%DEVICE_ID%" tcpip 5555
"%ADB%" connect "%PHONE_IP%:5555"
goto RUN_SCRCPY
:RUN_SCRCPY
:: Launch scrcpy in a detached process so the console can be killed
:: v1p4 Divorced the console from the mirrored image and vice versa
:: start "" /B scrcpy.exe --tcpip=%PHONE_IP% %SCRCPY_OPTS% >nul 2>&1
echo Launching scrcpy...
start "" scrcpy.exe --tcpip=%PHONE_IP% %SCRCPY_OPTS% >nul 2>&1
echo(
exit /b
REM end of adbconnect.bat
===== Linux script below (untested!) needs to be tested =====
#!/usr/bin/env bash
#
# adbconnect.sh
# Wi-Fi-only ADB + scrcpy auto-connect
# Linux bash version of adbconnect.bat
# v1p5 (20260613)
#
set -euo pipefail
# --- USER CONFIG ---
PHONE_IP="192.168.1.4"
SCRCPY_OPTS="--keyboard=sdk --always-on-top"
# --- FUNCTIONS ---
find_adb() {
if command -v adb >/dev/null 2>&1; then
ADB="$(command -v adb)"
else
echo "[ERROR] adb not found in PATH"
exit 1
fi
}
get_device_id() {
DEVICE_ID="$(adb devices | awk -v ip="$PHONE_IP" '
NR>1 && $1 ~ ip {print $1}
')"
if [[ -z "$DEVICE_ID" ]]; then
DEVICE_ID="$(adb devices | awk '
NR>1 && $1 ~ /[0-9]/ {print $1; exit}
')"
fi
}
retry_cmd() {
local attempts=$1
shift
local cmd=("$@")
for ((i=1; i<=attempts; i++)); do
if "${cmd[@]}"; then
return 0
fi
echo "Attempt $i failed, retrying..."
sleep 2
done
return 1
}
# --- MAIN ---
echo
echo "=== ADB Wireless Auto-Connect (Linux) ==="
echo "=== Enable: Developer options -> Wireless debugging ==="
echo
find_adb
echo "Using ADB: $ADB"
echo
echo "Checking existing ADB devices..."
get_device_id
if [[ -n "${DEVICE_ID:-}" ]]; then
echo "Already connected on $DEVICE_ID"
echo "Switching to TCP/IP 5555..."
adb -s "$DEVICE_ID" tcpip 5555
adb connect "$PHONE_IP:5555"
DEVICE_ID="$PHONE_IP:5555"
else
echo "Not connected. Need to pair."
echo
read -rp "Enter phone IP [$PHONE_IP]: " ip_in
[[ -n "$ip_in" ]] && PHONE_IP="$ip_in"
read -rp "Enter pairing port: " PAIR_PORT
read -rp "Enter pairing code: " PAIR_CODE
read -rp "Enter debug port: " DEBUG_PORT
echo
echo
# end of adbconnect.sh
--
On Usenet are helpful kind-hearted volunteers who know how do to things.
And then, there are the trolls... who do not.
Back to alt.os.linux | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-10 02:07 -0600
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-11 21:49 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-12 16:17 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Hank Rogers <Hank@nospam.invalid> - 2026-06-12 16:32 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Give It A Try <try.it@invalid.invalid> - 2026-06-12 23:20 +0100
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-13 11:31 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing 🇵🇱Jacek Marcin Jaworski🇵🇱 <jmj@energokod.gda.pl> - 2026-06-15 11:08 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Paul <nospam@needed.invalid> - 2026-06-15 12:11 -0400
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing 🇵🇱Jacek Marcin Jaworski🇵🇱 <jmj@energokod.gda.pl> - 2026-06-15 19:24 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-15 14:10 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-15 14:43 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing vallor <vallor@vallor.earth> - 2026-06-17 00:16 +0000
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 23:23 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-15 13:56 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Warpinator <invalid@invalid.invalid> - 2026-06-16 00:23 +0100
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-15 19:18 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing "Carlos E. R." <robin_listas@es.invalid> - 2026-06-16 12:15 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-30 22:12 -0400
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing "Carlos E. R." <robin_listas@es.invalid> - 2026-07-01 11:51 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-07-01 13:57 -0400
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Chris <ithinkiam@gmail.com> - 2026-06-16 07:07 +0000
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 02:21 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing "Carlos E. R." <robin_listas@es.invalid> - 2026-06-16 12:30 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 12:07 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing "Carlos E. R." <robin_listas@es.invalid> - 2026-06-16 20:11 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 14:40 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing "Carlos E. R." <robin_listas@es.invalid> - 2026-06-16 22:47 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 15:51 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing "Carlos E. R." <robin_listas@es.invalid> - 2026-06-18 00:45 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Hank Rogers <Hank@nospam.invalid> - 2026-06-17 17:56 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-30 21:46 -0400
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing "....winston" <winstonmvp@gmail.com> - 2026-06-16 19:47 -0400
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 23:26 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Chris <ithinkiam@gmail.com> - 2026-06-16 12:10 +0000
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 12:09 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-26 06:38 -0400
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-20 02:22 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-20 02:31 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-21 00:53 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-27 08:58 -0400
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Nadia Jarvis <invalid@invalid.invalid> - 2026-06-27 19:38 +0100
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Hank Rogers <Hank@nospam.invalid> - 2026-06-27 19:53 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-27 23:01 -0600
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-30 21:40 -0400
csiph-web