Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.os.linux > #82885
| 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-30 22:12 -0400 |
| Organization | BWH Usenet Archive (https://usenet.blueworldhosting.com) |
| Message-ID | <1121t2s$1j5e$1@nnrp.usenet.blueworldhosting.com> (permalink) |
| References | (2 earlier) <110p881$fqua$1@dont-email.me> <110phsu$1ku4$1@nnrp.usenet.blueworldhosting.com> <jU%XR.118310$SHu9.73006@fx45.iad> <110q4op$nt5$1@nnrp.usenet.blueworldhosting.com> <n9cm1iFas8nU1@mid.individual.net> |
Cross-posted to 3 groups.
Since adb is as essential to Android as ls is to Linux or dir to Windows,
it's important to note that ADB plus scrcpy started as USB-only until
Android 11 introduced secure Wi-Fi pairing with a pairing code plus random
port that we had to literally L@@K at in order to know them, but then
Android 12 refined this with TLS-based pairing that no longer required us
to manually know or even care about the specific Wireless connection port.
<https://gadgetguideonline.com/android/android-adb-wireless-debugging/>
For operating a phone on desktop monitor/mouse/keyboard/clipboard/speakers
scrcpy itself does not implement wireless protocols because screen copy
simply uses whatever ADB transport is active.
a. USB debugging -> scrcpy works immediately.
b. ADB over TCP/IP (manual or automatic) -> scrcpy works over Wi-Fi.
c. Wireless debugging (Android 11+) -> scrcpy works after pairing
scrcpy added convenience flags like --tcpip to automate enabling ADB over
Wi-Fi, but the underlying connection rules come from Android's ADB system.
To make those connections a single-step process, I wrote the three scripts
which are pasted in cleartext in this thread so that others can benefit.
$ adbconnectusb.bat (USB debugging, classic, pre-Android-11)
$ adbconnect.bat (ADB over TCP/IP, manual Wi-Fi mode, pre-Android-11)
$ adbconnecttls.bat (Wireless Debugging with pairing, Android 11+)
$ adbdebugtls.bat (TLS Wireless Debugging, Android 12+)
They turn multi-step ADB commands into single-action shortcuts,
so scrcpy can immediately attach to whichever transport is active.
Below is the latest adbconnect script, with the latest bugfixes.
I should probably rename it adbconnecttcp.bat to line up conventions.
:: adbconnect.bat
:: Android-to-desktop Wi-Fi adb and scrcpy connections
:: Connects Android 11 and Android 12+ devices to adb and scrcpy using
:: pairing mode and classic TCPIP mode. This script uses the Android
:: Wireless Debugging pairing workflow to obtain the pairing port,
:: pairing code and debug port from the phone. It then performs adb
:: pair and adb connect with retry logic, switches the device to TCPIP
:: port 5555 and launches scrcpy silently. This script does not use TLS
:: for the scrcpy connection, but it depends on Wireless Debugging
:: being active because Wireless Debugging controls whether adbd is
:: reachable. Once TCPIP mode is enabled, the script reconnects to
:: port 5555 and starts scrcpy over classic TCPIP mode.
::
:: 1. Eliminates the useless scrcpy console window which takes up space
:: 2. Eliminates random security steps in Wi-Fi adb connections
:: 3. Solves reconnection problems when
:: a. The phone leaves the LAN and returns
:: b. The PC is rebooted
:: c. The phone is rebooted
:: d. A connection is attempted when already connected
:: Uses Wireless Debugging mode plus classic TCPIP ADB mode.
:: Wireless Debugging does not open port 5555 by itself.
:: Classic ADB-over-WiFi can use port 5555 to simplify reconnects.
:: Running adb tcpip 5555 forces Android to open port 5555 even in
:: Wireless Debugging mode. This makes reconnections simpler because
:: the phone stays open on port 5555 even if
:: a. the phone leaves and rejoins the LAN
:: b. the PC reboots
:: c. scrcpy drops and reconnects
:: Port 5555 remains active until the phone reboots because Android
:: rebooting disables Wireless Debugging and closes the TCPIP daemon.
::
:: USB authorization can eliminate pairing codes
:: i. Connect via USB
:: ii. adb connect PHONE_IP:5555
:: iii. scrcpy --tcpip=PHONE_IP
::
:: If a USB device is present and authorized, adb devices will show
:: PHONE_IP:5555 device
:: You cannot get device state without USB authorization
::
:: Android 12+ introduced ADB-over-TLS auto-advertised via mDNS.
:: It auto-connects over encrypted channels without pairing or ports.
:: It appears as adb-SERIAL-GUID._adb-tls-connect._tcp
:: Wireless Debugging controls whether this TLS service is awake.
:: scrcpy cannot use the TLS auto-connect device directly.
::
:: This script uses pairing mode and TCPIP mode only.
:: TLS auto-connect is not used for scrcpy, but TLS must be awake
:: for adbd to be reachable.
::
:: v2p5 20260630
:: Cleaned up the descriptions by summarizing the version comments.
::
:: v2p4 20260630
:: Added version output string and improved explanations
::
:: v2p3 20260624
:: Added ability to detect if USB authentication was already done
::
:: v2p2 20260622
:: Improved handling of offline and unauthorized states
::
:: v2p1 20260621
:: Added SUMMARY system for executed commands
::
:: v2p0 20260621
:: Restored working version from v1p7
::
:: v1p9 20260620
:: Removed debug-port connect step which broke Wireless Debugging
::
:: v1p8 20260619
:: Removed debug-port connect step which broke Wireless Debugging
::
:: v1p7 20260615
:: Removed requirement for scrcpy-noconsole.vbs
::
:: v1p6 20260614
:: Added VBS no-console launcher fallback
::
:: v1p5 20260613
:: Added query asking for phone LAN IP address
::
:: v1p4 20260612
:: Minimized scrcpy console window
::
:: v1p3 20260612
:: Improved reliability of adb devices parsing
::
:: v1p2 20260611
:: Added retry logic and improved device-id handling
::
:: v1p1 20260611
:: Improved device lookup and reliability
::
:: v1p0 20260611
:: Converted adbconnect.vbs to adbconnect.bat
:: Connects desktop and phone over Wi-Fi using adb and scrcpy
:: No USB cord required
@echo off
:: vi. debugging can be removed later
:: echo MARK 1
setlocal enabledelayedexpansion
:: Version string
set SCRIPT_VERSION=v2p5
set SCRIPT_DATE=20260630
echo ============================================
echo ADB-over-TLS to TCPIP Launcher Debug Mode
echo Running adbconnect.bat %SCRIPT_VERSION% %SCRIPT_DATE%
echo ============================================
echo.
:: initialize temp summary file
set SUMMARY_FILE=%TEMP%\adbconnect_summary.txt
if exist "%SUMMARY_FILE%" del "%SUMMARY_FILE%"
:: On 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
:: REM ii. debugging (can be removed later)
:: if defined TRACE echo BEFORE FIRST FOR
:: REM vii. debugging can be removed later
:: echo MARK 2
for /f "delims=" %%A in ('where adb 2^>nul') do (
if not defined ADB set ADB=%%A
)
:: REM viii. debugging can be removed later
:: echo MARK 3
:: REM iii. debugging (can be removed later)
:: if defined TRACE echo AFTER FIRST FOR
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 i. debugging (can be removed later)
:: set TRACE=1
set DEVICE_ID=
set DEVICE_STATE=
REM Do not add extra quotes here as all these break batch parsing!
:: '"%ADB%" devices'
:: "%ADB%" devices
:: '"%ADB%" devices"'
:: '"%ADB%" devices"'
:: REM iv. debugging can be removed later
:: if defined TRACE echo BEFORE SECOND FOR
:: REM ix. debugging can be removed later
:: echo MARK 4
for /f "skip=1 tokens=1,2" %%I in ('%ADB% devices') do (
echo %%I | findstr /I "%PHONE_IP%" >nul && (
if not defined DEVICE_ID (
set DEVICE_ID=%%I
set DEVICE_STATE=%%J
)
)
)
:: REM x. debugging can be removed later
:: echo MARK 5
:: REM v. debugging can be removed later
:: if defined TRACE echo AFTER SECOND FOR
REM treat only "device" as connected
:: echo MARK 6
echo DEVICE_ID="%DEVICE_ID%" DEVICE_STATE="%DEVICE_STATE%"
REM if no device id, skip to NOT_CONNECTED
if "%DEVICE_ID%"=="" goto NOT_CONNECTED
REM if state is not "device", skip to NOT_CONNECTED
if /I not "%DEVICE_STATE%"=="device" goto NOT_CONNECTED
echo Already connected on %DEVICE_ID%
echo adb devices>>"%SUMMARY_FILE%"
REM skip redundant tcpip if already on 5555
if /I "%DEVICE_ID:~-5%"==":5555" (
echo Device already on port 5555. Skipping tcpip switch.
goto RUN_SCRCPY
)
goto RUN_TCPIP
:NOT_CONNECTED
:: echo MARK 8
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=Phone IP [%PHONE_IP%] :
set /p PAIR_PORT=Wireless debugging pairing port:
set /p PAIR_CODE=Wireless debugging pairing code:
set /p DEBUG_PORT=Wireless debugging debug port:
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 not errorlevel 1 (
echo adb pair %PHONE_IP%:%PAIR_PORT% %PAIR_CODE%>>"%SUMMARY_FILE%"
)
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.
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 not errorlevel 1 (
echo adb connect %PHONE_IP%:%DEBUG_PORT%>>"%SUMMARY_FILE%"
)
REM wait a few seconds for the Android adb daemon to be ready
timeout /t 2 >nul
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.
exit /b 2
)
)
echo.
REM Do not add extra quotes here as all these break batch parsing!
:: '"%ADB%" devices'
:: "%ADB%" devices
:: '"%ADB%" devices"'
:: '"%ADB%" devices"'
REM After connect, get the actual device id
set DEVICE_ID=
for /f "tokens=1" %%I in ('%ADB% devices ^| findstr /C:"%PHONE_IP%:"') do (
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.
set DEVICE_ID=%PHONE_IP%:%DEBUG_PORT%
)
goto RUN_TCPIP
:RUN_TCPIP
echo Switching device %DEVICE_ID% to TCP/IP 5555...
"%ADB%" -s "%DEVICE_ID%" tcpip 5555
if not errorlevel 1 echo adb -s %DEVICE_ID% tcpip 5555>>"%SUMMARY_FILE%"
echo Connecting final port: %PHONE_IP%:5555
"%ADB%" connect %PHONE_IP%:5555
if not errorlevel 1 echo adb connect %PHONE_IP%:5555>>"%SUMMARY_FILE%"
set DEVICE_ID=%PHONE_IP%:5555
:RUN_SCRCPY
echo Launching scrcpy completely silent...
set "VBS_TEMP=%TEMP%\scrcpy_runner.vbs"
echo strCommand = "cmd /c scrcpy.exe --tcpip=%PHONE_IP% %SCRCPY_OPTS%" > "%VBS_TEMP%"
echo CreateObject("Wscript.Shell").Run strCommand, 0, false >> "%VBS_TEMP%"
echo scrcpy --tcpip=%PHONE_IP% %SCRCPY_OPTS%>>"%SUMMARY_FILE%"
wscript.exe "%VBS_TEMP%"
timeout /t 1 >nul
if exist "%VBS_TEMP%" del "%VBS_TEMP%"
echo Done.
echo.
echo Summary of steps run in this instance:
type "%SUMMARY_FILE%"
echo.
echo.
echo.
exit /b
REM end of adbconnect.bat
--
Usenet is a team sport where each person adds unique value their own way.
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