Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Frequenzwahl, Bandplan und Sendeleistung liegt beim Betreiber.
| **TX-Modi** (`pluto-tx`) | FM (optional mit CTCSS/DCS), SSB (USB/LSB), M17, FreeDV 2020/2020B, RADE V1, File Broadcast, Baseband |
| **RX-Modi** (`pluto-advanced-rx`) | FM, SSB (USB/LSB), RADE V1, M17, Baseband |
| **Digimodes** (beide Apps, eigener Reiter) | Waterfall Writer (Text im Wasserfall), PSK31-Chat, RTTY, POCSAG (Funkruf), FT8, JS8 (JS8Call-kompatibel, Normal/Fast/Turbo/Slow), Meshtastic (LoRa; nur Pluto/HackRF/RTL-SDR), MeshCore (LoRa, nur RF-Geräte) |
| **Hardware** | PlutoSDR/Pluto+ (TX+RX), HackRF One (TX+RX), RTL-SDR (RX), Soundkarte/externes Funkgerät (TX+RX), AIOC-Adapter/analoges Funkgerät (TX) |
| **Hardware** | PlutoSDR/Pluto+ (TX+RX), HackRF One (TX+RX), RTL-SDR (RX), Soundkarte/externes Funkgerät (TX+RX), AIOC-Adapter/analoges Funkgerät (TX), ESP32-S3-Board (TX, nur 13 cm, nur FM und M17, experimentell) |
| **Automatisierung** | `pluto-cli` — dieselbe Codebasis headless, `--json`-Ausgabe |
| **Fernbetrieb** | `web-trx` — Browser-Oberfläche (FastAPI + Svelte) auf derselben Codebasis, ein Betreiber, Login, HTTPS |
| **Sicherheit** | NOTAUS, von GNU Radio unabhängige Abschalt-Logik, Live-Hardware-Readout |
Expand Down Expand Up @@ -118,6 +118,40 @@ eigenständige Skript `pluto_tx/tx-stdin.py` (Audio von stdin senden,
z. B. für eine TTS-Pipe ohne die GUI) nutzt dieselbe PTT-Logik
(`pluto_tx/aioc_ptt.py`) und funktioniert unabhängig von der App weiter.

### Optional: ESP32-S3 als 13-cm-Sender (FM und M17, experimentell)

Der Gerätetyp "ESP32-S3 (13 cm)" sendet mit einem ESP32-S3-Entwicklungsboard (mit **zwei** USB-Ports) im 13-cm-Band (2320–2450 MHz). Das Board hat
keinen I/Q-Ausgang: Es steuert den Testton seines WLAN-Funkteils in Frequenz (und ein wenig in der Amplitude), 40 000-mal pro Sekunde. Das genügt
für Signale mit **konstanter Hüllkurve**: `pluto-tx` rechnet das Basisband des Flowgraphs in die Momentanfrequenz um, und nur diese geht zum Chip. Deshalb
sind **nur FM und M17** wählbar; alles mit Amplitudenmodulation (SSB, PSK31, FT8, FreeDV, RADE, ...) und LoRa ist bei diesem Gerät gesperrt
(GUI: ausgegraut mit Hinweis, `pluto-cli`: Fehlermeldung, Flowgraph: Rückfall auf FM).

```
./install.sh # zuerst
./install-espdr.sh # esptool 5 (pipx), udev-Regel für das Board; --dry-run zeigt nur, was passieren würde
```

