Compare commits

..
Author SHA1 Message Date
sjg bf819aa177 [fix](trx-frontend): narrow weak WFM to 60 kHz
CI / lint (pull_request) Failing after 1s
CI / test (pull_request) Failing after 2s
CI / reuse (pull_request) Failing after 2s
2026-08-01 02:03:53 +02:00
sjg 0f4afda843 [fix](trx-frontend): make auto bandwidth modulation-aware
CI / lint (pull_request) Failing after 0s
CI / test (pull_request) Failing after 0s
CI / reuse (pull_request) Failing after 0s
2026-08-01 02:02:13 +02:00
sjg 5654520901 [fix](workspace): clear build and clippy warnings
CI / lint (push) Failing after 1s
CI / test (push) Failing after 1s
CI / reuse (push) Failing after 1s
2026-08-01 01:52:08 +02:00
sjg ff75fcc692 [refactor](trx-server): extract decoder history store
CI / lint (pull_request) Failing after 2s
CI / test (pull_request) Failing after 2s
CI / reuse (pull_request) Failing after 1s
CI / lint (push) Failing after 2s
CI / test (push) Failing after 2s
CI / reuse (push) Failing after 1s
2026-08-01 01:45:19 +02:00
sjg 4728b578ae [refactor](trx-server): extract history policy 2026-08-01 01:44:26 +02:00
sjg 7db7fad9b0 [refactor](trx-frontend): define module service boundaries 2026-08-01 01:44:26 +02:00
sjg 830f7299fe [fix](trx-frontend): vendor Opus decoder 2026-08-01 01:44:26 +02:00
sjg 061738a63b [fix](trx-frontend): serialize plugin loading
CI / lint (push) Failing after 1s
CI / test (push) Failing after 1s
CI / reuse (push) Failing after 1s
2026-08-01 01:43:50 +02:00
sjg e8bd97655f [fix](trx-server): offload history persistence
CI / reuse (push) Failing after 1s
CI / lint (push) Failing after 2s
CI / test (push) Failing after 2s
2026-08-01 01:43:47 +02:00
sjg 7d0b36450d [fix](trx-server): persist all decoder histories
CI / reuse (push) Failing after 1s
CI / lint (pull_request) Failing after 3s
CI / test (pull_request) Failing after 1s
CI / reuse (pull_request) Failing after 2s
CI / lint (push) Failing after 1s
CI / test (push) Failing after 1s
2026-08-01 01:23:36 +02:00
Stan Grams b12c83e8b5 [fix](trx-frontend): preload AIS map icons
CI / lint (pull_request) Failing after 6s
CI / test (pull_request) Failing after 2s
CI / reuse (pull_request) Failing after 1s
CI / lint (push) Failing after 1s
CI / test (push) Failing after 2s
CI / reuse (push) Failing after 0s
2026-08-01 01:14:07 +02:00
sjg ff4e2a5c5d [chore](trx-rs): install reuse with charset-normalizer extra
CI / lint (pull_request) Successful in 9m35s
CI / reuse (pull_request) Failing after 5s
CI / lint (push) Successful in 8m40s
CI / test (pull_request) Successful in 29m0s
CI / reuse (push) Failing after 5s
CI / test (push) Successful in 14m28s
The runner image's `reuse` failed to import (NoEncodingModuleError): it
needs an encoding-detection backend, which the bare `reuse` install does
not provide and which libmagic/`file` is not present to satisfy. Install
`reuse[charset-normalizer]` so the reuse job can run in the image.

Rebuild the runner image and recreate the containers to pick this up.

Assisted-By: Claude Code (claude-opus-4)
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-18 23:57:38 +02:00
sjg 2ef9f80fc1 [chore](trx-rs): drop redundant CI setup steps for baked runner image
CI / lint (pull_request) Successful in 9m14s
CI / reuse (pull_request) Failing after 6s
CI / test (pull_request) Successful in 15m15s
The host-executor runners run jobs inside one container that already has
the Rust toolchain and all build dependencies baked in, so the per-job
`apt-get install` and rustup steps were redundant. Worse, with two jobs
running concurrently in the same runner they collided on the dpkg lock
("Could not get lock /var/lib/dpkg/lock-frontend").

Remove the system-dependency, rustup and cache steps; jobs now run cargo
directly. The cargo registry persists in the long-lived runner container.

Assisted-By: Claude Code (claude-opus-4)
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-18 23:33:42 +02:00
sjg 6fe549e34e [chore](trx-rs): run reuse lint directly instead of Docker action
CI / test (pull_request) Failing after 52s
CI / reuse (pull_request) Failing after 3s
CI / lint (pull_request) Successful in 3m34s
The host-executor runners have no Docker daemon, so fsfe/reuse-action
(a Docker action) fails with "Cannot connect to the Docker daemon". Call
the reuse CLI directly; it is baked into the runner image.

Assisted-By: Claude Code (claude-opus-4)
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-18 13:24:26 +02:00
sjg 406a8f86b1 [chore](trx-rs): add Podman act_runner CI deployment
CI / lint (pull_request) Successful in 2m43s
CI / test (pull_request) Successful in 3m20s
CI / reuse (pull_request) Successful in 7s
CI / lint (push) Successful in 2m36s
CI / test (push) Successful in 2m35s
CI / reuse (push) Failing after 4s
Add container/: a rootless Podman + systemd (Quadlet) setup to run
per-project Gitea Actions runners on one host instead of VMs. Uses the
host executor with a purpose-built image that bakes in the Rust toolchain
and all build dependencies (opus, alsa, soapysdr, clang), so CI runs skip
the per-run install and cold soapysdr-sys build.

Includes the runner Containerfile, first-boot registration entrypoint,
act_runner config template, two Quadlet units (trx-rs + a second project),
and a README covering build, registration, the required host-executor
workflow tweak, and tuning.

Assisted-By: Claude Code (claude-opus-4)
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-18 12:45:53 +02:00
sjg 4b17b4ac1d [style](trx-ftx): use iterators in LDPC single-index loops
CI / lint (pull_request) Successful in 2m35s
CI / test (pull_request) Successful in 3m22s
CI / reuse (pull_request) Successful in 7s
CI / lint (push) Successful in 2m34s
CI / test (push) Successful in 3m26s
CI / reuse (push) Successful in 7s
clippy needless_range_loop (rust 1.97) flagged the loops in ldpc_check
and ldpc_decode that use a range only to index one array. Replace them
with iterator/enumerate forms. The belief-propagation loops that index
several arrays by the same variable are left as-is (not flagged).

Behaviour is unchanged; the transformations are index-for-index
equivalent. Verified the lib compiles and is clippy-clean; the crate's
LDPC tests run in the CI test job (they need a dev-dependency not
available in the local offline sandbox).

Assisted-By: Claude Code (claude-opus-4)
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-18 10:43:01 +02:00
sjg 977f7b709e [style](trx-ais): drop redundant u32 cast
CI / lint (pull_request) Failing after 2m28s
CI / test (pull_request) Successful in 3m23s
CI / reuse (pull_request) Successful in 7s
get_uint returns Option<u32>, so `? as u32` is an unnecessary same-type
cast flagged by clippy under -D warnings (rust 1.97).

Assisted-By: Claude Code (claude-opus-4)
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-18 10:28:55 +02:00
sjg a2838b06a2 [style](trx-ftx): fix clippy question_mark and collapsible_match
CI / lint (pull_request) Failing after 2m22s
CI / test (pull_request) Successful in 3m27s
CI / reuse (pull_request) Successful in 8s
CI runs a newer clippy (1.97) than was available locally, which flagged
three lints in trx-ftx not caught earlier:

- question_mark: replace the Some/None match in CallsignHashTable::lookup
  with `self.entries[idx].as_ref()?`
- collapsible_match: fold the nested `if` in text.rs char/nchar into match
  guards on the AlphanumSpaceSlash arm

Behaviour is unchanged; verified clean with nightly clippy (1.93).

Assisted-By: Claude Code (claude-opus-4)
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-18 09:25:12 +02:00
sjg c6cd661676 [style](trx-rs): fix clippy warnings for -D warnings CI
CI / lint (pull_request) Failing after 4m14s
CI / test (pull_request) Successful in 15m22s
CI / reuse (pull_request) Successful in 7s
The CI lint job runs clippy with -D warnings, which surfaced a set of
existing warnings across decoders, the client, and the soapysdr backend.
Resolve them so the workspace is clean under the enforced lint level:

- collapsible_match / identity_op / needless_range_loop / same_item_push
  in trx-rds, trx-wspr, trx-vdes, trx-wefax, trx-aprs (mostly tests)
- field_reassign_with_default -> struct-update syntax in trx-client config
  tests
- assign_op_pattern, useless vec!, and test-module ordering picked up by
  cargo clippy --fix in trx-client and the soapysdr WFM tests

No behaviour changes; all affected crates' tests pass.

Assisted-By: Claude Code (claude-opus-4)
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-17 23:49:12 +02:00
sjg bf08c7ebc0 [chore](trx-rs): install libclang for soapysdr-sys in CI
CI / lint (pull_request) Failing after 4m7s
CI / reuse (pull_request) Has been cancelled
CI / test (pull_request) Has been cancelled
soapysdr-sys builds bindings with bindgen, which needs libclang at build
time. Add clang and libclang-dev to the system dependencies so the
soapysdr backend (a default feature) compiles under CI.

Assisted-By: Claude Code (claude-opus-4)
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-17 23:30:49 +02:00
sjg c7470acc1c [chore](trx-rs): fix Rust PATH handling in CI
CI / lint (pull_request) Failing after 3m18s
CI / reuse (pull_request) Has been cancelled
CI / test (pull_request) Has been cancelled
The Set up Rust step wrote the cargo bin dir to GITHUB_PATH, which does
not help within the same step and is not relied upon across steps on the
Gitea act_runner. Prepend $HOME/.cargo/bin to PATH directly in the setup
and each cargo step instead, so rustup and cargo resolve regardless of
GITHUB_PATH support.

