Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --tcpip option to automate TCP/IP (wireless) connections #2827

Merged
merged 13 commits into from
Nov 29, 2021
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[Read in another language](#translations)

This application provides display and control of Android devices connected via
USB (or [over TCP/IP](#wireless)). It does not require any _root_ access.
USB (or [over TCP/IP](#tcpip-wireless)). It does not require any _root_ access.
It works on _GNU/Linux_, _Windows_ and _macOS_.

![screenshot](assets/screenshot-debian-600.jpg)
Expand Down Expand Up @@ -356,10 +356,38 @@ scrcpy --v4l2-buffer=500 # add 500 ms buffering for v4l2 sink

### Connection

#### Wireless
#### TCP/IP (wireless)

_Scrcpy_ uses `adb` to communicate with the device, and `adb` can [connect] to a
device over TCP/IP:
device over TCP/IP.

##### Automatic

An option `--tcpip` allows to configure the connection automatically. There are
two variants.

If the device (accessible at 192.168.1.1 in this example) already listens on a
port (typically 5555) for incoming adb connections, then run:

```bash
scrcpy --tcpip=192.168.1.1 # default port is 5555
scrcpy --tcpip=192.168.1.1:5555
```

If the device TCP/IP mode is disabled (or if you don't know the IP address),
connect the device over USB, then run:

```bash
scrcpy --tcpip # without arguments
```

It will automatically find the device IP address, enable TCP/IP mode, then
connect to the device before starting.

##### Manual

Alternatively, it is possible to enable the TCP/IP connection manually using
`adb`:

1. Connect the device to the same Wi-Fi as your computer.
2. Get your device IP address, in Settings → About phone → Status, or by
Expand Down
9 changes: 8 additions & 1 deletion app/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
src = [
'src/main.c',
'src/adb.c',
'src/adb_parser.c',
'src/adb_tunnel.c',
'src/cli.c',
'src/clock.c',
Expand Down Expand Up @@ -204,8 +205,14 @@ install_data('../data/icon.png',
# do not build tests in release (assertions would not be executed at all)
if get_option('buildtype') == 'debug'
tests = [
['test_adb_parser', [
'tests/test_adb_parser.c',
'src/adb_parser.c',
'src/util/str.c',
'src/util/strbuf.c',
]],
['test_buffer_util', [
'tests/test_buffer_util.c'
'tests/test_buffer_util.c',
]],
['test_cbuf', [
'tests/test_cbuf.c',
Expand Down
8 changes: 8 additions & 0 deletions app/scrcpy.1
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ For example, to use either LCtrl+LAlt or LSuper for scrcpy shortcuts, pass "lctr

Default is "lalt,lsuper" (left-Alt or left-Super).

.TP
.BI "\-\-tcpip[=ip[:port]]
Configure and reconnect the device over TCP/IP.

If a destination address is provided, then scrcpy connects to this address before starting. The device must listen on the given TCP port (default is 5555).

If no destination address is provided, then scrcpy attempts to find the IP address of the current device (typically connected over USB), enables TCP/IP mode, then connects to this address before starting.

.TP
.B \-S, \-\-turn\-screen\-off
Turn the device screen off immediately.
Expand Down
Loading