Der Code für das Board (`espdr/`, einschließlich der Firmware-Images) gehört zu diesem Repository: Er ist eine Kopie aus
[esp32-sdr-trx](https://github.com/jochenhammes/esp32-sdr-trx) (Zero-Clause-BSD-Lizenz, Stand in `espdr/UPSTREAM`), die `tools/sync-espdr.sh`
aktualisiert. **`espdr/` hier nicht ändern**, sondern in esp32-sdr-trx. Es wird nichts nachgeladen; die Firmware kommt bei Bedarf ins **RAM**
des Boards (der Flash bleibt unberührt). Verbindungsfeld: leer (Board an den USB-Ports finden) oder `NATIVER_PORT[,UART_PORT]`, z. B. `/dev/ttyACM1,/dev/ttyACM0`.

Vor der ersten Sendung einmal den Lizenzhinweis bestätigen (das sendet nichts):
`python3 -m espdr.cli_tx -f 2345 --test-tone 1000 --dry-run --accept-licence`. Dann z. B. `pluto-cli tx m17 --device espdr --freq 2345000000 --src-callsign <Rufzeichen>`.

**Was du wissen musst** (gemessen mit einem Board und einem PlutoSDR als Empfänger, Einzelheiten in
[`espdr/` → docs/research/PLAN-M17.md in esp32-sdr-trx](https://github.com/jochenhammes/esp32-sdr-trx/blob/feature/m17/docs/research/PLAN-M17.md), Abschnitt 10):
- Die M17-Kette von `pluto-tx` dekodiert das Signal (Rufzeichen und Sprache), auch noch am Ende einer 120-s-Sendung.
- Mit dem Gerät selbst (`pluto-cli`, ein Board, ein PlutoSDR als Empfänger, 2345 MHz, −6 dB) getestet: M17 von einer WAV-Datei wird dekodiert (Rufzeichen, 4,5 s Sprache);
FM sendet und endet sauber; fünf Sendungen hintereinander ohne hängenden Träger (Träger innerhalb der Messauflösung von 0,22 s beim Tasten und beim Loslassen).
**Nicht getestet:** die GUI im echten Betrieb, Mikrofonbetrieb über längere Zeit (Taktdrift Soundkarte gegen Chip), mehr als ein Board, 600-s-Sendungen.
- **Außerhalb des Kanals ist der Sender nicht sauber**: die Nachbarfenster (9 kHz) liegen 37 dB (±12,5 kHz) und 46 dB (±25 kHz) unter der Kanalleistung,
weiter draußen etwa −55 dBc bis ±200 kHz. Oberwellen sind **nicht gemessen**, die Leistung ist **nicht kalibriert** (Standardobergrenze −12 dB gegen den stärksten Wert).
- Die Trägerfrequenz **weicht ab** (der Quarz des Boards, einige kHz, je nach Temperatur) und **driftet** (1,5 kHz in 106 s, gemessen mit aktivem Thermalmodell des Boards und ohne ppm-Korrektur);
M17-Empfänger folgen dem. Bei etwa 10 % der Frequenzen liegt das Signal wegen der Einstellmöglichkeiten des Chips ein paar kHz neben dem Wunsch (die Warnung nennt die tatsächliche Frequenz).
- Die Latenz von PTT bis Träger beträgt mindestens 100 ms, das Ende des Trägers kommt etwa 125 ms nach dem Loslassen; die Frequenz lässt sich während der Sendung nicht ändern.
- Eine Sendung braucht eine **Amateurfunklizenz**, und du bist für das verantwortlich, was du sendest. Nur 2320–2450 MHz.

### Optional: FT8

```
Expand Down Expand Up @@ -486,10 +520,11 @@ weitere Rezepte) in [`pluto_cli/README.md`](pluto_cli/README.md).
| **RTL-SDR** (USB oder per `rtl_tcp` im Netzwerk) | — (kein TX-fähiges Gerät) | alle Modi |
| **Soundkarte / externes Funkgerät** | FM, RADE, Waterfall Writer, PSK31, RTTY, POCSAG, FT8, JS8 | alle Modi (Audio Input, z.B. für RADE über ein SSB-Funkgerät) |
| **AIOC-Adapter / analoges Funkgerät** (z. B. Quansheng UV-K5) | FM, RADE, Waterfall Writer, PSK31, RTTY, POCSAG, FT8, JS8 (Audio + echtes serielles PTT) | — (kein RX-Backend) |
| **ESP32-S3-Board** (nur 13 cm, experimentell) | nur FM und M17 (konstante Hüllkurve; Frequenz 2320–2450 MHz) | — (kein RX-Backend) |

Geräteauswahl per editierbarem Dropdown ("Device") plus Scan- und
Connect/Disconnect-Buttons. **Nur `pluto-tx`** hat zusätzlich ein
"Device Type"-Dropdown (PlutoSDR/HackRF/Soundcard/AIOC), das Verbindungsfeld,
"Device Type"-Dropdown (PlutoSDR/HackRF/Soundcard/AIOC/ESP32-S3), das Verbindungsfeld,
Frequenzbereich und Pegel-Regler passend umschaltet.

## Sicherheit
Expand All @@ -516,10 +551,11 @@ Gain-Register allein stoppt die Sendung nachweislich nicht).
## Struktur

```
install.sh / install-m17.sh / install-rade.sh / install-lora.sh / install-ft8.sh / install-js8.sh / install-web-trx.sh
install.sh / install-m17.sh / install-rade.sh / install-lora.sh / install-ft8.sh / install-js8.sh / install-web-trx.sh / install-espdr.sh
espdr/ # Kopie aus esp32-sdr-trx (0BSD): Host-Teil des ESP32-S3-Senders + Firmware-Images; `tools/sync-espdr.sh`, nicht hier ändern
pluto_tx/ # Sende-App
├── config.py # geräteunabhängige Konstanten
├── devices/ # TX-Geräte-Abstraktionsschicht (Pluto/HackRF/Soundcard)
├── devices/ # TX-Geräte-Abstraktionsschicht (Pluto/HackRF/Soundcard/AIOC/ESP32-S3)
├── safety.py # PlutoSafety: rohes python3-libiio, unabhängig von GNU Radio
├── flowgraph.py # PlutoTxFlowgraph: die gesamte Signalkette
├── dynamics.py # Kompressor/Limiter
Expand Down Expand Up @@ -617,6 +653,10 @@ offene Punkte stehen am Ende dieser Datei.

[GPLv3](LICENSE) — Copyright (C) 2026 Jochen Hammes (DA2JH).

Das Verzeichnis `espdr/` (Host-Teil des ESP32-S3-Senders und seine Firmware-Images) ist eine Kopie aus
[esp32-sdr-trx](https://github.com/jochenhammes/esp32-sdr-trx) unter der Zero-Clause-BSD-Lizenz (`espdr/LICENSE`, `espdr/NOTICE`); der Rest dieses
Repositories steht unter GPLv3. Die Kopie erzeugt `tools/sync-espdr.sh`, der Stand steht in `espdr/UPSTREAM`.

Die optionalen Abhängigkeiten `gr-m17` (GPLv2), `rade_c`/RADE
(BSD-2-Clause) und `ft8_lib` (MIT) werden von `install-m17.sh`/`install-rade.sh`/
`install-ft8.sh` separat aus ihren jeweiligen Quellen gebaut, nicht in diesem Repo
Expand Down
13 changes: 13 additions & 0 deletions espdr/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Zero-Clause BSD
==============

Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 changes: 15 additions & 0 deletions espdr/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
esp32-sdr-trx
=============

This project is built on eSpDR by h0m3us3r (https://github.com/h0m3us3r/eSpDR), published under the Zero-Clause BSD licence (0BSD).
eSpDR found how to read the ESP32-S3's undocumented Wi-Fi I/Q dump path and wrote the firmware around it: the radio bring-up, the
LO tuning (including the 5/6 conversion mode), the capture engine and the control protocol. The firmware in `firmware/` is that code with
changes; it started from upstream commit f279bf8 and went through the fork https://github.com/jochenhammes/eSpDR (branches
`narrowband`, `tx-research`; the research is kept there and in the tag `tx-research-final`).

What this project adds: the on-chip decimator that makes a 250 or 333 ksps stream out of the 16 Msps dump (no FPGA), the USB stream, the
flash boot, the rtl_tcp bridge, the experimental transmitter (frequency and amplitude steering of the PHY's test tone, FM and SSB voice),
the host tools `espdr-rx` and `espdr-tx`, and their documentation. Most of the code and the documentation was written with Claude
(Anthropic) as the coding assistant; every number in the documentation was measured.

The vendor PHY library (libphy.a) of ESP-IDF is linked at build time from an ESP-IDF v5.5 installation and is not part of this repository.
10 changes: 10 additions & 0 deletions espdr/UPSTREAM
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repository: https://github.com/jochenhammes/esp32-sdr-trx
commit: 580a0f7a4052410843b89c4f5c2f5973db68ef84
subject: board: find esptool as a program on the PATH when this Python has no esptool module
date: 2026-10-11T18:55:39+02:00
licence: 0BSD (espdr/LICENSE); the rest of pluto-tx is GPL-3.0
images (build products of the firmware of that repository, copied as they were; sha256 in espdr/images/SHA256SUMS.txt):
c5131425d56fb05c44874988ca77652a5c4482296bf206d944683ee131d73678 rx.bin
b017125ac6c1bcbb70c84e3675a0ecee485b3249f84803cae382b6b83c6f7fd6 tx.bin
09b2386299522e08fad02bfed8bab76bc5e37076b8d529c31811e967780b686b bootloader.bin
7f00b6c042a89b15b0cac534f82ed988caf29278ff5700b0c511eb1b5bb7c820 partition-table.bin
2 changes: 2 additions & 0 deletions espdr/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"""esp32-sdr-trx: an rtl_tcp receiver and an FM/SSB voice transmitter for one ESP32-S3 board."""
__version__ = "0.0.0.dev0"
210 changes: 210 additions & 0 deletions espdr/audio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
"""Audio sources for the transmitter: a WAV file, a pipe on stdin (WAV or raw samples), or a sound card.

Every source delivers mono float blocks at its own sample rate; `Mono8k` turns that into the 8 kHz stream the modulators take.
"""
import queue
import struct
import sys
import time

import numpy as np

from . import dsp

RAW_FORMATS = {"s16le": (np.dtype("<i2"), 32768.0), "f32le": (np.dtype("<f4"), 1.0), "u8": (np.dtype("u1"), None)}


class AudioError(Exception):
pass


def _to_float(raw, dtype, scale, channels):
a = np.frombuffer(raw, dtype=dtype)
if scale is None: # unsigned 8 bit
a = (a.astype(np.float32) - 128.0) / 128.0
else:
a = a.astype(np.float32) / scale
if channels > 1:
a = a[: len(a) // channels * channels].reshape(-1, channels).mean(axis=1)
return a


class StreamSource:
"""Raw or WAV audio read from a binary file object (a file, or stdin as a pipe)."""

def __init__(self, fh, rate=None, channels=1, fmt="s16le", block_s=0.02, name="stdin"):
self.fh, self.name, self.block_s = fh, name, block_s
head = fh.read(4)
if head == b"RIFF":
self._read_wav_header()
else:
if rate is None:
raise AudioError(f"{name}: raw audio needs --rate (and --channels, --format if they are not mono s16le)")
if fmt not in RAW_FORMATS:
raise AudioError(f"unknown format {fmt!r}; use one of {', '.join(RAW_FORMATS)}")
self.rate, self.channels = int(rate), int(channels)
self.dtype, self.scale = RAW_FORMATS[fmt]
self.pending = head
self.remaining = None

def _read_wav_header(self):
fh = self.fh
fh.read(4) # RIFF size
if fh.read(4) != b"WAVE":
raise AudioError(f"{self.name}: not a WAV file")
fmt = None
while True:
hdr = fh.read(8)
if len(hdr) < 8:
raise AudioError(f"{self.name}: no audio data in the WAV file")
cid, size = hdr[:4], struct.unpack("<I", hdr[4:])[0]
if cid == b"fmt ":
body = fh.read(size + (size & 1))
tag, ch, rate, _, _, bits = struct.unpack("<HHIIHH", body[:16])
if tag == 0xFFFE and len(body) >= 26: # WAVE_FORMAT_EXTENSIBLE: the real tag is in the sub format
tag = struct.unpack("<H", body[24:26])[0]
fmt = (tag, ch, rate, bits)
elif cid == b"data":
if fmt is None:
raise AudioError(f"{self.name}: the WAV data came before its format")
tag, ch, rate, bits = fmt
self.channels, self.rate = ch, rate
if tag == 1 and bits == 16:
self.dtype, self.scale = np.dtype("<i2"), 32768.0
elif tag == 1 and bits == 8:
self.dtype, self.scale = np.dtype("u1"), None
elif tag == 3 and bits == 32:
self.dtype, self.scale = np.dtype("<f4"), 1.0
else:
raise AudioError(f"{self.name}: WAV format tag {tag} with {bits} bits is not supported (use 16-bit PCM)")
self.pending = b""
self.remaining = None if size in (0, 0xFFFFFFFF) else size # streaming writers leave the size open
return
else:
fh.read(size + (size & 1))

def blocks(self):
width = self.dtype.itemsize * self.channels
n = max(1, int(self.rate * self.block_s)) * width
pending = self.pending
while True:
want = n - len(pending)
if self.remaining is not None:
want = min(want, self.remaining)
chunk = self.fh.read(want) if want > 0 else b""
if self.remaining is not None:
self.remaining -= len(chunk)
pending += chunk
whole = len(pending) // width * width
if whole >= n or (not chunk and whole):
yield _to_float(pending[:whole], self.dtype, self.scale, self.channels)
pending = pending[whole:]
if not chunk:
return

def close(self):
if self.fh not in (sys.stdin.buffer,):
self.fh.close()


class SoundCardSource:
"""A sound card input through PortAudio (the optional `sounddevice` package)."""

def __init__(self, device=None, rate=None, block_s=0.02):
try:
import sounddevice as sd
except ImportError:
raise AudioError("the sound card needs the sounddevice package: pip install 'esp32-sdr-trx[audio]' "
"(or: pipx inject esp32-sdr-trx sounddevice); on Linux also PortAudio: sudo apt install libportaudio2")
self.sd = sd
if device is not None and str(device).lstrip("-").isdigit():
device = int(device)
try:
info = sd.query_devices(device, "input")
except Exception as e:
raise AudioError(f"no such sound card input {device!r} ({e}); `espdr-tx --list-devices` shows what there is")
self.name = info["name"]
self.rate = int(rate or info["default_samplerate"])
self.q = queue.Queue(maxsize=200)
self.overflows = 0
self.stream = sd.InputStream(device=device, channels=1, samplerate=self.rate, dtype="float32",
blocksize=max(1, int(self.rate * block_s)), callback=self._cb)

def _cb(self, indata, frames, time_info, status):
if status:
self.overflows += 1
try:
self.q.put_nowait(indata[:, 0].copy())
except queue.Full:
self.overflows += 1

def blocks(self):
self.stream.start()
while True:
try:
yield self.q.get(timeout=1.0)
except queue.Empty:
raise AudioError(f"the sound card {self.name!r} delivers no audio")

def close(self):
try:
self.stream.stop()
self.stream.close()
except Exception:
pass


def list_devices():
try:
import sounddevice as sd
except ImportError:
raise AudioError("the sound card needs the sounddevice package: pip install 'esp32-sdr-trx[audio]'")
lines = []
for i, d in enumerate(sd.query_devices()):
if d["max_input_channels"] > 0:
lines.append(f" {i:3d} {d['name']} ({d['max_input_channels']} in, {int(d['default_samplerate'])} Hz)")
return lines


def open_source(spec, rate=None, channels=1, fmt="s16le", device=None):
"""spec: a file name, '-' for stdin, or 'soundcard' / 'soundcard:DEVICE' (number or name)."""
if spec == "-":
return StreamSource(sys.stdin.buffer, rate, channels, fmt, name="stdin")
if spec == "soundcard" or spec.startswith("soundcard:"):
dev = device if device is not None else (spec.split(":", 1)[1] if ":" in spec else None)
return SoundCardSource(dev, rate)
try:
fh = open(spec, "rb")
except OSError as e:
raise AudioError(f"{spec}: {e.strerror or e}")
return StreamSource(fh, rate, channels, fmt, name=spec)


class Mono8k:
"""Blocks of mono audio at the source's rate -> blocks of 8 kHz audio of about 20 ms."""

def __init__(self, source, out_rate=8000):
self.source = source
self.rs = dsp.Resampler(source.rate, out_rate) if source.rate != out_rate else None

def blocks(self):
for b in self.source.blocks():
y = self.rs.process(b) if self.rs else b
if len(y):
yield y.astype(float)

def trim(self, ppm):
if self.rs:
self.rs.trim = ppm


def test_tone(freq=1000.0, level=0.5, seconds=None, block_s=0.02, rate=8000):
"""A sine as an 8 kHz source (for --test-tone); endless when seconds is None."""
n = int(rate * block_s)
i = 0
total = None if seconds is None else int(seconds * rate)
while total is None or i < total:
k = n if total is None else min(n, total - i)
t = (np.arange(i, i + k)) / rate
yield level * np.sin(2 * np.pi * freq * t)
i += k
Loading
Loading