Assisted-By: Claude Code (claude-opus-4)
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-17 23:25:21 +02:00
sjg bcde03de38 [docs](trx-rs): track improvement areas in aidocs/wip.md
CI / lint (pull_request) Failing after 31s
CI / reuse (pull_request) Successful in 35s
CI / test (pull_request) Failing after 29s
Record the three-tier improvement backlog (infrastructure, robustness,
product) with a per-item progress status column, so the work discovered
in the July 2026 repo scan is tracked. Register aidocs/** in REUSE.toml
alongside docs/**.

Assisted-By: Claude Code (claude-opus-4)
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-17 21:21:57 +02:00
sjg 63d46562c7 [chore](trx-rs): add Gitea Actions CI pipeline
Introduce CI running on push to main and pull requests. Three jobs:
lint (rustfmt check + clippy with -D warnings), test (build and test the
workspace with --locked), and REUSE compliance. Installs the required
system libraries (opus, alsa, soapysdr) and caches the cargo registry
and target directory.

Assisted-By: Claude Code (claude-opus-4)
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-17 21:21:57 +02:00
sjg e575b3b365 [docs](trx-rs): adopt kernel-style AI attribution trailers
Replace the guidance to credit LLM usage via 'Co-authored-by:' with the
Linux kernel convention. Co-Authored-By and Co-Developed-By are reserved
for human authors (who must also sign off); AI/LLM assistance is
disclosed with an Assisted-By: trailer instead.

Apply the new policy to this commit as a worked example.

Assisted-By: Claude Code (claude-opus-4)
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-17 21:10:09 +02:00
sjgandClaude Opus 4.8 2121817c04 [style](trx-frontend-http): refine web UI design system and a11y
Introduce a shared design-token layer and apply it to the web
frontend for a more consistent, readable, and accessible feel.
Pure CSS plus one HTML block; no app.js behaviour changes, and the
existing multi-theme (style x light/dark) system is preserved.

- Add spacing, type, radius and motion tokens to :root.
- Fix undefined --surface consumed by .controls-tray, which dropped
  the panel background entirely; it now resolves per theme.
- Set body line-height and font smoothing; collapse near-duplicate
  font sizes onto canonical scale steps.
- Rebuild the auth gate with classes and replace hardcoded colours
  (#ff6b6b, #9aa4b5) with theme variables so it renders correctly in
  every theme.
- Add an opacity fade on tab switches, gated by prefers-reduced-motion.
- Extend focus-visible rings to the spectrum canvas, tabindex controls
  and links.
- Add a self-theming --accent-text token to lift accent-coloured text
  (links, active tab) to WCAG AA without altering brand fills.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NFpGtGTWUEYXLwZeZs2RAV
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-07-17 20:57:43 +02:00
sjgandClaude Opus 4.7 d0bd38d7df [docs](trx-frontend-http): point footer repo link to Gitea
Repoint the web UI footer link to git.haxx.space/sjg/trx-rs, swap the
GitHub octocat mark for a host-neutral git-branch icon, and relabel to
"trx-rs source".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-05-18 00:06:45 +02:00
sjgandClaude Opus 4.7 bf9617e24d [docs](trx-rs): migrate wiki links from GitHub to Gitea
Point README wiki/repo URLs at git.haxx.space/sjg/trx-rs (the new
primary upstream); same /wiki/<Page> path scheme as before.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-05-18 00:05:29 +02:00
sjgandClaude Opus 4.7 3c235fce5e [chore](trx-rs): REUSE 3.3 compliance, drop GitHub wiki workflow
Add a root REUSE.toml annotating docs, repo metadata, logos, vendored
Leaflet (BSD-2-Clause) and the DSEG14 font (OFL-1.1) instead of
per-file headers; add LICENSES/OFL-1.1.txt. reuse lint: compliant.

Also remove .github/workflows/wiki.yml: the project moved off GitHub
to a self-hosted Gitea, so the GitHub Actions wiki-publishing workflow
no longer runs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-05-18 00:05:24 +02:00
sjg ba48de2d30 Initial commit
Sync docs to Wiki / wiki (push) Has been cancelled
Signed-off-by: Stan Grams <sjg@haxx.space>
2026-05-17 23:25:14 +02:00
220 changed files with 4691 additions and 1662 deletions
+4
View File
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
#
# SPDX-License-Identifier: GPL-2.0-or-later
# Enable CPU optimizations for better performance # Enable CPU optimizations for better performance
# Set target-cpu to native to use all available CPU features on the build machine # Set target-cpu to native to use all available CPU features on the build machine
+47
View File
@@ -0,0 +1,47 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
#
# SPDX-License-Identifier: GPL-2.0-or-later
# CI for the self-hosted, host-executor Podman runners (see container/).
# The runner image bakes in the Rust toolchain and all build dependencies,
# so jobs go straight to cargo — no apt/rustup setup steps (which also
# collided on the dpkg lock when jobs ran concurrently in the same runner).
name: CI
on:
push:
branches: [main]
pull_request:
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: rustfmt
run: cargo fmt --all -- --check
- name: clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --workspace --all-targets --locked
- name: Test
run: cargo test --workspace --locked
reuse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: REUSE compliance
# `reuse` CLI instead of fsfe/reuse-action: the latter is a Docker
# action, which the host-executor runners cannot run. `reuse` is baked
# into the runner image (see container/Containerfile).
run: reuse lint
-39
View File
@@ -1,39 +0,0 @@
name: Sync docs to Wiki
on:
push:
branches: [main]
paths:
- 'docs/**'
workflow_dispatch:
permissions:
contents: write
jobs:
wiki:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout wiki
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}.wiki
path: wiki
token: ${{ secrets.GITHUB_TOKEN }}
- name: Sync docs to wiki
run: |
rsync -av --delete --exclude='.git' docs/ wiki/
cd wiki
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --cached --quiet; then
echo "No wiki changes to commit."
else
git commit -m "Sync docs from ${GITHUB_SHA::8}"
git push
fi
+21 -1
View File
@@ -18,7 +18,7 @@ When contributing to the project, please follow these guidelines:
- Use a maximum of 80 characters per line. - Use a maximum of 80 characters per line.
- Use a blank line between the commit message and the body. - Use a blank line between the commit message and the body.
- Sign your commits with `git commit -s`. - Sign your commits with `git commit -s`.
- Explicitly mark LLM usage in commit messages with 'Co-authored-by:'. - Disclose AI/LLM assistance with an `Assisted-By:` trailer (see below).
Use the format below for commit titles: Use the format below for commit titles:
[<type>](<crate>): <description> [<type>](<crate>): <description>
@@ -39,3 +39,23 @@ Allowed types:
- chore: build or maintenance changes - chore: build or maintenance changes
Write isolated commits for each crate. Write isolated commits for each crate.
## Attribution trailers
This project follows the Linux kernel convention for crediting work.
The `Co-Authored-By:` and `Co-Developed-By:` trailers name **people** who
authored the change. They are reserved for humans, and every person named
this way must also add their own `Signed-off-by:` line. Never use these
trailers for tools, assistants, or bots.
When a commit was produced with help from an AI assistant or LLM,
disclose it with an `Assisted-By:` trailer naming the tool (and model,
where relevant). The human committer remains the author of record and
takes responsibility for the change through `Signed-off-by:`.
Example:
Assisted-By: Claude Code (claude-opus-4)
Co-Authored-By: Jane Developer <jane@example.com>
Signed-off-by: Your Name <you@example.com>
Generated
+2
View File
@@ -3178,6 +3178,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"actix-ws", "actix-ws",
"base64",
"brotli 7.0.0", "brotli 7.0.0",
"bytes", "bytes",
"dirs", "dirs",
@@ -3261,6 +3262,7 @@ dependencies = [
name = "trx-server" name = "trx-server"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"base64",
"bytes", "bytes",
"chrono", "chrono",
"clap", "clap",
+1 -1
View File
@@ -1,3 +1,3 @@
SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
SPDX-License-Identifier: BSD-2-Clause SPDX-License-Identifier: GPL-2.0-or-later
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[workspace] [workspace]
members = [ members = [
-143
View File
@@ -1,143 +0,0 @@
# Fix Plan
Current state analysis of trx-rs as of 2026-04-08.
## Overall Assessment
The codebase is in good shape. Clippy is clean, no `unsafe` code, no TODO/FIXME markers,
robust error handling throughout. One broken test and several untested crates are the
main weak spots.
---
## P0 — Broken Test
### 1. `test_toggle_ft8_decode` returns 500 instead of 200
**Location:** `src/trx-client/trx-frontend/trx-frontend-http/src/api/mod.rs:1016`
**Root cause:** The handler `toggle_ft8_decode` (decoder.rs:353) requires
`context: web::Data<Arc<FrontendRuntimeContext>>` for multi-rig state resolution.
The test registers `state_rx` and `rig_tx` but not `context`, so actix-web returns 500
(missing app data). A `make_context()` helper already exists at line 757 but is unused
by this test.
**Fix:** Add `.app_data(web::Data::new(make_context()))` to the test's `App` builder
(line 1036-1041). ~1 line change.
**Impact:** This is the only failing test in the entire suite (50 pass, 1 fail).
---
## P1 — Test Coverage Gaps
### 2. trx-aprs decoder — 0 tests (596 LOC)
**Location:** `src/decoders/trx-aprs/src/lib.rs`
Bell 202 AFSK demodulator + AX.25 HDLC frame parser + CRC-16 validation.
No `#[cfg(test)]` module at all.
**Suggested tests:**
- CRC-16 computation on known frames
- HDLC flag detection and bit-unstuffing
- Full frame decode from synthetic AFSK audio (1200 baud sine pairs)
- Rejection of corrupted frames (bad CRC, truncated)
### 3. trx-decode-log — 0 tests (226 LOC)
**Location:** `src/decoders/trx-decode-log/src/lib.rs`
JSON Lines file writer with date-based rotation. Pure I/O wrapper.
**Suggested tests:**
- Write + read-back round-trip in a tempdir
- Date rotation triggers new file creation
- Flush error logging (mock writer)
### 4. trx-reporting — partial tests (1,065 LOC across 2 files)
**Location:** `src/trx-reporting/src/pskreporter.rs` (582 LOC),
`src/trx-reporting/src/aprsfi.rs` (483 LOC)
Both files have `#[cfg(test)]` modules but coverage is limited to serialization.
Network behavior (reconnect, rate-limit, batching) is untested.
**Suggested tests:**
- PSKReporter UDP datagram encoding round-trip
- APRS-IS login line formatting
- Spot batching and dedup logic (unit-testable without network)
---
## P2 — Code Quality
### 5. `audio.rs` is 4,000 LOC
**Location:** `src/trx-server/src/audio.rs`
Houses all decoder task launchers (FT8, FT4, FT2, APRS, AIS, VDES, CW, WSPR, LRPT,
WEFAX). Each launcher follows the same pattern. The file is coherent but large.
**Suggested improvement:** Extract decoder launchers into a `decoders/` submodule
within trx-server, one file per decoder family (e.g., `ftx.rs`, `aprs.rs`, `wefax.rs`).
Keep the audio pipeline and capture logic in `audio.rs`.
### 6. `scheduler.rs` is 1,585 LOC
**Location:** `src/trx-client/trx-frontend/trx-frontend-http/src/scheduler.rs`
Mixes grayline computation, timespan matching, satellite pass prediction, and the
scheduler state machine. Well-tested but dense.
**Suggested improvement:** Extract grayline and satellite pass logic into separate
modules (these are pure functions with no HTTP dependencies).
---
## P3 — Minor
### 7. `#[allow(dead_code)]` in soapysdr backend (4 annotations)
**Locations:**
- `vchan_impl.rs:66,87``fixed_slot_count`, `process_pair`
- `real_iq_source.rs:20``device`
- `demod.rs:113` — lifetime anchor
All documented as intentional (lifetime anchors / reserved capacity). No action needed
unless the fields can be converted to `PhantomData` or `_`-prefixed without breaking
semantics.
### 8. FrontendRuntimeContext test helper duplication risk
**Location:** `src/trx-client/trx-frontend/trx-frontend-http/src/api/mod.rs:757`
`make_context()` and `spawn_rig_responder()` are good helpers but only used by some
tests. As new endpoint tests are added, ensure they consistently use these helpers to
avoid repeating the `test_toggle_ft8_decode` bug.
---
## Implementation Order
```mermaid
gantt
title Fix Plan
dateFormat X
axisFormat %s
section P0
Fix test_toggle_ft8_decode :p0, 0, 1
section P1
Add trx-aprs tests :p1a, 1, 3
Add trx-decode-log tests :p1b, 1, 2
Expand trx-reporting tests :p1c, 1, 3
section P2
Split audio.rs decoder launchers :p2a, 3, 5
Extract scheduler pure functions :p2b, 3, 5
```
P0 is a one-line fix. P1 items are independent and can be parallelized. P2 items are
refactors that should wait until P1 tests provide regression safety.
+338
View File
@@ -0,0 +1,338 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Moe Ghoul>, 1 April 1989
Moe Ghoul, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+43
View File
@@ -0,0 +1,43 @@
SIL OPEN FONT LICENSE
Version 1.1 - 26 February 2007
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting, or substituting — in part or in whole — any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
+16 -7
View File
@@ -5,7 +5,7 @@
A modular amateur radio control stack written in Rust. A modular amateur radio control stack written in Rust.
[![License](https://img.shields.io/badge/license-BSD--2--Clause-blue.svg)](LICENSES) [![License](https://img.shields.io/badge/license-GPL--2.0--or--later-blue.svg)](LICENSES)
</div> </div>
@@ -64,9 +64,15 @@ brew install soapysdr
``` ```
</details> </details>
See [Build Requirements](https://github.com/sgrams/trx-rs/wiki/User-Manual#build-requirements) See [Build Requirements](https://git.haxx.space/sjg/trx-rs/wiki/User-Manual#build-requirements)
in the wiki for details on each library. in the wiki for details on each library.
> **Note:** `cmake` is required even when a system Opus library is installed.
> The `audiopus_sys` crate probes for Opus via `pkg-config`; if it is not found
> (or `pkg-config` is unavailable), it falls back to compiling a vendored copy
> of Opus with CMake. A missing `cmake` therefore fails the build with
> `is cmake not installed?` rather than a missing-Opus error.
### 2. Build ### 2. Build
```bash ```bash
@@ -127,12 +133,15 @@ a unified set of frontends.
| Resource | Description | | Resource | Description |
|----------|-------------| |----------|-------------|
| [User Manual](https://github.com/sgrams/trx-rs/wiki/User-Manual) | Configuration, features, and usage | | [User Manual](https://git.haxx.space/sjg/trx-rs/wiki/User-Manual) | Configuration, features, and usage |
| [Architecture](https://github.com/sgrams/trx-rs/wiki/Architecture) | System design, crate layout, data flow, and internals | | [Architecture](https://git.haxx.space/sjg/trx-rs/wiki/Architecture) | System design, crate layout, data flow, and internals |
| [Optimization Guidelines](https://github.com/sgrams/trx-rs/wiki/Optimization-Guidelines) | Performance guidelines for the real-time DSP pipeline | | [Optimization Guidelines](https://git.haxx.space/sjg/trx-rs/wiki/Optimization-Guidelines) | Performance guidelines for the real-time DSP pipeline |
| [Planned Features](https://github.com/sgrams/trx-rs/wiki/Planned-Features) | Roadmap and design notes | | [Planned Features](https://git.haxx.space/sjg/trx-rs/wiki/Planned-Features) | Roadmap and design notes |
| [Contributing](CONTRIBUTING.md) | Commit conventions, workflow, and code style | | [Contributing](CONTRIBUTING.md) | Commit conventions, workflow, and code style |
## License ## License
BSD-2-Clause. See [`LICENSES`](LICENSES) for bundled third-party license files. GPL-2.0-or-later. See [`LICENSES`](LICENSES) for the full license text and
bundled third-party license files. Bundled third-party components retain their
original licenses: Leaflet is BSD-2-Clause, DSEG is OFL-1.1, and opus-decoder
is MIT.
+52
View File
@@ -0,0 +1,52 @@
version = 1
# Project-owned files without an in-file SPDX header (docs, config,
# repo metadata, logos, and bespoke web assets).
[[annotations]]
path = [
".gitattributes",
".gitignore",
"CLAUDE.md",
"CONTRIBUTING.md",
"README.md",
"trx-rs.toml.example",
"docs/**",
"aidocs/**",
"src/decoders/trx-ftx/README.md",
"src/decoders/trx-wxsat/README.md",
"assets/trx-logo.png",
"src/trx-client/trx-frontend/trx-frontend-http/assets/trx-favicon.png",
"src/trx-client/trx-frontend/trx-frontend-http/assets/trx-logo.png",
"src/trx-client/trx-frontend/trx-frontend-http/assets/web/bandplan.json",
"src/trx-client/trx-frontend/trx-frontend-http/assets/web/leaflet-ais-tracksymbol.js",
]
SPDX-FileCopyrightText = "2026 Stan Grams <sjg@haxx.space>"
SPDX-License-Identifier = "GPL-2.0-or-later"
# Vendored Leaflet 1.9.4 (https://leafletjs.com), distributed under BSD-2-Clause.
[[annotations]]
path = [
"src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/leaflet.js",
"src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/leaflet.css",
"src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/layers.png",
"src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/layers-2x.png",
"src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/marker-icon.png",
"src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/marker-icon-2x.png",
"src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/marker-shadow.png",
]
SPDX-FileCopyrightText = "2010-2023 Vladimir Agafonkin, 2010-2011 CloudMade"
SPDX-License-Identifier = "BSD-2-Clause"
# Vendored DSEG14 font (https://github.com/keshikan/DSEG), SIL OFL 1.1.
[[annotations]]
path = ["src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/dseg14-classic-latin-400-normal.woff2"]
SPDX-FileCopyrightText = "2020 The DSEG Authors (https://github.com/keshikan/DSEG)"
SPDX-License-Identifier = "OFL-1.1"
# Vendored opus-decoder 0.7.11 browser build
# (https://github.com/eshaz/wasm-audio-decoders), MIT.
# SHA-256: fd73ee0a9c8a5e233c0b88234df14f46003ad89bb4ba27435bc8714db2a6dc62
[[annotations]]
path = ["src/trx-client/trx-frontend/trx-frontend-http/assets/web/vendor/opus-decoder-0.7.11.min.js"]
SPDX-FileCopyrightText = "2021-2025 Ethan Halsall"
SPDX-License-Identifier = "MIT"
+89
View File
@@ -0,0 +1,89 @@
# Work In Progress — Project Improvement Areas
Living tracker for engineering-infrastructure and hardening work identified
during a July 2026 repo scan. The architecture-level backlog
(`docs/Improvement-Areas.md`, P0P3) is closed; these items focus on the
tooling, robustness, and product concerns *around* the code.
Status legend: **Done** · **In progress** · **Not started**
| # | Tier | Area | Status |
|----|------|------|--------|
| 1 | 1 — Infrastructure | Gitea Actions CI (fmt, clippy, test, REUSE) | In progress |
| 2 | 1 — Infrastructure | Supply-chain & lint governance (cargo-deny/audit, MSRV, `[workspace.lints]`) | Not started |
| 3 | 1 — Infrastructure | Release & deployment (container image, systemd units, binary releases) | Not started |
| 4 | 2 — Robustness | Panic-resilience audit (harden ~495 unwrap/expect/panic sites) | Not started |
| 5 | 2 — Robustness | `unsafe` SIMD safety scaffolding (`# Safety` docs, scalar↔SIMD equivalence tests) | Not started |
| 6 | 2 — Robustness | DSP performance benchmarks (criterion, guard optimization gains) | Not started |
| 7 | 2 — Robustness | Test-coverage measurement & gap-filling (llvm-cov; CAT backends, server tasks) | Not started |
| 8 | 3 — Product | Frontend modularization & tooling (split `app.js` into ES modules, ESLint, JS tests) | Not started |
| 9 | 3 — Product | Runtime observability (`/health`, Prometheus metrics) | Not started |
| 10 | 3 — Product | Documentation freshness & consolidation (reconcile `docs/` with code) | Not started |
## Tier 1 — Infrastructure gaps
### 1. Gitea Actions CI
No `.gitea/` / `.github/` / Woodpecker workflows exist, despite 768 tests.
Add a workflow running `cargo fmt --check`, `cargo clippy -D warnings`,
`cargo build`/`cargo test`, and REUSE lint on push + pull_request.
System deps: `pkg-config cmake libopus-dev libasound2-dev libsoapysdr-dev`
(the `soapysdr` backend is a default feature).
Notes for the runner: assumes an `act_runner` registered with an
`ubuntu-latest` label and GitHub-action proxying enabled (used by
`actions/checkout`, `actions/cache`, `fsfe/reuse-action`). `clippy` runs
with `-D warnings`; core crates are already clean, but if the first full
`--all-features` run surfaces warnings in a less-travelled crate, fix them
(preferred) or temporarily soften that step.
### 2. Supply-chain & lint governance
No `deny.toml`, `cargo audit`, `rustfmt.toml`/`clippy.toml`, declared MSRV,
or `[workspace.lints]`. Add dependency auditing to CI, pin an MSRV
(`rust-version`), and centralize lint policy in the workspace manifest.
### 3. Release & deployment
No `Dockerfile`, systemd units, packaging, or release automation (only
`script/dummy-server.sh`). Add a container image, example systemd units for
`trx-server`/`trx-client`, and a tag-triggered static-binary release job.
## Tier 2 — Robustness & correctness
### 4. Panic-resilience audit
495 `unwrap()`/`expect()`/`panic!` sites, 11 in the hottest server files
(`audio.rs`, `rig_task.rs`). A panic there can drop a rig task or the
process. Convert hot-path panics to error propagation / graceful
degradation; reserve `expect` for documented invariants.
### 5. `unsafe` SIMD safety scaffolding
13 `unsafe` blocks (AVX2 DSP). Add `# Safety` docs stating invariants,
confirm runtime feature detection is tested, and add property tests
asserting SIMD output matches the scalar fallback across random inputs.
### 6. DSP performance benchmarks
`docs/Optimization-Guidelines.md` documents NCO/polyphase/AVX2 gains, but no
`criterion` benches guard them. Add benches for the demod/resample/FFT hot
paths so regressions surface as numbers.
### 7. Test-coverage measurement & gap-filling
67 of 146 Rust files have no test module. Protocol is well covered; backends
(CAT BCD/ASCII encoding), `listener.rs`, and `config.rs` look thin. Wire up
`cargo-llvm-cov` and target the CAT backends and server tasks first.
## Tier 3 — Product & maintainability
### 8. Frontend modularization & tooling
`app.js` is 8,760 lines and `map-core.js` 3,515, with no modules, linter, or
tests. Keeping vanilla HTML+JS (no framework), split into native ES modules
by concern, add ESLint + Prettier, and add `node:test` unit tests for pure
logic (frequency formatting, unit math, decode parsing).
### 9. Runtime observability
`tracing` is set up, but there is no `/health` endpoint or metrics
instrumentation. Add health/readiness endpoints and Prometheus-format
metrics (decode rates, reconnects, audio underruns, per-rig state).
### 10. Documentation freshness & consolidation
`docs/` (13 files) is mostly dated 2026-03-29 while code moved into July, and
mixes planning artifacts with reference docs. Reconcile against current code,
separate "plans" from "reference," and fold still-true content into the
canonical docs.
+61
View File
@@ -0,0 +1,61 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
#
# SPDX-License-Identifier: GPL-2.0-or-later
# Gitea Actions runner image for trx-rs CI (host-executor / "Pattern B").
#
# All build dependencies, the Rust toolchain, Node.js (for JS actions such as
# actions/checkout and actions/cache) and the `reuse` tool are baked in, so CI
# runs skip the per-run apt/rustup install cost. `sudo` is present so the
# existing workflow's `sudo apt-get ...` / rustup steps remain valid — they
# just become fast no-ops because everything is already installed.
FROM docker.io/library/debian:bookworm-slim
ARG ACT_RUNNER_VERSION=0.2.11
ARG NODE_MAJOR=20
ENV DEBIAN_FRONTEND=noninteractive \
RUSTUP_HOME=/opt/rustup \
CARGO_HOME=/opt/cargo \
PATH=/opt/cargo/bin:/usr/local/bin:/usr/bin:/bin
# Base tooling + trx-rs build dependencies (mirrors .gitea/workflows/ci.yml).
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl xz-utils git sudo pipx \
build-essential pkg-config cmake clang libclang-dev \
libopus-dev libasound2-dev libsoapysdr-dev \
&& rm -rf /var/lib/apt/lists/*
# Node.js (JS-based actions need node in PATH under the host executor).
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
# REUSE >= 3 (Debian's packaged reuse is too old for REUSE.toml).
# The [charset-normalizer] extra provides an encoding-detection backend;
# without it (and without libmagic) reuse fails to import at runtime.
RUN PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install 'reuse[charset-normalizer]'
# Rust stable with rustfmt + clippy, installed system-wide.
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --no-modify-path --profile minimal \
--component rustfmt --component clippy \
&& chmod -R a+rwX "$CARGO_HOME" "$RUSTUP_HOME"
# act_runner binary.
RUN arch="$(dpkg --print-architecture)"; \
case "$arch" in amd64) rarch=amd64;; arm64) rarch=arm64;; *) echo "unsupported arch $arch" >&2; exit 1;; esac; \
curl -fsSL -o /usr/local/bin/act_runner \
"https://gitea.com/gitea/act_runner/releases/download/v${ACT_RUNNER_VERSION}/act_runner-${ACT_RUNNER_VERSION}-linux-${rarch}" \
&& chmod +x /usr/local/bin/act_runner
# Default config template (seeded into the /data volume on first boot).
COPY config.yaml /etc/act_runner/config.yaml
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# /data holds the .runner registration, cache and workflow workspaces.
VOLUME /data
WORKDIR /data
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
+118
View File
@@ -0,0 +1,118 @@
<!--
SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
SPDX-License-Identifier: GPL-2.0-or-later
-->
# Podman-based Gitea Actions runners
Run two independent Gitea Actions runners on one host as rootless Podman
containers managed by systemd (Quadlet) — one per project — instead of two
VMs. Uses the **host executor**: workflow steps run directly inside a
purpose-built runner image that already has the Rust toolchain and all build
dependencies baked in, so CI runs skip the per-run install cost and no
Docker/Podman socket is needed.
## Files
| File | Purpose |
|------|---------|
| `Containerfile` | Runner image: Debian + build deps + clang + Rust + Node + `reuse` + `act_runner`. |
| `entrypoint.sh` | Registers on first boot (if needed), then runs the daemon. |
| `config.yaml` | act_runner config template (seeded into each runner's volume). |
| `trx-rs-runner.container` | Quadlet unit for the trx-rs runner. |
| `project2-runner.container` | Quadlet unit for the second project's runner. |
## Prerequisites (once per host)
Rootless Podman with cgroups v2 (default on modern distros). As the unprivileged
user that will own the runners:
```bash
# Survive logout / start on boot without an interactive session.
loginctl enable-linger "$USER"
```
No `podman.socket` is required for the host executor.
## 1. Build the image
```bash
cd container
podman build -t trx-rs-ci:latest .
```
## 2. Get a registration token
For **each** repo: *Settings → Actions → Runners → Create new Runner* and copy
the token. (Org- or instance-level tokens work too if you prefer wider scope.)
## 3. Install and start the runners
```bash
mkdir -p ~/.config/containers/systemd
cp trx-rs-runner.container project2-runner.container ~/.config/containers/systemd/
# Paste each repo's token for the FIRST boot only:
# Environment=GITEA_RUNNER_REGISTRATION_TOKEN=xxxx…
$EDITOR ~/.config/containers/systemd/trx-rs-runner.container
$EDITOR ~/.config/containers/systemd/project2-runner.container
systemctl --user daemon-reload
systemctl --user start trx-rs-runner
systemctl --user start project2-runner
systemctl --user status trx-rs-runner
podman logs -f gitea-runner-trx-rs
```
Once each runner shows **online** in the repo's runner list, blank out the
`GITEA_RUNNER_REGISTRATION_TOKEN` line again (the registration is persisted in
the `…-data` volume) and `systemctl --user daemon-reload`.
## Required workflow change: the `reuse` job
The host executor runs steps directly in the container and therefore **cannot
run Docker-based actions**. The current `reuse` job uses `fsfe/reuse-action@v5`,
which is a Docker action. `reuse` is baked into the image, so replace that job
with a plain command:
```yaml
reuse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: REUSE compliance
run: reuse lint
```
The `lint` and `test` jobs need no changes: their `sudo apt-get …` and rustup
steps still run, but become fast no-ops because the image already has those
packages and the toolchain. (`sudo` is included in the image for exactly this
reason.)
> If you would rather keep Docker-based actions and per-run images, use the
> **Docker executor** instead: drop the `:host` suffix from the label in
> `config.yaml`, enable `systemctl --user --now enable podman.socket`, mount it
> into the container, and set `container.docker_host` to the socket path. That
> trades the baked-in speed for stronger per-job isolation.
## Tuning
- **`capacity`** (in `config.yaml`) — concurrent jobs per runner. Rust builds
are heavy; 12 is sensible when two runners share a host.
- **`PodmanArgs=--cpus/--memory`** (in each `.container`) — hard resource caps
so one project cannot starve the other.
- **SELinux** — the `:Z` volume flag is already set; keep it if SELinux is
enforcing.
## Committing these files
If you add this directory to a REUSE-checked repo, register the markdown in
`REUSE.toml` (the other files carry inline SPDX headers):
```toml
[[annotations]]
path = ["container/**"]
SPDX-FileCopyrightText = "2026 Stan Grams <sjg@haxx.space>"
SPDX-License-Identifier = "GPL-2.0-or-later"
```
+32
View File
@@ -0,0 +1,32 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# act_runner configuration template. Seeded into /data/config.yaml on first
# boot; edit the copy inside the volume to change settings per runner.
log:
level: info
runner:
# Registration state. Relative to the daemon's working directory (/data).
file: .runner
# Concurrent jobs this runner will pick up. Rust builds are heavy — keep this
# modest, especially if two runners share one host. The trx-rs workflow has
# three parallel jobs (lint, test, reuse); capacity 2 lets two overlap.
capacity: 2
timeout: 3h
# Map the workflow's `runs-on: ubuntu-latest` to the HOST executor, i.e. run
# steps directly inside THIS container (which already has all the toolchain).
# No Docker/Podman socket is required in this mode.
labels:
- "ubuntu-latest:host"
cache:
# Built-in actions cache server (used by actions/cache). Stored in the volume.
enabled: true
dir: "/data/cache"
host:
# Where per-job workspaces are created.
workdir_parent: /data/workflows
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Registers the runner on first boot (if no .runner state exists in /data),
# then runs the act_runner daemon. Idempotent: on subsequent boots it reuses
# the stored registration and ignores the token.
set -euo pipefail
CONFIG_FILE="${CONFIG_FILE:-/data/config.yaml}"
cd /data
# Seed the config from the image's template on first boot so it lives in the
# persistent volume and can be edited there.
if [ ! -f "$CONFIG_FILE" ]; then
cp /etc/act_runner/config.yaml "$CONFIG_FILE"
fi
# runner.file in config.yaml is ".runner" (relative to this CWD => /data/.runner).
if [ ! -f /data/.runner ]; then
if [ -z "${GITEA_RUNNER_REGISTRATION_TOKEN:-}" ]; then
echo "ERROR: no /data/.runner registration and GITEA_RUNNER_REGISTRATION_TOKEN is empty." >&2
echo " Grab a token from the repo's Settings -> Actions -> Runners and set it" >&2
echo " in the Quadlet unit for the first boot only." >&2
exit 1
fi
echo "Registering runner '${GITEA_RUNNER_NAME:-podman}' with ${GITEA_INSTANCE_URL} ..."
act_runner register --no-interactive \
--config "$CONFIG_FILE" \
--instance "${GITEA_INSTANCE_URL:?set GITEA_INSTANCE_URL}" \
--token "$GITEA_RUNNER_REGISTRATION_TOKEN" \
--name "${GITEA_RUNNER_NAME:-podman}" \
--labels "${GITEA_RUNNER_LABELS:-ubuntu-latest:host}"
fi
exec act_runner daemon --config "$CONFIG_FILE"
+40
View File
@@ -0,0 +1,40 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Rootless Podman Quadlet for the SECOND project's Gitea Actions runner,
# co-located on the same host as the trx-rs runner.
#
# It has its own name, its own data volume and its own registration token, so
# the two runners are fully independent. They share the `ubuntu-latest` label,
# but registration SCOPE (which repo each token came from) keeps their jobs
# separate — neither will pick up the other's work.
#
# If project 2 needs different build dependencies, build it its own image from
# an adjusted Containerfile and point Image= at that instead of reusing the
# trx-rs image below.
[Unit]
Description=Gitea Actions runner — project 2
After=network-online.target
Wants=network-online.target
[Container]
Image=localhost/gitea-act-runner:latest
ContainerName=gitea-runner-project2
Volume=gitea-runner-project2-data:/data:Z
Environment=CONFIG_FILE=/data/config.yaml
Environment=GITEA_INSTANCE_URL=https://git.haxx.space
Environment=GITEA_RUNNER_NAME=project2-podman
Environment=GITEA_RUNNER_LABELS=ubuntu-latest:host
Environment=GITEA_RUNNER_REGISTRATION_TOKEN=
PodmanArgs=--cpus=4.0 --memory=6g
[Service]
Restart=always
TimeoutStartSec=0
[Install]
WantedBy=default.target
+41
View File
@@ -0,0 +1,41 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Rootless Podman Quadlet for the trx-rs Gitea Actions runner.
# Install to ~/.config/containers/systemd/trx-rs-runner.container then:
# systemctl --user daemon-reload
# systemctl --user start trx-rs-runner
#
# First boot only: paste a registration token (repo Settings -> Actions ->
# Runners) into GITEA_RUNNER_REGISTRATION_TOKEN. After the runner appears
# online you can blank it again — the registration is persisted in the volume.
[Unit]
Description=Gitea Actions runner — trx-rs
After=network-online.target
Wants=network-online.target
[Container]
Image=localhost/trx-rs-ci:latest
ContainerName=gitea-runner-trx-rs
# Persistent state: .runner registration, cache, workspaces.
Volume=gitea-runner-trx-rs-data:/data:Z
Environment=CONFIG_FILE=/data/config.yaml
Environment=GITEA_INSTANCE_URL=https://git.haxx.space
Environment=GITEA_RUNNER_NAME=trx-rs-podman
Environment=GITEA_RUNNER_LABELS=ubuntu-latest:host
Environment=GITEA_RUNNER_REGISTRATION_TOKEN=
# Resource caps so a heavy Rust build here cannot starve the other project's
# runner on the same host. Tune to your box.
PodmanArgs=--cpus=4.0 --memory=6g
[Service]
Restart=always
# A cold Rust build can be slow; don't let systemd consider startup failed.
TimeoutStartSec=0
[Install]
WantedBy=default.target
+6 -2
View File
@@ -1,9 +1,13 @@
# RDS Parameter Tuning — Work in Progress # RDS Parameter Tuning Notes
*Decoder tuning rationale for `trx-rds`. Recorded 2026-03-27; reflects the
shipped parameter set. Kept as a reference for why these constants were chosen —
not an open work item.*
## Goal ## Goal
Maximum sensitivity (weak-signal decode) with zero false positive PI decodes. Maximum sensitivity (weak-signal decode) with zero false positive PI decodes.
## Changes Made ## Changes Applied
### `src/decoders/trx-rds/src/lib.rs` ### `src/decoders/trx-rds/src/lib.rs`
Executable → Regular
+4
View File
@@ -1,4 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
#
# SPDX-License-Identifier: GPL-2.0-or-later
# Run trx-server with the dummy backend for development and testing. # Run trx-server with the dummy backend for development and testing.
set -euo pipefail set -euo pipefail
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-ais" name = "trx-ais"
+2 -2
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Basic AIS GMSK/HDLC decoder. //! Basic AIS GMSK/HDLC decoder.
//! //!
@@ -243,7 +243,7 @@ fn parse_frame(frame: RawFrame, channel: &str) -> Option<AisMessage> {
let message_type = get_uint(&bits, 0, 6)? as u8; let message_type = get_uint(&bits, 0, 6)? as u8;
let repeat = get_uint(&bits, 6, 2)? as u8; let repeat = get_uint(&bits, 6, 2)? as u8;
let mmsi = get_uint(&bits, 8, 30)? as u32; let mmsi = get_uint(&bits, 8, 30)?;
let mut msg = AisMessage { let mut msg = AisMessage {
rig_id: None, rig_id: None,
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-aprs" name = "trx-aprs"
+5 -5
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Bell 202 AFSK demodulator + AX.25/APRS decoder. //! Bell 202 AFSK demodulator + AX.25/APRS decoder.
//! //!
@@ -638,7 +638,7 @@ mod tests {
for (i, &ch) in b"N0CALL".iter().enumerate() { for (i, &ch) in b"N0CALL".iter().enumerate() {
addr[i] = ch << 1; addr[i] = ch << 1;
} }
addr[6] = (0 << 1) | 1; // SSID=0, last=true addr[6] = 1; // SSID=0, last=true
let decoded = decode_ax25_address(&addr, 0); let decoded = decode_ax25_address(&addr, 0);
assert_eq!(decoded.call, "N0CALL"); assert_eq!(decoded.call, "N0CALL");
@@ -652,7 +652,7 @@ mod tests {
for (i, &ch) in b"SP2SJG".iter().enumerate() { for (i, &ch) in b"SP2SJG".iter().enumerate() {
addr[i] = ch << 1; addr[i] = ch << 1;
} }
addr[6] = (5 << 1) | 0; // SSID=5, last=false addr[6] = 5 << 1; // SSID=5, last=false
let decoded = decode_ax25_address(&addr, 0); let decoded = decode_ax25_address(&addr, 0);
assert_eq!(decoded.call, "SP2SJG"); assert_eq!(decoded.call, "SP2SJG");
@@ -667,7 +667,7 @@ mod tests {
for (i, &ch) in b"W1AW ".iter().enumerate() { for (i, &ch) in b"W1AW ".iter().enumerate() {
addr[i] = ch << 1; addr[i] = ch << 1;
} }
addr[6] = (0 << 1) | 1; addr[6] = 1;
let decoded = decode_ax25_address(&addr, 0); let decoded = decode_ax25_address(&addr, 0);
assert_eq!(decoded.call, "W1AW"); assert_eq!(decoded.call, "W1AW");
@@ -691,7 +691,7 @@ mod tests {
for &ch in src_bytes.as_bytes().iter().take(6) { for &ch in src_bytes.as_bytes().iter().take(6) {
frame.push(ch << 1); frame.push(ch << 1);
} }
frame.push((0 << 1) | 1); // SSID=0, last=true frame.push(1); // SSID=0, last=true
// Control + PID // Control + PID
frame.push(0x03); // UI frame frame.push(0x03); // UI frame
frame.push(0xF0); // No layer-3 protocol frame.push(0xF0); // No layer-3 protocol
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-cw" name = "trx-cw"
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Goertzel-based CW (Morse code) decoder. //! Goertzel-based CW (Morse code) decoder.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-decode-log" name = "trx-decode-log"
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Server-side decoder file logging (APRS / CW / FT8 / WSPR). //! Server-side decoder file logging (APRS / CW / FT8 / WSPR).
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-ftx" name = "trx-ftx"
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Open-addressing hash table for callsign lookup during FTx decoding. //! Open-addressing hash table for callsign lookup during FTx decoding.
//! //!
@@ -160,8 +160,7 @@ impl CallsignHashTable {
let mut idx = start_idx; let mut idx = start_idx;
loop { loop {
match &self.entries[idx] { let entry = self.entries[idx].as_ref()?;
Some(entry) => {
let stored = (entry.hash & HASH22_MASK) >> shift; let stored = (entry.hash & HASH22_MASK) >> shift;
if stored == target { if stored == target {
return Some(entry.callsign.clone()); return Some(entry.callsign.clone());
@@ -171,9 +170,6 @@ impl CallsignHashTable {
return None; return None;
} }
} }
None => return None,
}
}
} }
/// Age all entries and remove those older than `max_age`. /// Age all entries and remove those older than `max_age`.
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
use super::protocol::{FTX_LDPC_K_BYTES, FTX_LDPC_M, FTX_LDPC_N}; use super::protocol::{FTX_LDPC_K_BYTES, FTX_LDPC_M, FTX_LDPC_N};
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
use super::protocol::{FT8_CRC_POLYNOMIAL, FT8_CRC_WIDTH}; use super::protocol::{FT8_CRC_POLYNOMIAL, FT8_CRC_WIDTH};
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Candidate search, shared decode helpers, and dispatcher functions for FTx decoding. //! Candidate search, shared decode helpers, and dispatcher functions for FTx decoding.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Shared LDPC encoding functions used by all FTx protocols. //! Shared LDPC encoding functions used by all FTx protocols.
+13 -13
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Pure Rust LDPC decoder for FTx protocols. //! Pure Rust LDPC decoder for FTx protocols.
//! //!
@@ -42,8 +42,8 @@ pub(crate) fn ldpc_check(codeword: &[u8; FTX_LDPC_N]) -> i32 {
for m in 0..FTX_LDPC_M { for m in 0..FTX_LDPC_M {
let mut x: u8 = 0; let mut x: u8 = 0;
let num_rows = FTX_LDPC_NUM_ROWS[m] as usize; let num_rows = FTX_LDPC_NUM_ROWS[m] as usize;
for i in 0..num_rows { for &nm in FTX_LDPC_NM[m].iter().take(num_rows) {
x ^= codeword[FTX_LDPC_NM[m][i] as usize - 1]; x ^= codeword[nm as usize - 1];
} }
if x != 0 { if x != 0 {
errors += 1; errors += 1;
@@ -81,11 +81,11 @@ pub fn ldpc_decode(
for j in 0..FTX_LDPC_M { for j in 0..FTX_LDPC_M {
let num_rows = FTX_LDPC_NUM_ROWS[j] as usize; let num_rows = FTX_LDPC_NUM_ROWS[j] as usize;
let m_row = j * FTX_LDPC_N; let m_row = j * FTX_LDPC_N;
for ii1 in 0..num_rows { for &nm1 in FTX_LDPC_NM[j].iter().take(num_rows) {
let i1 = FTX_LDPC_NM[j][ii1] as usize - 1; let i1 = nm1 as usize - 1;
let mut a = 1.0f32; let mut a = 1.0f32;
for ii2 in 0..num_rows { for &nm2 in FTX_LDPC_NM[j].iter().take(num_rows) {
let i2 = FTX_LDPC_NM[j][ii2] as usize - 1; let i2 = nm2 as usize - 1;
if i2 != i1 { if i2 != i1 {
a *= fast_tanh(-m_matrix[m_row + i2] / 2.0f32); a *= fast_tanh(-m_matrix[m_row + i2] / 2.0f32);
} }
@@ -97,8 +97,8 @@ pub fn ldpc_decode(
// Hard decisions // Hard decisions
for i in 0..FTX_LDPC_N { for i in 0..FTX_LDPC_N {
let mut l = codeword[i]; let mut l = codeword[i];
for j in 0..3 { for &mn in FTX_LDPC_MN[i].iter().take(3) {
l += e_matrix[(FTX_LDPC_MN[i][j] as usize - 1) * FTX_LDPC_N + i]; l += e_matrix[(mn as usize - 1) * FTX_LDPC_N + i];
} }
plain[i] = if l > 0.0 { 1 } else { 0 }; plain[i] = if l > 0.0 { 1 } else { 0 };
} }
@@ -113,12 +113,12 @@ pub fn ldpc_decode(
// Update m[][] from e[][] // Update m[][] from e[][]
for i in 0..FTX_LDPC_N { for i in 0..FTX_LDPC_N {
for ji1 in 0..3 { for (ji1, &mn1) in FTX_LDPC_MN[i].iter().enumerate().take(3) {
let j1 = FTX_LDPC_MN[i][ji1] as usize - 1; let j1 = mn1 as usize - 1;
let mut l = codeword[i]; let mut l = codeword[i];
for ji2 in 0..3 { for (ji2, &mn2) in FTX_LDPC_MN[i].iter().enumerate().take(3) {
if ji1 != ji2 { if ji1 != ji2 {
let j2 = FTX_LDPC_MN[i][ji2] as usize - 1; let j2 = mn2 as usize - 1;
l += e_matrix[j2 * FTX_LDPC_N + i]; l += e_matrix[j2 * FTX_LDPC_N + i];
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! FTx message pack/unpack logic. //! FTx message pack/unpack logic.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Common types, constants, and shared functions used across all FTx protocols. //! Common types, constants, and shared functions used across all FTx protocols.
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Windowed FFT waterfall/spectrogram engine for FTx decoding. //! Windowed FFT waterfall/spectrogram engine for FTx decoding.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! OSD-1/OSD-2 CRC-guided bit-flip decoder for the (174,91) LDPC code. //! OSD-1/OSD-2 CRC-guided bit-flip decoder for the (174,91) LDPC code.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
/// FTx protocol variants. /// FTx protocol variants.
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
+3 -7
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Character table lookup and string utility functions for FTx message //! Character table lookup and string utility functions for FTx message
//! encoding/decoding. //! encoding/decoding.
@@ -64,11 +64,9 @@ pub fn charn(mut c: i32, table: CharTable) -> char {
return EXTRAS[c as usize]; return EXTRAS[c as usize];
} }
} }
CharTable::AlphanumSpaceSlash => { CharTable::AlphanumSpaceSlash if c == 0 => {
if c == 0 {
return '/'; return '/';
} }
}
_ => {} _ => {}
} }
@@ -116,11 +114,9 @@ pub fn nchar(c: char, table: CharTable) -> Option<i32> {
'?' => return Some(n + 4), '?' => return Some(n + 4),
_ => {} _ => {}
}, },
CharTable::AlphanumSpaceSlash => { CharTable::AlphanumSpaceSlash if c == '/' => {
if c == '/' {
return Some(n); return Some(n);
} }
}
_ => {} _ => {}
} }
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Top-level FTx decoder matching the `trx-ft8` public API. //! Top-level FTx decoder matching the `trx-ft8` public API.
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Per-symbol FFT and multi-scale bit metrics extraction. //! Per-symbol FFT and multi-scale bit metrics extraction.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! FT2-specific waterfall sync scoring and likelihood extraction. //! FT2-specific waterfall sync scoring and likelihood extraction.
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Frequency-domain downsampling via IFFT. //! Frequency-domain downsampling via IFFT.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! FT2 pipeline orchestration. //! FT2 pipeline orchestration.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! 2D sync scoring with complex Costas reference waveforms. //! 2D sync scoring with complex Costas reference waveforms.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! FT4-specific sync scoring, likelihood extraction, and tone encoding. //! FT4-specific sync scoring, likelihood extraction, and tone encoding.
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! FT8-specific sync scoring, likelihood extraction, and tone encoding. //! FT8-specific sync scoring, likelihood extraction, and tone encoding.
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
pub mod common; pub mod common;
mod decoder; mod decoder;
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-rds" name = "trx-rds"
+13 -28
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
use std::f32::consts::{PI, SQRT_2, TAU}; use std::f32::consts::{PI, SQRT_2, TAU};
use std::sync::Arc; use std::sync::Arc;
@@ -632,33 +632,18 @@ impl Candidate {
} }
let segment = usize::from((block_b & 0x0003) as u8); let segment = usize::from((block_b & 0x0003) as u8);
let di = ((block_b >> 2) & 0x1) != 0; let di = ((block_b >> 2) & 0x1) != 0;
match segment { let di_flag = Some(di);
0 => { let slot = match segment {
if self.state.dynamic_pty != Some(di) { 0 => &mut self.state.dynamic_pty,
self.state.dynamic_pty = Some(di); 1 => &mut self.state.compressed,
2 => &mut self.state.artificial_head,
3 => &mut self.state.stereo,
_ => unreachable!("segment is masked to two bits"),
};
if *slot != di_flag {
*slot = di_flag;
changed = true; changed = true;
} }
}
1 => {
if self.state.compressed != Some(di) {
self.state.compressed = Some(di);
changed = true;
}
}
2 => {
if self.state.artificial_head != Some(di) {
self.state.artificial_head = Some(di);
changed = true;
}
}
3 => {
if self.state.stereo != Some(di) {
self.state.stereo = Some(di);
changed = true;
}
}
_ => {}
}
let [b0, b1] = block_d.to_be_bytes(); let [b0, b1] = block_d.to_be_bytes();
self.ps_bytes[segment * 2] = sanitize_text_byte(b0); self.ps_bytes[segment * 2] = sanitize_text_byte(b0);
self.ps_bytes[segment * 2 + 1] = sanitize_text_byte(b1); self.ps_bytes[segment * 2 + 1] = sanitize_text_byte(b1);
@@ -1458,9 +1443,9 @@ mod tests {
} }
// BPSK modulate onto the 57 kHz subcarrier. // BPSK modulate onto the 57 kHz subcarrier.
for t in 0..n { for (t, sample) in shaped.iter_mut().enumerate().take(n) {
let phase = TAU * RDS_SUBCARRIER_HZ * t as f32 / sample_rate; let phase = TAU * RDS_SUBCARRIER_HZ * t as f32 / sample_rate;
shaped[t] *= phase.cos(); *sample *= phase.cos();
} }
shaped shaped
} }
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-vdes" name = "trx-vdes"
+2 -4
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! CRC-16 for VDES link-layer frames. //! CRC-16 for VDES link-layer frames.
//! //!
@@ -134,9 +134,7 @@ mod tests {
.flat_map(|&b| (0..8).rev().map(move |i| (b >> i) & 1)) .flat_map(|&b| (0..8).rev().map(move |i| (b >> i) & 1))
.collect(); .collect();
// Append wrong CRC // Append wrong CRC
for _ in 0..16 { bits.resize(bits.len() + 16, 0);
bits.push(0);
}
assert!(!check_crc16(&bits)); assert!(!check_crc16(&bits));
} }
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! VDES 100 kHz decoder for VDE-TER (ITU-R M.2092-1). //! VDES 100 kHz decoder for VDE-TER (ITU-R M.2092-1).
//! //!
+3 -3
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! VDES link-layer frame parsing per ITU-R M.2092-1. //! VDES link-layer frame parsing per ITU-R M.2092-1.
//! //!
@@ -346,8 +346,8 @@ mod tests {
write_bits(&mut bits, 12, 32, 123456); // source_id write_bits(&mut bits, 12, 32, 123456); // source_id
write_bits(&mut bits, 44, 11, 20); // data_count = 20 write_bits(&mut bits, 44, 11, 20); // data_count = 20
// Fill some payload // Fill some payload
for i in 55..75 { for (i, bit) in bits.iter_mut().enumerate().take(75).skip(55) {
bits[i] = (i % 2) as u8; *bit = (i % 2) as u8;
} }
append_crc(&mut bits); append_crc(&mut bits);
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Turbo FEC decoder for VDES TER-MCS-1 (100 kHz channel). //! Turbo FEC decoder for VDES TER-MCS-1 (100 kHz channel).
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-wefax" name = "trx-wefax"
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! WEFAX decoder configuration. //! WEFAX decoder configuration.
+13 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Top-level WEFAX decoder state machine. //! Top-level WEFAX decoder state machine.
//! //!
@@ -489,12 +489,23 @@ impl WefaxDecoder {
let ppl = WefaxConfig::pixels_per_line(ioc); let ppl = WefaxConfig::pixels_per_line(ioc);
let mut path_str = None; let mut path_str = None;
let mut png_data = None;
// Save PNG if output directory is configured. // Save PNG if output directory is configured.
if let Some(ref dir) = self.config.output_dir { if let Some(ref dir) = self.config.output_dir {
let output_path = PathBuf::from(dir); let output_path = PathBuf::from(dir);
match image.save_png(&output_path, self.freq_hz, &self.mode) { match image.save_png(&output_path, self.freq_hz, &self.mode) {
Ok(p) => { Ok(p) => {
// Read back the PNG bytes for remote client transfer.
match std::fs::read(&p) {
Ok(bytes) => {
png_data =
Some(base64::engine::general_purpose::STANDARD.encode(&bytes));
}
Err(e) => {
eprintln!("WEFAX: failed to read PNG for transfer: {}", e);
}
}
path_str = Some(p.to_string_lossy().into_owned()); path_str = Some(p.to_string_lossy().into_owned());
} }
Err(e) => { Err(e) => {
@@ -512,6 +523,7 @@ impl WefaxDecoder {
ioc, ioc,
pixels_per_line: ppl, pixels_per_line: ppl,
path: path_str, path: path_str,
png_data,
complete: true, complete: true,
})); }));
} }
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! FM discriminator for WEFAX demodulation. //! FM discriminator for WEFAX demodulation.
//! //!
+5 -4
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Image buffer and PNG encoding for WEFAX decoded images. //! Image buffer and PNG encoding for WEFAX decoded images.
@@ -274,7 +274,8 @@ mod tests {
// Pseudo-random noise vs gradient — correlation should be low. // Pseudo-random noise vs gradient — correlation should be low.
let noise: Vec<u8> = (0..256) let noise: Vec<u8> = (0..256)
.map(|i| ((i * 1103515245 + 12345) as u32 >> 8 & 0xff) as u8) .map(|i| (i as u32).wrapping_mul(1_103_515_245).wrapping_add(12_345))
.map(|value| ((value >> 8) & 0xff) as u8)
.collect(); .collect();
let r = asm.correlation_with_last(&noise).expect("r"); let r = asm.correlation_with_last(&noise).expect("r");
assert!( assert!(
@@ -374,8 +375,8 @@ mod tests {
let (y, m, d, h, mi, _) = unix_to_utc(1775055000); let (y, m, d, h, mi, _) = unix_to_utc(1775055000);
assert_eq!(y, 2026); assert_eq!(y, 2026);
// Just verify reasonable values without asserting exact date. // Just verify reasonable values without asserting exact date.
assert!(m >= 1 && m <= 12); assert!((1..=12).contains(&m));
assert!(d >= 1 && d <= 31); assert!((1..=31).contains(&d));
assert!(h < 24); assert!(h < 24);
assert!(mi < 60); assert!(mi < 60);
} }
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! WEFAX (Weather Facsimile) decoder. //! WEFAX (Weather Facsimile) decoder.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Line slicer: pixel clock recovery and line buffer assembly. //! Line slicer: pixel clock recovery and line buffer assembly.
//! //!
+3 -5
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Phasing signal detector and line-start alignment for WEFAX. //! Phasing signal detector and line-start alignment for WEFAX.
//! //!
@@ -161,10 +161,8 @@ mod tests {
for line_idx in 0..20 { for line_idx in 0..20 {
let mut line = vec![1.0f32; spl]; let mut line = vec![1.0f32; spl];
for j in pulse_start..pulse_start + pw { for slot in line.iter_mut().skip(pulse_start).take(pw) {
if j < spl { *slot = 0.0;
line[j] = 0.0;
}
} }
let result = det.process(&line); let result = det.process(&line);
if let Some(offset) = result { if let Some(offset) = result {
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Polyphase rational resampler: 48000 Hz → 11025 Hz. //! Polyphase rational resampler: 48000 Hz → 11025 Hz.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! APT tone detector for WEFAX start/stop signals. //! APT tone detector for WEFAX start/stop signals.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-wspr" name = "trx-wspr"
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
use crate::protocol; use crate::protocol;
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
mod decoder; mod decoder;
mod protocol; mod protocol;
+4 -4
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
/// Decoded WSPR message payload. /// Decoded WSPR message payload.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@@ -483,7 +483,7 @@ mod tests {
let c4 = idx27(b'T'); let c4 = idx27(b'T');
let c5 = idx27(b' '); let c5 = idx27(b' ');
let n1 = ((c0 * 36 + c1) * 10 + c2) * 27u32.pow(3) + c3 * 27u32.pow(2) + c4 * 27 + c5; let n1 = ((c0 * 36 + c1) * 10 + c2) * 27u32.pow(3) + c3 * 27u32.pow(2) + c4 * 27 + c5;
let m1 = (179 - 10 * 5 - 2) * 180 + 10 * 13 + 0; // FN20 let m1 = (179 - 10 * 5 - 2) * 180 + 10 * 13; // FN20 (final term is 0)
let power_code = 37u32; let power_code = 37u32;
let mut input_bits = [0u8; NBITS]; let mut input_bits = [0u8; NBITS];
@@ -530,8 +530,8 @@ mod tests {
fn interleave_deinterleave_roundtrip() { fn interleave_deinterleave_roundtrip() {
// Create a sequence of distinguishable values // Create a sequence of distinguishable values
let mut original = [0u8; NSYMS]; let mut original = [0u8; NSYMS];
for i in 0..NSYMS { for (i, slot) in original.iter_mut().enumerate() {
original[i] = (i % 256) as u8; *slot = (i % 256) as u8;
} }
let interleaved = interleave(&original); let interleaved = interleave(&original);
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-wxsat" name = "trx-wxsat"
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Shared PNG image encoding for weather satellite decoders. //! Shared PNG image encoding for weather satellite decoders.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Weather satellite image decoders. //! Weather satellite image decoders.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! CCSDS CADU (Channel Access Data Unit) frame synchronisation and extraction. //! CCSDS CADU (Channel Access Data Unit) frame synchronisation and extraction.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! QPSK demodulator for Meteor-M LRPT. //! QPSK demodulator for Meteor-M LRPT.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! MCU (Minimum Coded Unit) assembly and multi-channel image composition. //! MCU (Minimum Coded Unit) assembly and multi-channel image composition.
//! //!
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Meteor-M LRPT (Low Rate Picture Transmission) satellite image decoder. //! Meteor-M LRPT (Low Rate Picture Transmission) satellite image decoder.
//! //!
+2 -2
View File
@@ -1,12 +1,12 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-app" name = "trx-app"
version.workspace = true version.workspace = true
edition = "2021" edition = "2021"
license = "BSD-2-Clause" license = "GPL-2.0-or-later"
[dependencies] [dependencies]
serde = { workspace = true } serde = { workspace = true }
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
use serde::de::DeserializeOwned; use serde::de::DeserializeOwned;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
pub mod config; pub mod config;
pub mod logging; pub mod logging;
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
use tracing::Level; use tracing::Level;
use tracing_subscriber::FmtSubscriber; use tracing_subscriber::FmtSubscriber;
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Shared configuration validation helpers used by both `trx-server` and //! Shared configuration validation helpers used by both `trx-server` and
//! `trx-client`. //! `trx-client`.
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
/// Normalize a name to lowercase alphanumeric. /// Normalize a name to lowercase alphanumeric.
pub fn normalize_name(name: &str) -> String { pub fn normalize_name(name: &str) -> String {
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-client" name = "trx-client"
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Local audio bridge for trx-client. //! Local audio bridge for trx-client.
//! //!
+74 -57
View File
@@ -1,13 +1,13 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Audio TCP client that connects to the server's audio port and relays //! Audio TCP client that connects to the server's audio port and relays
//! RX/TX Opus frames via broadcast/mpsc channels. //! RX/TX Opus frames via broadcast/mpsc channels.
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use std::sync::{Arc, Mutex, RwLock}; use std::sync::{Arc, Mutex, RwLock};
use std::time::Duration; use std::time::{Duration, Instant};
use bytes::Bytes; use bytes::Bytes;
use flate2::read::GzDecoder; use flate2::read::GzDecoder;
@@ -36,6 +36,13 @@ use trx_core::audio::{
use trx_core::decode::DecodedMessage; use trx_core::decode::DecodedMessage;
use trx_frontend::VChanAudioCmd; use trx_frontend::VChanAudioCmd;
/// Minimum uptime before a connection is "stable" enough to reset the
/// reconnect backoff. Connections that die before this threshold leave the
/// exponential backoff climbing — protects the server from a tight reconnect
/// storm when the peer is broken in some way that only manifests after the
/// TCP handshake.
const STABLE_CONNECTION_THRESHOLD: Duration = Duration::from_secs(30);
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
struct ActiveVChanSub { struct ActiveVChanSub {
freq_hz: u64, freq_hz: u64,
@@ -289,7 +296,7 @@ async fn run_single_rig_audio_client(
info!("Audio client [{}]: connecting to {}", rig_id, server_addr); info!("Audio client [{}]: connecting to {}", rig_id, server_addr);
match TcpStream::connect(&server_addr).await { match TcpStream::connect(&server_addr).await {
Ok(stream) => { Ok(stream) => {
reconnect_delay = Duration::from_secs(1); let connected_at = Instant::now();
if let Err(e) = handle_single_rig_connection( if let Err(e) = handle_single_rig_connection(
stream, stream,
&rig_id, &rig_id,
@@ -311,6 +318,13 @@ async fn run_single_rig_audio_client(
{ {
warn!("Audio connection [{}] dropped: {}", rig_id, e); warn!("Audio connection [{}] dropped: {}", rig_id, e);
} }
// Only reset the backoff after a connection survived long
// enough to be considered stable. TCP `connect()` succeeding
// is not enough — a peer that fails immediately after
// accepting must not be hammered every second.
if connected_at.elapsed() >= STABLE_CONNECTION_THRESHOLD {
reconnect_delay = Duration::from_secs(1);
}
} }
Err(e) => { Err(e) => {
warn!("Audio connect [{}] failed: {}", rig_id, e); warn!("Audio connect [{}] failed: {}", rig_id, e);
@@ -342,59 +356,6 @@ async fn run_single_rig_audio_client(
} }
} }
#[cfg(test)]
mod tests {
use super::{resolve_audio_addr, AudioConnectConfig};
use std::collections::HashMap;
#[test]
fn resolve_audio_addr_prefers_fixed_url() {
let mut rig_connect = HashMap::new();
rig_connect.insert(
"home-hf".to_string(),
AudioConnectConfig::fixed("audio.example.com:4700".to_string()),
);
let addr = resolve_audio_addr(
"home-hf",
Some(4531),
&rig_connect,
&AudioConnectConfig::from_host_port("control.example.com".to_string(), 4531),
);
assert_eq!(addr, "audio.example.com:4700");
}
#[test]
fn resolve_audio_addr_uses_advertised_port_with_remote_host() {
let mut rig_connect = HashMap::new();
rig_connect.insert(
"home-hf".to_string(),
AudioConnectConfig::from_host_port("control.example.com".to_string(), 4531),
);
let addr = resolve_audio_addr(
"home-hf",
Some(4600),
&rig_connect,
&AudioConnectConfig::from_host_port("fallback.example.com".to_string(), 4531),
);
assert_eq!(addr, "control.example.com:4600");
}
#[test]
fn resolve_audio_addr_falls_back_to_default_port() {
let rig_connect = HashMap::new();
let addr = resolve_audio_addr(
"home-hf",
None,
&rig_connect,
&AudioConnectConfig::from_host_port("fallback.example.com".to_string(), 4531),
);
assert_eq!(addr, "fallback.example.com:4531");
}
}
/// Handle a single TCP connection for one rig. Similar to `handle_audio_connection` /// Handle a single TCP connection for one rig. Similar to `handle_audio_connection`
/// but publishes to per-rig channels directly and mirrors to global when selected. /// but publishes to per-rig channels directly and mirrors to global when selected.
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
@@ -586,7 +547,10 @@ async fn handle_single_rig_connection(
rig_id_for_rx, msg_type rig_id_for_rx, msg_type
); );
} }
Err(_) => break, Err(e) => {
warn!("Audio client [{}]: read error: {}", rig_id_for_rx, e);
break;
}
} }
} }
}); });
@@ -750,3 +714,56 @@ async fn handle_single_rig_connection(
Ok(()) Ok(())
} }
#[cfg(test)]
mod tests {
use super::{resolve_audio_addr, AudioConnectConfig};
use std::collections::HashMap;
#[test]
fn resolve_audio_addr_prefers_fixed_url() {
let mut rig_connect = HashMap::new();
rig_connect.insert(
"home-hf".to_string(),
AudioConnectConfig::fixed("audio.example.com:4700".to_string()),
);
let addr = resolve_audio_addr(
"home-hf",
Some(4531),
&rig_connect,
&AudioConnectConfig::from_host_port("control.example.com".to_string(), 4531),
);
assert_eq!(addr, "audio.example.com:4700");
}
#[test]
fn resolve_audio_addr_uses_advertised_port_with_remote_host() {
let mut rig_connect = HashMap::new();
rig_connect.insert(
"home-hf".to_string(),
AudioConnectConfig::from_host_port("control.example.com".to_string(), 4531),
);
let addr = resolve_audio_addr(
"home-hf",
Some(4600),
&rig_connect,
&AudioConnectConfig::from_host_port("fallback.example.com".to_string(), 4531),
);
assert_eq!(addr, "control.example.com:4600");
}
#[test]
fn resolve_audio_addr_falls_back_to_default_port() {
let rig_connect = HashMap::new();
let addr = resolve_audio_addr(
"home-hf",
None,
&rig_connect,
&AudioConnectConfig::from_host_port("fallback.example.com".to_string(), 4531),
);
assert_eq!(addr, "fallback.example.com:4531");
}
}
+21 -13
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
//! Configuration file support for trx-client. //! Configuration file support for trx-client.
//! //!
@@ -1110,8 +1110,8 @@ url = "remote.example.com:4530"
#[test] #[test]
fn test_validate_rejects_duplicate_remote_names() { fn test_validate_rejects_duplicate_remote_names() {
let mut config = ClientConfig::default(); let config = ClientConfig {
config.remotes = vec![ remotes: vec![
RemoteEntry { RemoteEntry {
name: "dup".to_string(), name: "dup".to_string(),
url: "a:4530".to_string(), url: "a:4530".to_string(),
@@ -1126,20 +1126,24 @@ url = "remote.example.com:4530"
auth: RemoteAuthConfig::default(), auth: RemoteAuthConfig::default(),
poll_interval_ms: 750, poll_interval_ms: 750,
}, },
]; ],
..Default::default()
};
assert!(config.validate().unwrap_err().contains("duplicate name")); assert!(config.validate().unwrap_err().contains("duplicate name"));
} }
#[test] #[test]
fn test_validate_rejects_empty_remote_name() { fn test_validate_rejects_empty_remote_name() {
let mut config = ClientConfig::default(); let config = ClientConfig {
config.remotes = vec![RemoteEntry { remotes: vec![RemoteEntry {
name: "".to_string(), name: "".to_string(),
url: "a:4530".to_string(), url: "a:4530".to_string(),
rig_id: None, rig_id: None,
auth: RemoteAuthConfig::default(), auth: RemoteAuthConfig::default(),
poll_interval_ms: 750, poll_interval_ms: 750,
}]; }],
..Default::default()
};
assert!(config assert!(config
.validate() .validate()
.unwrap_err() .unwrap_err()
@@ -1148,14 +1152,16 @@ url = "remote.example.com:4530"
#[test] #[test]
fn test_validate_rejects_empty_remote_url() { fn test_validate_rejects_empty_remote_url() {
let mut config = ClientConfig::default(); let config = ClientConfig {
config.remotes = vec![RemoteEntry { remotes: vec![RemoteEntry {
name: "hf".to_string(), name: "hf".to_string(),
url: " ".to_string(), url: " ".to_string(),
rig_id: None, rig_id: None,
auth: RemoteAuthConfig::default(), auth: RemoteAuthConfig::default(),
poll_interval_ms: 750, poll_interval_ms: 750,
}]; }],
..Default::default()
};
assert!(config assert!(config
.validate() .validate()
.unwrap_err() .unwrap_err()
@@ -1164,14 +1170,16 @@ url = "remote.example.com:4530"
#[test] #[test]
fn test_validate_rejects_zero_remote_poll_interval() { fn test_validate_rejects_zero_remote_poll_interval() {
let mut config = ClientConfig::default(); let config = ClientConfig {
config.remotes = vec![RemoteEntry { remotes: vec![RemoteEntry {
name: "hf".to_string(), name: "hf".to_string(),
url: "a:4530".to_string(), url: "a:4530".to_string(),
rig_id: None, rig_id: None,
auth: RemoteAuthConfig::default(), auth: RemoteAuthConfig::default(),
poll_interval_ms: 0, poll_interval_ms: 0,
}]; }],
..Default::default()
};
assert!(config assert!(config
.validate() .validate()
.unwrap_err() .unwrap_err()
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
mod audio_bridge; mod audio_bridge;
mod audio_client; mod audio_client;
+2 -2
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
@@ -1678,7 +1678,7 @@ mod tests {
#[test] #[test]
fn global_target_for_snapshot_skips_other_server_selection() { fn global_target_for_snapshot_skips_other_server_selection() {
let snapshot = sample_snapshot(); let snapshot = sample_snapshot();
let rigs = vec![RigEntry { let rigs = [RigEntry {
rig_id: "hf".to_string(), rig_id: "hf".to_string(),
display_name: Some("Gdansk HF".to_string()), display_name: Some("Gdansk HF".to_string()),
state: snapshot, state: snapshot,
+1 -1
View File
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-frontend" name = "trx-frontend"
+1 -1
View File
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
use std::collections::{HashMap, HashSet, VecDeque}; use std::collections::{HashMap, HashSet, VecDeque};
use std::net::SocketAddr; use std::net::SocketAddr;
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-frontend-http-json" name = "trx-frontend-http-json"
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
pub mod server; pub mod server;
@@ -1,6 +1,6 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> // SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
// //
// SPDX-License-Identifier: BSD-2-Clause // SPDX-License-Identifier: GPL-2.0-or-later
use std::net::SocketAddr; use std::net::SocketAddr;
use std::sync::Arc; use std::sync::Arc;
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space> # SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
# #
# SPDX-License-Identifier: BSD-2-Clause # SPDX-License-Identifier: GPL-2.0-or-later
[package] [package]
name = "trx-frontend-http" name = "trx-frontend-http"
@@ -16,6 +16,7 @@ tokio = { workspace = true, features = ["full"] }
serde = { workspace = true, features = ["derive"] } serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true } serde_json = { workspace = true }
tracing = { workspace = true } tracing = { workspace = true }
base64 = "0.22"
actix-web = "4.4" actix-web = "4.4"
actix-ws = "0.3" actix-ws = "0.3"
tokio-stream = { version = "0.1", features = ["sync"] } tokio-stream = { version = "0.1", features = ["sync"] }
@@ -1,3 +1,7 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// --- Decoder registry (fetched from /decoders on load) --- // --- Decoder registry (fetched from /decoders on load) ---
/** @type {Array<{id:string,label:string,activation:string,active_modes:string[],background_decode:boolean,bookmark_selectable:boolean}>} */ /** @type {Array<{id:string,label:string,activation:string,active_modes:string[],background_decode:boolean,bookmark_selectable:boolean}>} */
let decoderRegistry = []; let decoderRegistry = [];
@@ -641,7 +645,7 @@ function flushDeferredDecodeMapSync() {
if (!decodeMapSyncPending || decodeHistoryReplayActive || !window.trx?.map?.aprsMap) return; if (!decodeMapSyncPending || decodeHistoryReplayActive || !window.trx?.map?.aprsMap) return;
decodeMapSyncPending = false; decodeMapSyncPending = false;
scheduleUiFrameJob("decode-map-maintenance", () => { scheduleUiFrameJob("decode-map-maintenance", () => {
window.trx.map?.pruneMapHistory(); window.trx.modules.map?.pruneMapHistory();
}); });
} }
@@ -1275,7 +1279,7 @@ function applyRigList(activeRigId, rigIds, displayNames) {
if (typeof bmPopulateScopePicker === "function") bmPopulateScopePicker(); if (typeof bmPopulateScopePicker === "function") bmPopulateScopePicker();
if (typeof bmFetch === "function") bmFetch(document.getElementById("bm-category-filter")?.value || ""); if (typeof bmFetch === "function") bmFetch(document.getElementById("bm-category-filter")?.value || "");
} }
window.trx.map?.updateMapRigFilter(); window.trx.modules.map?.updateMapRigFilter();
} }
@@ -1301,7 +1305,7 @@ async function refreshRigList() {
serverRigs = rigs; serverRigs = rigs;
serverActiveRigId = data.active_remote || null; serverActiveRigId = data.active_remote || null;
applyRigList(data.active_remote, rigIds, displayNames); applyRigList(data.active_remote, rigIds, displayNames);
window.trx.map?.syncAprsReceiverMarker(); window.trx.modules.map?.syncAprsReceiverMarker();
} catch (e) { } catch (e) {
// Non-fatal: SSE/status path still drives main UI. // Non-fatal: SSE/status path still drives main UI.
} }
@@ -3139,9 +3143,9 @@ function render(update) {
const grid = latLonToMaidenhead(serverLat, serverLon); const grid = latLonToMaidenhead(serverLat, serverLon);
locationSubtitle.textContent = `Location: ${grid}`; locationSubtitle.textContent = `Location: ${grid}`;
locationSubtitle.style.display = ""; locationSubtitle.style.display = "";
window.trx.map?.reverseGeocodeLocation(serverLat, serverLon, grid); window.trx.modules.map?.reverseGeocodeLocation(serverLat, serverLon, grid);
} }
window.trx.map?.syncAprsReceiverMarker(); window.trx.modules.map?.syncAprsReceiverMarker();
if (typeof update.initial_map_zoom === "number" && Number.isFinite(update.initial_map_zoom)) { if (typeof update.initial_map_zoom === "number" && Number.isFinite(update.initial_map_zoom)) {
initialMapZoom = Math.max(1, Math.round(update.initial_map_zoom)); initialMapZoom = Math.max(1, Math.round(update.initial_map_zoom));
} }
@@ -3890,7 +3894,7 @@ async function switchRigFromSelect(selectEl) {
if (typeof setSchedulerRig === "function") setSchedulerRig(lastActiveRigId); if (typeof setSchedulerRig === "function") setSchedulerRig(lastActiveRigId);
if (typeof setBackgroundDecodeRig === "function") setBackgroundDecodeRig(lastActiveRigId); if (typeof setBackgroundDecodeRig === "function") setBackgroundDecodeRig(lastActiveRigId);
if (typeof bmFetch === "function") bmFetch(document.getElementById("bm-category-filter")?.value || ""); if (typeof bmFetch === "function") bmFetch(document.getElementById("bm-category-filter")?.value || "");
window.trx.map?.syncAprsReceiverMarker(); window.trx.modules.map?.syncAprsReceiverMarker();
// Switch this session's rig and reconnect SSE to the new rig's // Switch this session's rig and reconnect SSE to the new rig's
// state channel. // state channel.
try { try {
@@ -4264,7 +4268,7 @@ const MODE_BW_DEFAULTS = {
FM: [12_500, 2_500, 25_000, 500], FM: [12_500, 2_500, 25_000, 500],
AIS: [25_000, 12_500, 50_000, 500], AIS: [25_000, 12_500, 50_000, 500],
VDES: [100_000, 25_000, 200_000, 1_000], VDES: [100_000, 25_000, 200_000, 1_000],
WFM: [180_000, 50_000,300_000,5_000], WFM: [180_000, 60_000,300_000,5_000],
DIG: [3_000, 300, 6_000, 100], DIG: [3_000, 300, 6_000, 100],
PKT: [25_000, 300, 50_000, 500], PKT: [25_000, 300, 50_000, 500],
}; };
@@ -4344,64 +4348,93 @@ async function applyBandwidthFromInput() {
} catch (_) {} } catch (_) {}
} }
function estimateBandwidthAroundPeak(data, centerHz) { function estimateOccupiedBandwidth(data, centerHz) {
if (!data || !isBinsArray(data.bins) || data.bins.length < 3 || !Number.isFinite(centerHz)) { if (!data || !isBinsArray(data.bins) || data.bins.length < 3 || !Number.isFinite(centerHz)) {
return null; return null;
} }
const bins = data.bins; const bins = data.bins;
const maxIdx = bins.length - 1; const maxIdx = bins.length - 1;
const hzPerBin = data.sample_rate / maxIdx;
const fullLoHz = data.center_hz - data.sample_rate / 2; const fullLoHz = data.center_hz - data.sample_rate / 2;
const centerIdx = Math.max( const centerIdx = Math.max(
1, 1,
Math.min(maxIdx - 1, Math.round(((centerHz - fullLoHz) / data.sample_rate) * maxIdx)), Math.min(maxIdx - 1, Math.round(((centerHz - fullLoHz) / data.sample_rate) * maxIdx)),
); );
const searchRadius = Math.max(6, Math.min(120, Math.round(maxIdx * 0.03))); const mode = (modeEl ? modeEl.value : "USB").toUpperCase();
const searchLo = Math.max(1, centerIdx - searchRadius); const [defaultBw, minBw, maxBw, stepBw] = mwDefaultsForMode(mode);
const searchHi = Math.min(maxIdx - 1, centerIdx + searchRadius); const oneSided = mode === "USB" || mode === "DIG" || mode === "CW"
? 1
: mode === "LSB" || mode === "CWR" ? -1 : 0;
const isWfm = mode === "WFM";
let peakIdx = centerIdx; // Reduce single-bin peaks and holes before finding occupied-channel edges.
for (let i = searchLo; i <= searchHi; i++) { // WFM needs a wider smoothing window because its energy is noise-like and
if (bins[i] > bins[peakIdx]) peakIdx = i; // spread across the entire channel rather than concentrated at a carrier.
const smoothRadius = isWfm ? 3 : 1;
const smoothed = bins.map((_, i) => {
let sum = 0;
let count = 0;
for (let j = Math.max(0, i - smoothRadius); j <= Math.min(maxIdx, i + smoothRadius); j++) {
sum += bins[j];
count += 1;
} }
return sum / count;
});
const sorted = [...bins].sort((a, b) => a - b); const sorted = [...bins].sort((a, b) => a - b);
const noise = sorted[Math.floor(sorted.length * 0.2)]; const noise = sorted[Math.floor(sorted.length * 0.2)];
const peak = bins[peakIdx]; const maxSpanBins = Math.max(2, Math.ceil(maxBw / hzPerBin));
const threshold = Math.max(noise + 4, peak - Math.max(8, (peak - noise) * 0.35)); const searchHalfBins = oneSided === 0 ? Math.ceil(maxSpanBins / 2) : maxSpanBins;
const searchLo = Math.max(1, centerIdx - (oneSided > 0 ? 2 : searchHalfBins));
const searchHi = Math.min(maxIdx - 1, centerIdx + (oneSided < 0 ? 2 : searchHalfBins));
let peak = -Infinity;
for (let i = searchLo; i <= searchHi; i++) peak = Math.max(peak, smoothed[i]);
const snr = peak - noise;
if (!Number.isFinite(snr) || snr < (isWfm ? 5 : 4)) return isWfm ? minBw : defaultBw;
let left = peakIdx; // A threshold relative to the noise floor finds occupied bandwidth much
let right = peakIdx; // more reliably than one relative to the peak. The latter fails for WFM,
let belowCount = 0; // whose multiplex spectrum has peaks, notches, and no narrow centre carrier.
for (let i = peakIdx; i > 1; i--) { const threshold = noise + Math.max(3, Math.min(isWfm ? 6 : 10, snr * (isWfm ? 0.18 : 0.28)));
if (bins[i] < threshold) belowCount += 1; const allowedGap = Math.max(isWfm ? 4 : 2, Math.ceil((isWfm ? 12_000 : stepBw) / hzPerBin));
else belowCount = 0;
if (belowCount >= 2) break; function occupiedExtent(direction, limitBins) {
left = i; let lastOccupied = centerIdx;
let gap = 0;
for (let n = 0; n <= limitBins; n++) {
const i = centerIdx + direction * n;
if (i <= 0 || i >= maxIdx) break;
if (smoothed[i] >= threshold) {
lastOccupied = i;
gap = 0;
} else if (++gap > allowedGap) {
break;
}
}
return Math.abs(lastOccupied - centerIdx) * hzPerBin;
} }
belowCount = 0; let rawBw;
for (let i = peakIdx; i < maxIdx - 1; i++) { if (oneSided !== 0) {
if (bins[i] < threshold) belowCount += 1; rawBw = occupiedExtent(oneSided, maxSpanBins);
else belowCount = 0; } else {
if (belowCount >= 2) break; const leftHz = occupiedExtent(-1, searchHalfBins);
right = i; const rightHz = occupiedExtent(1, searchHalfBins);
// A symmetric RF filter must contain the larger of the two sidebands.
rawBw = 2 * Math.max(leftHz, rightHz);
} }
const shoulderPad = Math.max(1, Math.round((right - left) * 0.08)); // Add a transition-band margin. Weak WFM deliberately falls back to the
left = Math.max(0, left - shoulderPad); // 60 kHz mode floor above: a narrower filter trades stereo/RDS content for
right = Math.min(maxIdx, right + shoulderPad); // a useful improvement in intelligibility when the signal is very poor.
rawBw *= isWfm ? 1.08 : 1.12;
const hzPerBin = data.sample_rate / maxIdx;
const rawBw = Math.max(hzPerBin, (right - left) * hzPerBin);
const [, minBw, maxBw, stepBw] = mwDefaultsForMode(modeEl ? modeEl.value : "USB");
const clamped = Math.max(minBw, Math.min(maxBw, rawBw)); const clamped = Math.max(minBw, Math.min(maxBw, rawBw));
return Math.max(stepBw, Math.round(clamped / stepBw) * stepBw); return Math.max(stepBw, Math.round(clamped / stepBw) * stepBw);
} }
async function applyAutoBandwidth() { async function applyAutoBandwidth() {
if (!lastSpectrumData || lastFreqHz == null) return; if (!lastSpectrumData || lastFreqHz == null) return;
const estimated = estimateBandwidthAroundPeak(lastSpectrumData, lastFreqHz); const estimated = estimateOccupiedBandwidth(lastSpectrumData, lastFreqHz);
if (!Number.isFinite(estimated) || estimated <= 0) { if (!Number.isFinite(estimated) || estimated <= 0) {
syncBandwidthInput(currentBandwidthHz); syncBandwidthInput(currentBandwidthHz);
return; return;
@@ -4476,16 +4509,25 @@ function updateTabHistory(name, replaceHistory = false) {
} }
// Initialise the Leaflet map, waiting for both Leaflet (L) and map-core.js // Initialise the Leaflet map, waiting for both Leaflet (L) and map-core.js
// (window.trx.map) if they haven't loaded yet. // (window.trx.modules.map) if they haven't loaded yet.
let _mapInitTimer = null; let _mapInitTimer = null;
function _initMapWhenReady() { function _initMapWhenReady() {
const loadingEl = document.getElementById("map-loading"); const loadingEl = document.getElementById("map-loading");
if (window.trx.map && typeof L !== "undefined") { if (window.trx.modules.map && typeof L !== "undefined") {
if (_mapInitTimer) { clearInterval(_mapInitTimer); _mapInitTimer = null; } if (_mapInitTimer) { clearInterval(_mapInitTimer); _mapInitTimer = null; }
if (loadingEl) loadingEl.classList.add("is-hidden"); if (loadingEl) loadingEl.classList.add("is-hidden");
window.trx.map.initAprsMap(); window.trx.modules.map.initAprsMap();
window.trx.map.sizeAprsMapToViewport(); window.trx.modules.map.sizeAprsMapToViewport();
if (window.trx.map.aprsMap) setTimeout(() => window.trx.map.aprsMap.invalidateSize(), 50); // The map panel was just made visible (display:none → ""); the browser
// may not have laid it out yet, so getBoundingClientRect() can return
// stale/zero dimensions. Double-rAF ensures a full layout pass has
// completed before we re-measure and tell Leaflet about its real size.
requestAnimationFrame(() => {
requestAnimationFrame(() => {
window.trx.modules.map.sizeAprsMapToViewport();
if (window.trx.modules.map.aprsMap) window.trx.modules.map.aprsMap.invalidateSize();
});
});
return; return;
} }
// Not ready yet — show overlay and poll until both are available. // Not ready yet — show overlay and poll until both are available.
@@ -4531,7 +4573,7 @@ function navigateToTab(name, options = {}) {
_initMapWhenReady(); _initMapWhenReady();
} }
if (name === "statistics") { if (name === "statistics") {
window.trx.map?.scheduleStatsRender(); window.trx.modules.map?.scheduleStatsRender();
} }
if (name === "recorder") { if (name === "recorder") {
refreshRecorderStatus(); refreshRecorderStatus();
@@ -4708,10 +4750,11 @@ if (headerAuthBtn) {
// ── Shared namespace for lazy-loaded modules ──────────────────────────────── // ── Shared namespace for lazy-loaded modules ────────────────────────────────
// Modules (map-core.js, screenshot.js) access core state and utilities via // Modules (map-core.js, screenshot.js) access core state and utilities via
// window.trx. Modules register their own APIs as sub-namespaces // window.trx. Modules register their own APIs as sub-namespaces
// (e.g. window.trx.map, window.trx.screenshot). // (e.g. window.trx.modules.map, window.trx.modules.screenshot).
window.trx = Object.create(null); const trxState = Object.create(null);
const trxModules = Object.create(null);
// -- State getters (backed by core-scoped variables) -- // -- State getters (backed by core-scoped variables) --
Object.defineProperties(window.trx, { Object.defineProperties(trxState, {
serverLat: { get() { return serverLat; }, set(v) { serverLat = v; } }, serverLat: { get() { return serverLat; }, set(v) { serverLat = v; } },
serverLon: { get() { return serverLon; }, set(v) { serverLon = v; } }, serverLon: { get() { return serverLon; }, set(v) { serverLon = v; } },
lastFreqHz: { get() { return lastFreqHz; } }, lastFreqHz: { get() { return lastFreqHz; } },
@@ -4749,7 +4792,7 @@ Object.defineProperties(window.trx, {
signalOverlayGl: { get() { return signalOverlayGl; } }, signalOverlayGl: { get() { return signalOverlayGl; } },
}); });
// -- Shared utility functions -- // -- Shared utility functions --
Object.assign(window.trx, { const trxCore = Object.freeze({
saveSetting, loadSetting, showHint, escapeMapHtml, formatFreq, formatFreqForHumans, saveSetting, loadSetting, showHint, escapeMapHtml, formatFreq, formatFreqForHumans,
formatWavelength, formatBwLabel, formatUptime, formatSigStrength, formatSignal, formatWavelength, formatBwLabel, formatUptime, formatSigStrength, formatSignal,
postPath, scheduleUiFrameJob, navigateToTab, rigBadgeColor, postPath, scheduleUiFrameJob, navigateToTab, rigBadgeColor,
@@ -4759,18 +4802,19 @@ Object.assign(window.trx, {
currentTheme, canvasPalette, currentStyle, currentTheme, canvasPalette, currentStyle,
cssColorToRgba, rgbaWithAlpha, isBinsArray, estimateNoiseFloorDb, cssColorToRgba, rgbaWithAlpha, isBinsArray, estimateNoiseFloorDb,
spectrumVisibleRange, drawSpectrum, spectrumVisibleRange, drawSpectrum,
bandForHz: function(hz) { return window.trx.map?.bandForHz?.(hz); }, bandForHz: function(hz) { return trxModules.map?.bandForHz?.(hz); },
markDecodeMapSyncPending, markDecodeMapSyncPending,
decodeHistoryMapRenderingDeferred, decodeHistoryMapRenderingDeferred,
updateDocumentTitle, updateDocumentTitle,
activeChannelRds, activeChannelRds,
}); });
Object.defineProperties(window.trx, { Object.defineProperties(trxState, {
decodeHistoryReplayActive: { get() { return decodeHistoryReplayActive; } }, decodeHistoryReplayActive: { get() { return decodeHistoryReplayActive; } },
decodeMapSyncPending: { get() { return decodeMapSyncPending; } }, decodeMapSyncPending: { get() { return decodeMapSyncPending; } },
_activeTab: { get() { return _activeTab; } }, _activeTab: { get() { return _activeTab; } },
locationSubtitle: { get() { return locationSubtitle; } }, locationSubtitle: { get() { return locationSubtitle; } },
}); });
window.trx = Object.freeze({ state: trxState, core: trxCore, modules: trxModules });
// Load plugin scripts now that window.trx is populated. Dynamic scripts are // Load plugin scripts now that window.trx is populated. Dynamic scripts are
// async so they must not be created before the namespace they depend on exists. // async so they must not be created before the namespace they depend on exists.
@@ -4784,7 +4828,7 @@ window.addEventListener("resize", resizeHeaderSignalCanvas);
// ── Map module (extracted to map-core.js, lazy-loaded) ────────────────────── // ── Map module (extracted to map-core.js, lazy-loaded) ──────────────────────
// The map, statistics, and geolocation code (~3,450 lines) has been moved to // The map, statistics, and geolocation code (~3,450 lines) has been moved to
// map-core.js and is loaded on demand when the Map tab is first activated. // map-core.js and is loaded on demand when the Map tab is first activated.
// Core communicates with the map module via window.trx.map.* namespace. // Core communicates with the map module via window.trx.modules.map.* namespace.
// ── Geo utilities (shared with map-core.js via window.trx) ───────────────── // ── Geo utilities (shared with map-core.js via window.trx) ─────────────────
function haversineKm(lat1, lon1, lat2, lon2) { function haversineKm(lat1, lon1, lat2, lon2) {
@@ -4919,7 +4963,7 @@ document.querySelectorAll(".sub-tab-bar").forEach(_wireSubTabBar);
window.addEventListener("resize", () => { window.addEventListener("resize", () => {
const mapTab = document.getElementById("tab-map"); const mapTab = document.getElementById("tab-map");
if (!mapTab || mapTab.style.display === "none") return; if (!mapTab || mapTab.style.display === "none") return;
window.trx.map?.sizeAprsMapToViewport(); window.trx.modules.map?.sizeAprsMapToViewport();
}); });
// --- Signal measurement --- // --- Signal measurement ---
@@ -6089,8 +6133,8 @@ function dispatchDecodeMessage(msg, skipStats) {
if (msg.type === "wefax" && window.onServerWefax) window.onServerWefax(msg); if (msg.type === "wefax" && window.onServerWefax) window.onServerWefax(msg);
if (msg.type === "wefax_progress" && window.onServerWefaxProgress) window.onServerWefaxProgress(msg); if (msg.type === "wefax_progress" && window.onServerWefaxProgress) window.onServerWefaxProgress(msg);
if (!skipStats && msg.type && msg.type !== "lrpt_image" && msg.type !== "lrpt_progress" && msg.type !== "wefax" && msg.type !== "wefax_progress") { if (!skipStats && msg.type && msg.type !== "lrpt_image" && msg.type !== "lrpt_progress" && msg.type !== "wefax" && msg.type !== "wefax_progress") {
window.trx.map?.statsRecordDecode(msg.type, msg.rig_id || msg.remote || null); window.trx.modules.map?.statsRecordDecode(msg.type, msg.rig_id || msg.remote || null);
window.trx.map?.scheduleStatsRender(); window.trx.modules.map?.scheduleStatsRender();
} }
} }
@@ -6099,10 +6143,10 @@ function dispatchDecodeBatch(batch) {
// Record statistics for every message in the batch regardless of dispatch path. // Record statistics for every message in the batch regardless of dispatch path.
for (const msg of batch) { for (const msg of batch) {
if (msg.type && msg.type !== "lrpt_image" && msg.type !== "lrpt_progress" && msg.type !== "wefax" && msg.type !== "wefax_progress") { if (msg.type && msg.type !== "lrpt_image" && msg.type !== "lrpt_progress" && msg.type !== "wefax" && msg.type !== "wefax_progress") {
window.trx.map?.statsRecordDecode(msg.type, msg.rig_id || msg.remote || null); window.trx.modules.map?.statsRecordDecode(msg.type, msg.rig_id || msg.remote || null);
} }
} }
window.trx.map?.scheduleStatsRender(); window.trx.modules.map?.scheduleStatsRender();
const type = String(batch[0]?.type || ""); const type = String(batch[0]?.type || "");
const uniformType = batch.every((msg) => String(msg?.type || "") === type); const uniformType = batch.every((msg) => String(msg?.type || "") === type);
if (uniformType) { if (uniformType) {
@@ -6187,9 +6231,9 @@ function restoreDecodeHistoryGroup(kind, messages) {
// Record statistics for restored history messages. // Record statistics for restored history messages.
if (kind !== "lrpt_image" && kind !== "lrpt_progress" && kind !== "wefax" && kind !== "wefax_progress") { if (kind !== "lrpt_image" && kind !== "lrpt_progress" && kind !== "wefax" && kind !== "wefax_progress") {
for (const msg of messages) { for (const msg of messages) {
window.trx.map?.statsRecordDecode(kind, msg.rig_id || msg.remote || null, msg.ts_ms || undefined); window.trx.modules.map?.statsRecordDecode(kind, msg.rig_id || msg.remote || null, msg.ts_ms || undefined);
} }
window.trx.map?.scheduleStatsRender(); window.trx.modules.map?.scheduleStatsRender();
} }
if (kind === "ais") { if (kind === "ais") {
if (window.restoreAisHistory) { window.restoreAisHistory(messages); } if (window.restoreAisHistory) { window.restoreAisHistory(messages); }
@@ -7006,9 +7050,18 @@ function stopSpectrumStreaming() {
// ── /meter (fast signal-strength) streaming ───────────────────────────────── // ── /meter (fast signal-strength) streaming ─────────────────────────────────
// Dedicated SSE channel pushed at ~30 Hz by trx-server; bypasses /events so // Dedicated SSE channel pushed at ~30 Hz by trx-server; bypasses /events so
// meter frames are never gated by full-RigState diffing. Synchronous DOM // meter frames are never gated by full-RigState diffing.
// write per frame — no rAF coalescing, per user requirement that it "feel //
// instant" on the frontend. // Client-side asymmetric EMA smoothing (GQRX-style ballistics):
// attack τ ≈ 400 ms — rises in ~12 frames at 30 Hz
// decay τ ≈ 1.0 s — falls in ~30 frames, readable
// DOM updates are coalesced via requestAnimationFrame so the bar
// animates at display refresh rate, not SSE rate.
const METER_ATTACK_ALPHA = 0.08; // per-frame at ~30 Hz ≈ 400 ms τ
const METER_DECAY_ALPHA = 0.03; // per-frame at ~30 Hz ≈ 1.0 s τ
let meterSmoothedDbm = null;
let meterRafPending = false;
function scheduleMeterReconnect() { function scheduleMeterReconnect() {
if (meterReconnectTimer !== null) return; if (meterReconnectTimer !== null) return;
meterReconnectTimer = setTimeout(() => { meterReconnectTimer = setTimeout(() => {
@@ -7019,6 +7072,24 @@ function scheduleMeterReconnect() {
function applyMeterSample(dbm) { function applyMeterSample(dbm) {
if (typeof dbm !== "number" || !Number.isFinite(dbm)) return; if (typeof dbm !== "number" || !Number.isFinite(dbm)) return;
// Asymmetric EMA: fast attack, slow decay.
if (meterSmoothedDbm === null) {
meterSmoothedDbm = dbm;
} else {
const alpha = dbm > meterSmoothedDbm ? METER_ATTACK_ALPHA : METER_DECAY_ALPHA;
meterSmoothedDbm += alpha * (dbm - meterSmoothedDbm);
}
// Coalesce DOM writes to display refresh rate.
if (!meterRafPending) {
meterRafPending = true;
requestAnimationFrame(flushMeterDom);
}
}
function flushMeterDom() {
meterRafPending = false;
const dbm = meterSmoothedDbm;
if (dbm === null) return;
prevRenderData.sigDbm = dbm; prevRenderData.sigDbm = dbm;
const sUnits = dbmToSUnits(dbm); const sUnits = dbmToSUnits(dbm);
sigLastSUnits = sUnits; sigLastSUnits = sUnits;
@@ -7059,6 +7130,7 @@ function stopMeterStreaming() {
clearTimeout(meterReconnectTimer); clearTimeout(meterReconnectTimer);
meterReconnectTimer = null; meterReconnectTimer = null;
} }
meterSmoothedDbm = null; // reset so next rig starts fresh
} }
// ── Rendering ──────────────────────────────────────────────────────────────── // ── Rendering ────────────────────────────────────────────────────────────────
@@ -7959,12 +8031,12 @@ window.addEventListener("keydown", (event) => {
// S — spectrum screenshot (lazy-loads screenshot.js on first use) // S — spectrum screenshot (lazy-loads screenshot.js on first use)
if (key === "s") { if (key === "s") {
event.preventDefault(); event.preventDefault();
if (window.trx.screenshot) { if (window.trx.modules.screenshot) {
void window.trx.screenshot.captureSpectrumScreenshot(); void window.trx.modules.screenshot.captureSpectrumScreenshot();
} else { } else {
const s = document.createElement("script"); const s = document.createElement("script");
s.src = "/screenshot.js"; s.src = "/screenshot.js";
s.onload = () => { void window.trx.screenshot?.captureSpectrumScreenshot(); }; s.onload = () => { void window.trx.modules.screenshot?.captureSpectrumScreenshot(); };
document.body.appendChild(s); document.body.appendChild(s);
} }
return; return;
@@ -1,3 +1,7 @@
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
//
// SPDX-License-Identifier: GPL-2.0-or-later
const textDecoder = typeof TextDecoder === "function" ? new TextDecoder() : null; const textDecoder = typeof TextDecoder === "function" ? new TextDecoder() : null;
const HISTORY_GROUP_KEYS = ["ais", "vdes", "aprs", "hf_aprs", "cw", "ft8", "ft4", "ft2", "wspr", "wefax"]; const HISTORY_GROUP_KEYS = ["ais", "vdes", "aprs", "hf_aprs", "cw", "ft8", "ft4", "ft2", "wspr", "wefax"];

Some files were not shown because too many files have changed in this diff Show More