Last active
May 16, 2018 17:33
-
-
Save mirland/68d326903845f933e6e403776c820e51 to your computer and use it in GitHub Desktop.
Wifi ADB
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
wifi_adb() { | |
PORT="$1" | |
if [ -z "$PORT" ]; then | |
PORT="5" | |
fi | |
re='^[0-9]+$' | |
if ! [[ $PORT =~ $re ]] ; then | |
echo "error: Not a number" >&2; return 1 | |
fi | |
re='^[0-9]$' | |
if ! [[ $PORT =~ $re ]] ; then | |
echo "error: you have to choose a number between 0 and 9" >&2; return 1 | |
fi | |
echo "Used port is 555$PORT" | |
DEVICE_IP_ADDR=`adb -d shell ifconfig wlan0 | awk '/inet addr/ {gsub("addr:", "", $2); print $2}'` | |
adb -d tcpip "555$PORT" | |
echo "Unplug the phone. After that, press enter" | |
read | |
adb connect "$DEVICE_IP_ADDR:555$PORT" | |
echo "If you lost connection you can reconnect the device using" | |
echo "adb connect $DEVICE_IP_ADDR:555$PORT" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment