• Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pa

    From Hank Rogers@3:633/10 to All on Fri Jun 12 16:32:21 2026
    Subject: Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pairing

    Maria Sophia wrote on 6/12/2026 4:17 PM:
    Maria Sophia wrote:
    I've streamlined adb connections over Wi-Fi between the desktop & Android >>> by eliminating the USB cable & by reducing the need for new cryptic ports. >>
    If it takes two steps, we reduce it to one, so here's a reduction in steps.

    I made the script more robust where the goal is to simplify connection when mirroring the phone over Wi-Fi (no USB) when you're at home.

    Most of the effort is tricks to get around modern Android security fences.

    :: adbconnect.bat
    :: No-USB, Wi-Fi only, adb/scrcpy static IP and static 5555 port connect
    :: 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
    :: 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)
    :: 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
    :: v1p3 20260612 moved the pipe outside the FOR command for reliability
    :: v1p4 20260612 divorced the console from the mirrored Android image
    :: so that either can be killed by the user and the other will remain
    @echo off
    setlocal enabledelayedexpansion

    set PHONE_IP=192.168.1.4
    set SCRCPY_OPTS=--keyboard=sdk --always-on-top

    echo.
    echo === ADB Wireless Auto-Connect ===
    echo Phone IP: %PHONE_IP%
    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
    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


    Wonderful Mary. Thanks for adding this value for us!

    Keep up your altruistic work.



    --- PyGate Linux v1.5.16
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From ??Jacek Marcin Jaworski??@3:633/10 to All on Mon Jun 15 11:08:43 2026
    Subject: Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pairing

    It is hard to me find any reason to use your scripts from this thread.
    Maybe they will be useful, when I return to commercial Android programming.

    But I have "a buddy-to-buddy reprimand" for you:
    Publishing files here like you did is against Netiquette. Because it is allowed only for "binary groups".
    So, if you think your scripts are useful, and you can maintain them for
    long time (for eg. 5y. - like typical commercial products), then please publish them on separate server. It can be just *.zip, or *.tar.xz
    archive on your home page (github.com is not mandatory, and I do not
    recommend it due to generating "secret debt" for their users).

    --
    Z totaliztycznym salutem!
    Jacek Marcin Jaworski, Pruszcz Gd., woj. Pomorskie, Polska ??, UE ??;
    tel.: +48-609-170-742, najlepiej w godz.: 5:00-5:55 lub 16:00-17:25; <jmj@energokod.gda.pl>, gpg: 4A541AA7A6E872318B85D7F6A651CC39244B0BFA;
    Domowa s. WWW: <https://energokod.gda.pl>;
    Mini Netykieta: <https://energokod.gda.pl/MiniNetykieta.html>;
    Mailowa Samoobrona: <https://emailselfdefense.fsf.org/pl>.
    UWAGA:
    NIE ZACI?GAJ "UKRYTEGO D?UGU"! P?A? ZA PROG. FOSS I INFO. INTERNETOWE!
    CZYTAJ DARMOWY: "17. Raport Totaliztyczny - Patroni Kontra Bankierzy": <https://energokod.gda.pl/raporty-totaliztyczne/17.%20Patroni%20Kontra%20Bankierzy.pdf>


    --- PyGate Linux v1.5.16
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Paul@3:633/10 to All on Mon Jun 15 12:11:45 2026
    Subject: Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pairing

    On Mon, 6/15/2026 5:08 AM, ??Jacek Marcin Jaworski?? wrote:
    It is hard to me find any reason to use your scripts from this thread. Maybe they will be useful, when I return to commercial Android programming.

    But I have "a buddy-to-buddy reprimand" for you:
    Publishing files here like you did is against Netiquette. Because it is allowed only for "binary groups".
    So, if you think your scripts are useful, and you can maintain them for long time (for eg. 5y. - like typical commercial products), then please publish them on separate server. It can be just *.zip, or *.tar.xz archive on your home page (github.com is not mandatory, and I do not recommend it due to generating "secret debt" for their users).


    Where did you get this strange idea ?????????????

    Script is NOT BINARY FFS. It's text.

    And anyone coming here, should review carefully anything
    of this nature they find in a posting.

    The scripts in the post, are short. Short enough
    you would spend the time reading what each command
    does, check the manual page of the command, and so on.

    A lot of the time, when someone asks for help, it will
    require working at the command line (if a GUI tool is not
    available to make a change). The instructions in the
    post you just read, are barely script quality. You
    could execute the lines one by one, in terminal if you want.

    I treat the things I find in newsgroup posts, as "conceptual ideas".
    Not generally as finished products of a commercial nature,
    complete with tech support and a free lunch.

    And I believe that the remaining people who come to USENET,
    understand this. In the same way if they went to Superuser,
    or StackExchange, they would treat any source code or script
    with the same "normal suspicion" they always use, and review
    it before using it.

    The very first time I downloaded FOSS source, I read it
    line for line, from one end to the other. 1MB of it!
    Why did I do that ? I wanted to see how practical it
    would be, to review a work properly before doing
    a make, make install. It was a lot of work. The works
    in USENET, tend to be shorter posts, like 60 lines of
    script would be a relatively long work here. And you should
    be prepared to read and research what you just copied off
    the screen, before using it. The materials may also receive
    feedback from people familiar with the code, and they may
    suggest corrections. It is then, a "work in progress".
    And if you've been here long enough, you understand all
    the dynamics.

    *******

    Treat what you see here as "illustrations" and don't
    be making up silly rules for nothing.

    If you "did not allow us to do anything technical here",
    what the hell use would this place be ?????????? Get a clue.

    Paul

    --- PyGate Linux v1.5.16
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From ??Jacek Marcin Jaworski??@3:633/10 to All on Mon Jun 15 19:24:21 2026
    Subject: Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pairing

    W dniu 15.06.2026 oÿ18:11, Paul pisze:
    Treat what you see here as "illustrations" and don't
    be making up silly rules for nothing.

    If you "did not allow us to do anything technical here",
    what the hell use would this place be ?????????? Get a clue.

    You miss one thing: she don't ask anything, but she just publish there
    her scripts like on github.com . Usenet is not intended for this except
    binary groups.

    And please don't introduce me as "mentally mad"! Because I very like discussion with cleaver and smart people. But again: this is not that case.

    BTW: I have "mentally mad" diagnosis, but this is pure evil and parasite polish government medics propaganda.

    --
    Z totaliztycznym salutem!
    Jacek Marcin Jaworski, Pruszcz Gd., woj. Pomorskie, Polska ??, UE ??;
    tel.: +48-609-170-742, najlepiej w godz.: 5:00-5:55 lub 16:00-17:25; <jmj@energokod.gda.pl>, gpg: 4A541AA7A6E872318B85D7F6A651CC39244B0BFA;
    Domowa s. WWW: <https://energokod.gda.pl>;
    Mini Netykieta: <https://energokod.gda.pl/MiniNetykieta.html>;
    Mailowa Samoobrona: <https://emailselfdefense.fsf.org/pl>.
    UWAGA:
    NIE ZACI?GAJ "UKRYTEGO D?UGU"! P?A? ZA PROG. FOSS I INFO. INTERNETOWE!
    CZYTAJ DARMOWY: "17. Raport Totaliztyczny - Patroni Kontra Bankierzy": <https://energokod.gda.pl/raporty-totaliztyczne/17.%20Patroni%20Kontra%20Bankierzy.pdf>


    --- PyGate Linux v1.5.16
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Warpinator@3:633/10 to All on Tue Jun 16 00:23:33 2026
    Subject: Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pairing

    On 15/06/2026 19:56, Maria Sophia wrote:
    The whole point, of course, is that if something takes 10 steps, we reduce
    it in half & if it takes 2 steps, we still reduce it in half (if we can).

    This is where people use Warpinator. It allows them to transfer files
    between any operating systems, including Android, iOS, macOS, Linux and Windows. Why waste time reinventing a wheel that might not even work?
    Go and try it and post your tutorial for Jacek Marcin Jaworski <jmj@energokod.gda.pl> to follow.


    --- PyGate Linux v1.5.16
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris@3:633/10 to All on Tue Jun 16 07:07:40 2026
    Subject: Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pairing

    ??Jacek Marcin Jaworski?? <jmj@energokod.gda.pl> wrote:
    It is hard to me find any reason to use your scripts from this thread.
    Maybe they will be useful, when I return to commercial Android programming.

    But I have "a buddy-to-buddy reprimand" for you:
    Publishing files here like you did is against Netiquette. Because it is allowed only for "binary groups".
    So, if you think your scripts are useful, and you can maintain them for
    long time (for eg. 5y. - like typical commercial products), then please publish them on separate server. It can be just *.zip, or *.tar.xz
    archive on your home page (github.com is not mandatory, and I do not recommend it due to generating "secret debt" for their users).

    I agree that pointing to a stable online resource designed for code is so
    much better than this particular poster's constant tweaking of their
    personal scripts on usenet.

    I mean, how is anyone meant to know which is the final and definitive
    version without trawling through screeds of threads? Assuming they even
    work outside of his very non-standard set up.

    You're flogging an already dead and turned into dog food horse. I've made
    the same suggestion to "Arlen" several times over the years, but he refuses
    for "privacy" reasons (sic). He just doesn't understand how internet
    anonymity really works.


    --- PyGate Linux v1.5.17
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Carlos E. R.@3:633/10 to All on Tue Jun 16 12:15:14 2026
    Subject: Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pairing

    On 2026-06-16 02:18, Maria Sophia wrote:
    Apparently LocalSend has a more mature GUI but the Linux Warpinator GUI is apparently tried and true, so it's a good choice for the Linux team. It's especially useful on Mint systems as it comes pre-installed by default.

    It is available on openSUSE Leap 16.0.
    I never heard of it.

    --
    Cheers,
    Carlos E.R.
    ES??, EU??;

    --- PyGate Linux v1.5.17
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Carlos E. R.@3:633/10 to All on Tue Jun 16 12:30:26 2026
    Subject: Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pairing

    On 2026-06-16 09:21, Maria Sophia wrote:
    Chris wrote:
    I agree that pointing to a stable online resource designed for code is so
    much better than this particular poster's constant tweaking of their
    personal scripts on usenet.

    Hi Chris,

    C'mon. You're actually complaining that I provided fully working Windows scripts, and that I improved them, and that I ported them to Linux for you?

    You do not understand the criticism. Or you feign not understanding.

    The rest of the post is unrelated, thus deleted


    --
    Cheers,
    Carlos E.R.
    ES??, EU??;

    --- PyGate Linux v1.5.17
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris@3:633/10 to All on Tue Jun 16 12:10:46 2026
    Subject: Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pairing

    Maria Sophia <mariasophia@comprehension.com> wrote:
    Chris wrote:
    I agree that pointing to a stable online resource designed for code is so
    much better than this particular poster's constant tweaking of their
    personal scripts on usenet.

    Hi Chris,

    C'mon. You're actually complaining that I provided fully working Windows scripts, and that I improved them, and that I ported them to Linux for you?

    Nope. Try comprehending what I actually wrote rather than responding to something I didn't.



    --- PyGate Linux v1.5.17
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Carlos E. R.@3:633/10 to All on Tue Jun 16 20:11:43 2026
    Subject: Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pairing

    On 2026-06-16 19:07, Maria Sophia wrote:
    Carlos E. R. wrote:
    C'mon. You're actually complaining that I provided fully working Windows >>> scripts, and that I improved them, and that I ported them to Linux for you? >>
    You do not understand the criticism.

    If Chris had even once in his entire life ever invested the time and energy to post a working tutorial or PSA or working code that he labored on to
    help himself and others, I'd understand better his complaint that he can't.

    Accusing others doesn't change facts.

    --
    Cheers,
    Carlos E.R.
    ES??, EU??;

    --- PyGate Linux v1.5.17
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Carlos E. R.@3:633/10 to All on Tue Jun 16 22:47:39 2026
    Subject: Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pairing

    On 2026-06-16 21:40, Maria Sophia wrote:
    Carlos E. R. wrote:
    On 2026-06-16 19:07, Maria Sophia wrote:
    Carlos E. R. wrote:
    C'mon. You're actually complaining that I provided fully working Windows >>>>> scripts, and that I improved them, and that I ported them to Linux for you?

    You do not understand the criticism.

    If Chris had even once in his entire life ever invested the time and energy >>> to post a working tutorial or PSA or working code that he labored on to
    help himself and others, I'd understand better his complaint that he can't. >>
    Accusing others doesn't change facts.

    Well, I'm going to ask *you* to provide something that is worth value.

    Given I've posted, oh, I don't know, hundreds of useful scripts...
    Q: What specific web site do you suggest I post the final script to?

    Up to you, and it wasn't my idea, anyway :-)

    I have never done this, so I can not advise

    You could use github, or hire a server of your own somewhere. Or set up
    a server at home. Sourceforge, perhaps (this one I have used).

    a. It needs to have no requirement for a login/account
    b. It needs to be free
    c. It needs to be easy to post to (and to update, if necessary)?
    A: ???

    To help you add value (instead of just complaining I add too much value),
    all I ask you to do is answer the question above so that I can post it.

    Here's a README description of how it simplifies Wi-Fi adb/scrcpy usage
    which should help you find the location you claim I should post it to.


    No, this is not relevant to the question.


    --
    Cheers,
    Carlos E.R.
    ES??, EU??;

    --- PyGate Linux v1.5.17
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris@3:633/10 to All on Tue Jun 16 23:34:58 2026
    Subject: Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pairing

    Maria Sophia <mariasophia@comprehension.com> wrote:
    Chris wrote:
    I agree that pointing to a stable online resource designed for code is so >>>> much better than this particular poster's constant tweaking of their
    personal scripts on usenet.

    Hi Chris,

    C'mon. You're actually complaining that I provided fully working Windows >>> scripts, and that I improved them, and that I ported them to Linux for you? >>
    Nope. Try comprehending what I actually wrote rather than responding to
    something I didn't.


    In your entire life, how many times have you invested the time and energy
    to post a working tutorial or PSA or working code that you labored on to
    help yourself and others, and where did you post that working example to?

    Given I'm a University academic teaching Masters students and supervise PhD students, plus I've provided professional training to other academics in software coding principles; quite a lot.

    *I* have posted those on github (search Software Carpentry lessons for an
    idea of the kind of thing), on internal student teaching platforms and
    staff sharepoint sites. If *I* referenced ("thousands", lol) unfindable so-called tutorials on usenet in my appraisals, I'd lose all credibility.

    In a former life, I also contributed to the codebase of a linux
    distribution. Anonymously <gasp>!

    This is why *I* know what *I* am talking about.

    Now, back to *you*. What help do *you* need to do things properly?


    --- PyGate Linux v1.5.17
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From ....winston@3:633/10 to All on Tue Jun 16 19:47:04 2026
    Subject: Re: PSA: Streamlined persistent ADB port over Wi?Fi without repeated pairing

    On 06/16/2026 3:40 PM, Maria Sophia wrote:
    Carlos E. R. wrote:
    On 2026-06-16 19:07, Maria Sophia wrote:
    Carlos E. R. wrote:
    C'mon. You're actually complaining that I provided fully working Windows >>>>> scripts, and that I improved them, and that I ported them to Linux for you?

    You do not understand the criticism.

    If Chris had even once in his entire life ever invested the time and energy >>> to post a working tutorial or PSA or working code that he labored on to
    help himself and others, I'd understand better his complaint that he can't. >>
    Accusing others doesn't change facts.

    Well, I'm going to ask *you* to provide something that is worth value.


    At this stage...those requests(to anyone) get closer the edge of pettiness.

    Be confident in your content, regardless of the feedback especially when
    few reply on its value.
    - for a better assessment of what's been read, a blog might prove more visits, then just a simple link to the blog article would/could be
    appropriate for nntp users.


    --
    ...w­¤?ñ?¤

    --- PyGate Linux v1.5.17
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)