Metadata-Version: 2.5
Name: symbiolink
Version: 0.4.2
Summary: adb + scrcpy for Symbian S60 3rd Edition phones: symdb CLI and symcast screen mirror over Wi-Fi or USB
Project-URL: Homepage, https://github.com/manojanasuri16/SymbioLink
Project-URL: Repository, https://github.com/manojanasuri16/SymbioLink
Project-URL: Issues, https://github.com/manojanasuri16/SymbioLink/issues
Author-email: Manoj Anasuri <manojanasuri16@gmail.com>
License: MIT
License-File: LICENSE
Keywords: adb,n79,n82,nokia,pys60,retro,s60,scrcpy,screen-mirror,symbian
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Environment :: X11 Applications :: Qt
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Communications
Classifier: Topic :: System :: Hardware
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Requires-Dist: pyqt5>=5.15
Description-Content-Type: text/markdown

# SymbioLink

*Symbian, from "symbiosis": the PC and the phone working together.*

**ADB and scrcpy for Symbian phones.** A Linux-first device bridge for Nokia
S60 / Symbian handsets: a device-side server, an `adb`-style command line tool
(`symdb`) and a screen mirroring and keypad client (`symcast`, PyQt5).

> **Needs a hacked phone for full functionality.** SymbioLink is built for
> phones with platform security relaxed (**Open4All** via RomPatcher+, or a
> developer certificate). The package asks for `SwEvent` (key control) and
> `CommDD` (USB cable), which a stock phone will not grant: an unhacked phone
> refuses to install it ("Access not granted" / "Certificate error").
> How to hack an S60v3 phone:
> [Unlock guide on RetroArchive](https://manojanasuri16.github.io/RetroArchive/guides/unlock-n79/)
> and [symbian-unlock-guide](https://github.com/manojanasuri16/symbian-unlock-guide).
> If the phone is hacked but Open4All is off when you install, you get the
> same refusal: switch it on in RomPatcher+ and install again.

Built for S60 3rd Edition phones (Symbian OS 9.1-9.3). Capabilities are
reported by the device, hardware details live in device profiles, and API
differences live in platform adapters, so nothing is tied to one model.

*Tested on: Nokia N79 (FP2) and Nokia N82 (FP1).*

> **Status: 0.4.2 (Wi-Fi and USB cable verified on real phones).** On
> firmware 10.045 (RM-348), 2026-11-29, the server, the PC client and the
> `symcast` viewer were run against the phone over both transports: connect,
> device info, file transfer, live mirror and keypad input. The limits that
> remain (about 10 fps, no process or app list, no silent install, one client at
> a time, no authentication) are listed below and in
> [docs/CHECKLIST.md](docs/CHECKLIST.md). Nothing in this repository claims a
> phone result that was not observed.

---

## Why

Android has `adb` and `scrcpy`. Symbian has nothing equivalent: file transfer
tools, remote-control tools and screenshot utilities existed, but they are
closed, dead or tied to one model. SymbioLink aims at the same workflow:

```sh
symdb devices
symdb connect 192.168.1.20
symdb shell info
symdb push photo.jpg C:\Data\
symdb pull C:\Data\notes.txt .
symdb screencap screen.jpg
```

and `symcast` for live mirroring and keypad control.

## What works today

| Area | State | Notes |
|---|---|---|
| SL/1 protocol (PC + phone + tests) | **working** | 37 offline tests pass (14 PC-side, 23 phone-side) |
| Device server (PyS60 1.4.5), 0.4.2 | **working** | Wi-Fi and USB; one client at a time |
| `_symbiolink.pyd` (native screen capture, HAL facts, capability list, key injection), UID `0xE7A3D5F7` | **working** | keys and stream verified on the phone |
| `symbiolink_usb.exe` USB relay (phone side), UID `0xE7A3D5F8` | **working** | CDC-ACM port to the server, PC Suite mode |
| USB transport (PC side, `--usb`) | **working** | needs the udev rule; ~0.65 s to auto-detect |
| Wi-Fi TCP transport | **working** | 47020/TCP; the pattern RetroSend uses on this phone |
| Connect, hello, caps, info, battery | **working** | over Wi-Fi and USB |
| File push, pull, ls, mkdir, rm | **working** | 100 KB round trip byte-identical; a SIS pushed over the bridge installed |
| Live screen stream (`screen.stream`) and `symcast` mirror | **working** | ~8.8 fps over USB, ~7.4 fps over Wi-Fi at quality 50 (cap about 10 fps) |
| Key and text input (`input.key`, `input.text`) | **working** | keyboard and clickable keypad in `symcast`; needs Open4All (see Requirements) |
| `symcast` screenshot (Ctrl+S), help overlay, reconnect (Ctrl+R) | **working** | |
| UDP discovery | **implemented** | phone broadcasts, PC reads the source address |
| `symcast --record` (MJPEG AVI via ffmpeg) | **implemented, not yet run on a phone** | |
| Touch injection | **blocked** | needs a touchscreen device (S60 5th Edition / Symbian^3) |
| App list, process list, SIS install from the bridge | **blocked** | needs native helpers (`RApaLsSession`, `TFindProcess`); the install UI is the only route |

## Requirements

**Phone**

- An S60 3rd Edition phone (FP1 or FP2; see *Tested on* above) for the reference path
  (FP1 and 5th Edition need their own platform adapter - see
  [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md#platforms)). Verified on firmware
  10.045 (RM-348).
- **Python for S60 1.4.5** installed (`PythonForS60_1_4_5_3rdEd.sis` plus
  `PythonScriptShell_1_4_5_3rdEd.SIS`).
- Wi-Fi, for the Wi-Fi transport. The phone picks the access point when the
  server binds its socket. The USB transport does not need Wi-Fi.
- For USB: the phone's connection mode set to **PC Suite**.
- The SymbioLink `.sis` installed **on the same drive as Python for S60**
  (usually the memory card). A cross-drive install needs the `rscfix` helper,
  which is not built yet.
- **A hacked phone: Open4All (or a developer certificate) active when you
  install.** The package asks for `SwEvent` (key input) and `CommDD` (USB
  relay), system capabilities a stock phone refuses, so on an unhacked phone
  the whole install is refused. See the box at the top for the unlock guide.

| Works on | Hacked S60v3 phone (Open4All) | Stock phone |
|---|---|---|
| Install SymbioLink | yes | no (installer refuses) |
| Wi-Fi: mirror, screenshots, files, info | yes | - |
| Key and text input | yes | - |
| USB cable | yes | - |

**PC**

- Linux with Python 3.9+. `pipx install symbiolink` brings PyQt5 (for
  `symcast`) along; `symdb` itself uses only the standard library.
- For USB: the udev rule installed (`symdb setup-udev --install`, see First run).
  Without it the phone's second serial port does not appear and `--usb` finds
  nothing.
- Only to rebuild the phone package yourself: the Symbian toolchain
  [symbian-s60v3-toolchain](https://github.com/manojanasuri16/symbian-s60v3-toolchain)
  (GnuPoc + CodeSourcery GCCE 3.4.3 + S60 3.2 SDK) and Python 2.7 for ensymble.
  The PC package already ships a built `SymbioLink.sis`.

## Installation

### As a global CLI (recommended)

```sh
pipx install symbiolink
```

This puts `symdb` and `symcast` on your PATH, in their own environment. With uv
instead:

```sh
uv tool install symbiolink
```

The package also carries the phone installer (`SymbioLink.sis`) and the Linux
udev rule, so nothing else has to be downloaded.

<details>
<summary>Install straight from GitHub with pipx</summary>

```sh
pipx install git+https://github.com/manojanasuri16/SymbioLink.git
```

Useful for the latest `master` without waiting for a PyPI release.
</details>

<details>
<summary>Run from a clone (for development)</summary>

```sh
git clone https://github.com/manojanasuri16/SymbioLink.git
cd SymbioLink
uv sync
uv run symdb --version
uv run symcast --fake
```

Pip alternative: `pip install -e .` inside a virtual environment.
</details>

## First run

1. **Hack the phone** (Open4All on), see the box at the top. Without it the
   installer refuses SymbioLink.
2. **Install Python for S60 1.4.5** on the phone (the interpreter and the
   script shell SIS for S60 3rd Edition), as every PyS60 app needs.
3. **Get SymbioLink onto the phone.** The first install has to go by memory
   card or Bluetooth, because `symdb` can only talk to the phone once the app
   runs:
   ```sh
   symdb sis-path        # prints where the bundled SymbioLink.sis is
   ```
   Copy that file to the memory card (USB mass storage mode or a card reader)
   or send it over Bluetooth, then open it in **Files** on the phone. Later
   updates can go over the bridge itself:
   ```sh
   symdb install-app     # pushes it to C:\Data\SymbioLink.sis
   ```
   then open **Files > Phone memory > SymbioLink.sis** on the phone. If an
   older SymbioLink is refused or does not start cleanly, uninstall it first
   (0.2.0 moved the `_symbiolink.pyd` UID to `0xE7A3D5F7`; the app UID is still
   `0xE7A3D601`, `symbiolink_usb.exe` is `0xE7A3D5F8`). The package is self-signed,
   valid 2008-2037, so it also installs when the phone clock is wrong.
4. **For the USB cable (Linux, once):**
   ```sh
   symdb setup-udev            # shows the rule and the sudo commands
   symdb setup-udev --install  # runs them (asks first; -y to skip)
   ```
5. **Open SymbioLink on the phone** and leave it running (it shows the port,
   the client state and the last command; `Select` toggles the UDP
   announcement, `Back` exits; the USB relay `symbiolink_usb.exe` starts with the app,
   **Start USB relay** in the menu restarts it). Then mirror it:
   ```sh
   symcast --usb              # phone in PC Suite mode, over the cable
   symcast 192.168.1.20       # or over Wi-Fi
   ```

## Usage

Over Wi-Fi:

```sh
symdb devices --discover          # phones broadcasting on the LAN
symdb connect 192.168.1.20        # remembered in ~/.config/symbiolink
symdb caps                        # what this phone can and cannot do
symdb shell info
symdb shell battery
symdb shell ls 'C:\Data'
symdb push photo.jpg 'C:\Data\'
symdb pull 'C:\Data\file.txt' .
symdb screencap screen.jpg
```

Over the USB cable (phone in PC Suite mode, relay started):

```sh
symdb connect --usb               # auto-detects /dev/ttyACM1 (remembered)
symdb shell info                  # same commands once connected
symdb -s usb:/dev/ttyACM1 caps    # or name the port explicitly
```

Setup helpers: `symdb sis-path`, `symdb install-app [--to PATH]`,
`symdb setup-udev [--install] [-y]`, `symdb --version`.

Live mirror and keypad (PyQt5):

```sh
symcast 192.168.1.20             # or --discover; --scale 2 --quality 50
symcast --usb                    # the cable instead of Wi-Fi
symcast 192.168.1.20 --record session.avi   # MJPEG AVI via ffmpeg
```

Keys: arrows = d-pad (held), Enter/Space = select, F1 = left softkey, F2 or Esc =
right softkey, F3 = call (opens dialled numbers), F4 = end (clears the dialer,
closes apps; if the bridge itself is in front it opens Menu first, so the bridge
is not closed), F5 = menu, Backspace/Delete/C = clear, 0-9 * # direct,
Ctrl+T = send text, Ctrl+S = screenshot to ~/Pictures, Ctrl+R = reconnect,
H or ? = help overlay. The keypad on screen is clickable.

`-s host[:port]` selects a device explicitly, `-s usb` or `--usb` the cable;
`SYMDB_DEVICE` does the same from the environment. Ports: **47020/TCP** (server,
also the local end of the USB relay), **47021/UDP** (announcements).

### The USB rule

`symdb setup-udev --install` copies the bundled `70-symbiolink.rules` to
`/etc/udev/rules.d/` and reloads udev. The rule does two things. The phone's
second CDC-ACM port (the one `symbiolink_usb.exe` uses) declares a vendor protocol, so
Linux `cdc_acm` skips it; the rule adds the Nokia id so it appears as an extra
`/dev/ttyACMn`, normally `ttyACM1`. The logged-in user also gets access
(`uaccess`), so no `sudo` or `uucp` group is needed. The phone's own modem port
(`ttyACM0`) is held by the phone and reports `KErrAccessDenied`; it is not used.

### Try it without a phone (from a clone)

The fake phone implements the server side over a local directory, so the CLI and
the protocol can be exercised anywhere:

```sh
uv run python tests/fake_phone.py --root /tmp/phone --announce &
uv run symdb -s 127.0.0.1:47020 shell info
uv run symdb -s 127.0.0.1:47020 screencap /tmp/fake.jpg
uv run symcast --fake
```

## Building the phone package

The `SymbioLink.sis` bundled in the Python package is a build artifact of the
phone side. Rebuild it from a clone with:

```sh
sh scripts/build_native.sh    # -> phone/native/out/_symbiolink.pyd, symbiolink_usb.exe
sh scripts/build_sis.sh       # -> src/symbiolink/data/SymbioLink.sis
```

`build_native.sh` expects the toolchain next to this repository; point it
elsewhere with `SYMBIAN_SDK=/path/to/symbian-s60v3-toolchain`.
`build_sis.sh` looks for Python 2 and ensymble in the neighbouring RetroSend
checkout; override with `PY2=... ENSYMBLE=...`. The package carries
`_symbiolink.pyd` and `symbiolink_usb.exe`. Commit the rebuilt
`src/symbiolink/data/SymbioLink.sis` (it is excepted from the `*.sis` ignore
rule); `dist/` is only for `uv build` output.

## Tests

```sh
uv run pytest                        # framing, client, CLI, viewer (PC side)
python2 tests/test_phone_server.py   # device modules on Python 2.7
sh scripts/check_py22.sh             # rejects syntax newer than Python 2.2
sh scripts/build_native.sh           # native module compiles (arm-none-symbianelf-gcc)
sh scripts/build_sis.sh              # package builds
```

`tests/test_proto.py` and `tests/test_symcast.py` also run on their own with
`python3` (the viewer test needs PyQt5 and uses `QT_QPA_PLATFORM=offscreen`).
CI runs the pytest suite; the Python 2.7 phone test runs locally only, as
GitHub's setup-python no longer provides 2.7.

The phone-side checks above run offline. The hardware results in this README were
observed by hand on the phone, not by these tests.

## How it fits together

```
 PC (Python 3)                          Phone (PyS60 1.4.5 + native helpers)
 ┌──────────────┐   TCP 47020 / SL/1   ┌────────────────────────────────┐
 │ symdb       │ ───────────────────► │ linkserver.py  (app + sockets)   │
 │ symcast    │ ◄─────────────────── │ handlers.py  (commands)        │
 │ (PyQt5)      │   UDP 47021 announce │ s60v3.py     (platform)        │
 └──────────────┘                      │ n79.py       (hardware profile)│
        ▲                              │ _symbiolink.pyd (WS/HAL, native) │
        │ USB CDC-ACM (SL/1 bytes)     └──────────────▲─────────────────┘
        └────────────── cable ─────────── symbiolink_usb.exe ───┘ relays ACM::1 <-> 127.0.0.1:47020
```

- **Capability-driven.** Every command the phone cannot do comes back as a
  refusal with a reason, never as a silent failure. `symdb caps` prints the
  whole table.
- **Transport-independent protocol.** The same SL/1 byte stream runs over Wi-Fi
  TCP and over the USB cable (through the phone-side `symbiolink_usb.exe` relay). Nothing
  above the transport layer knows which one is in use.
- **Native where Python cannot reach.** PyS60 can screenshot and move files but
  cannot inject keys, list apps or report capabilities. Those go into native
  modules, behind the same protocol.

Detail: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md),
[docs/FEASIBILITY.md](docs/FEASIBILITY.md),
[protocol/slproto.md](protocol/slproto.md),
[docs/PROTOCOL.md](docs/PROTOCOL.md) (command meanings).

## Verified on hardware (0.3.5)

Nokia N79, firmware 10.045 (RM-348), 2026-11-29, server 0.3.5. Full evidence per
item is in [docs/CHECKLIST.md](docs/CHECKLIST.md).

- Connect, hello, caps, info and battery over Wi-Fi (TCP 47020) and over USB.
- Stream: q50 at 8.8 fps over USB and 7.4 fps over Wi-Fi (q30: 9.0 and 8.9),
  frames of about 14-18 KB. The limit is the phone's JPEG encode, about 80 ms per
  frame.
- Transfer: push about 132 KB/s over USB and 124 KB/s over Wi-Fi; pull about
  257 KB/s and 222 KB/s. Request round trip median 54 ms over USB, 56 ms over
  Wi-Fi.
- Keys seen on the screen: d-pad, select, both softkeys, call, end, menu, 0-9,
  star, hash, clear, `input.text`. The keypad autolock blocks injected keys until
  the phone is unlocked (LSK then `*`).
- Switching between USB and Wi-Fi works: a new client replaces a stale one.

## Roadmap

| Phase | Content | State |
|---|---|---|
| 1 | Protocol, `symdb`, device server, native helper, packaging | done; verified on hardware (Wi-Fi and USB) |
| 2 | Live screen mirroring, `symcast` viewer, frame rate/latency measurement | done; measured on hardware (about 8-9 fps) |
| 3 | Remote control: key injection (`SwEvent`), key maps, touch profiles | keys done; touch blocked |
| 4 | App list/launch/stop, processes, logs, SIS install | blocked on native helpers |
| 5 | Polished `symdb` + `symcast`, reconnection | partly: Ctrl+R reconnect; the rest planned |
| 6 | Other Symbian devices and OS generations | planned |

## Limitations (read before filing a bug)

- **PyS60 1.4.5 only.** One Python runtime per S60 3rd Edition generation; S60
  5th Edition and Symbian^3 ship PyS60 2.x with a different socket API.
- **Frame rate is capped at about 10 fps** by the phone's JPEG encode.
- **One client at a time**, and the phone cannot tell who connected (PyS60 has
  no `getpeername`), hence the UDP announcement direction.
- **Keypad autolock** blocks injected keys until the phone is unlocked.
- **No process or app list** yet; silent `symdb install` does not exist (`symdb install-app` only pushes the SIS). A SIS pushed
  over the bridge still has to be installed from the phone's own UI, which is
  not silent.
- **Key injection needs `SwEvent`**, a system capability: a stock phone refuses
  a self-signed package that declares it. Use an Open4All phone or a developer
  certificate.
- **No TLS, no authentication.** The server accepts any connection on the local
  network or the cable. Use it on networks you trust, or keep Wi-Fi off when not
  needed.

## Related projects

- [symbian-s60v3-toolchain](https://github.com/manojanasuri16/symbian-s60v3-toolchain) - the toolchain used to build this.
- [RetroSend](https://github.com/manojanasuri16/RetroSend),
  [RetroTele](https://github.com/manojanasuri16/RetroTele) - sibling S60 apps whose
  socket, packaging and native-helper patterns this project reuses.
- RetroCamKey - the key-injection pattern (`SimulateRawEvent`) this project follows.
- [localsend-py22](https://github.com/manojanasuri16/localsend-py22) - the
  PyS60 network notes that shaped the server.

## Publishing

Releases go to PyPI and GitHub Releases from `.github/workflows/release.yml`
when a `v*` tag is pushed.

One-time setup on PyPI (trusted publisher, no API token): at
<https://pypi.org/manage/account/publishing/> add a pending publisher with
PyPI project `symbiolink`, owner `manojanasuri16`, repository `SymbioLink`,
workflow `release.yml`, environment `pypi`. Create the `pypi` environment in the
GitHub repository settings (Environments) as well.

Then, for each release:

1. Bump `__version__` in `src/symbiolink/__init__.py` (the package version is
   read from it).
2. Rebuild the phone package if the phone side changed
   (`sh scripts/build_sis.sh`) and commit it.
3. `git tag vX.Y.Z && git push origin vX.Y.Z`.

The workflow builds the sdist and wheel with `uv build`, creates the GitHub
Release with them plus `SymbioLink.sis`, and publishes to PyPI.

## Licence

MIT, see [LICENSE](LICENSE). Python for S60, the S60 SDK and the Symbian
toolchain keep their own licences; none of them are redistributed here.
