Skip to content

Instantly share code, notes, and snippets.

@lucianomlima
Created June 5, 2019 17:57
Show Gist options
  • Select an option

  • Save lucianomlima/d2bffb57bf028f9ef5bb7ef109878200 to your computer and use it in GitHub Desktop.

Select an option

Save lucianomlima/d2bffb57bf028f9ef5bb7ef109878200 to your computer and use it in GitHub Desktop.

Revisions

  1. Luciano Lima created this gist Jun 5, 2019.
    17 changes: 17 additions & 0 deletions adb_connect.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    function adb_connect {
    # PORT used to connect. Default: 5555
    PORT=${1:-5555}

    # IP address from current device connected
    IP_ADDRESS=`adb shell ip route | awk '{print $9}'`

    echo "ADB connect to $IP_ADDRESS on port $PORT"

    # Change connection from usb to tcpip using $PORT
    adb tcpip $PORT

    # Connect to device
    adb connect "$IP_ADDRESS:$PORT"

    echo "Done!"
    }