Created
May 7, 2020 08:35
-
-
Save jjv360/19e591a3b94b1fce64f635661d20954c to your computer and use it in GitHub Desktop.
Start WiFi debugging an Android device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rem | |
rem Connect to android device for debugging over WiFi | |
rem | |
rem Setup | |
echo off | |
cls | |
rem Header | |
echo. | |
echo +----------------------+ | |
echo ^| ADB WiFi Debug ^| | |
echo +----------------------+ | |
echo v1 | |
echo. | |
rem Set ADB to USB mode | |
echo ^> Setting ADB to USB mode... | |
adb usb >NUL 2>&1 | |
rem Wait for user to connect their phone | |
echo ^> Waiting for phone... (connect your phone via USB now) | |
:phoneloop | |
rem Weird way of storing output into a variable... Thanks, Windows | |
adb shell echo 'IsConnected' >"%TEMP%/adbout.txt" 2>&1 | |
set /p Out=<"%TEMP%/adbout.txt" | |
rem Check if text matches, which will only happen if the device is connected | |
if "%Out%"=="IsConnected" goto endphoneloop | |
rem Wait a bit | |
PING localhost -n 2 >NUL 2>&1 | |
rem Start loop again | |
goto phoneloop | |
:endphoneloop | |
rem Get device's IP | |
echo ^> Fetching phone's IP address... | |
adb shell "ip -f inet addr show wlan0 | grep -E -o '([0-9]{1,3}[\.]){3}[0-9]{1,3}' | head -1" >"%TEMP%/adbout.txt" 2>&1 | |
set /p IP=<"%TEMP%/adbout.txt" | |
echo Found IP: %IP% | |
rem Set device to TCP mode | |
echo ^> Setting TCP connect mode... | |
adb tcpip 5558 | |
PING localhost -n 2 >NUL 2>&1 | |
adb connect %IP%:5558 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment