Skip to content

Instantly share code, notes, and snippets.

@mirland
Last active May 16, 2018 17:33
Show Gist options
  • Save mirland/68d326903845f933e6e403776c820e51 to your computer and use it in GitHub Desktop.
Save mirland/68d326903845f933e6e403776c820e51 to your computer and use it in GitHub Desktop.
Wifi ADB
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