Developer · v0.5.3
Trunk Recorder Pro API — build your own interface
Everything Trunk Recorder Pro's built-in web interface does goes through the API described here, so an interface of your own can do all of it: a scanner-style listening page, a wall display, a phone view, a dashboard for one talkgroup, a program that logs calls or forwards them somewhere.
Two guides:
- This page is for developers: how to serve an interface, the client library, the examples, and every message.
llms.txtis for an LLM building an interface for you: the same facts, condensed, with rules and a template. See Having an LLM build an interface.
protocol.ts is the exact definition of every
message. Both guides defer to it.
A running recorder serves all of this, on the built-in interface's port and on every other interface's (Serving your interface):
| URL | What |
|---|---|
/ |
The interface this port is for: the built-in one on the recorder's port (8080), yours on its own |
GET /api/docs |
This page (Markdown) |
GET /api/llms.txt |
The LLM guide |
GET /api/client.js |
The client library (client.js) |
GET /api/examples/… |
The examples, runnable: e.g. /api/examples/wall.html |
GET /api/protocol.ts |
Every message, as TypeScript types with comments: the definition |
GET /api/schema |
The same as JSON Schema (draft-07): definitions.FromRecorder / definitions.ToRecorder |
GET /api/version |
{"app": "trunk-pro", "version": "…", "api": 1} (api: the interface API version). Always open, signed in or not |
GET /api/session |
{ auth, access, user, proxy, passkeys, passkeyOrigin, ownPasskeys, appSignIn, apps, app }: whether signing in is on, what this request may do, whether (and where) passkeys work, the user's own passkeys, whether an app signs in by way of the browser here, and the apps signed in (Signing in) |
POST /api/login, POST /api/logout |
Sign a browser in with an access token (a session cookie; answers { access, user }), and out ({"all": true}: everywhere) |
POST /api/passkey/login/…, /api/passkey/register/… |
Sign a browser in with a passkey, and add one (Passkeys) |
GET /signin |
The sign-in page, on every port, whether or not a page needs it |
GET /app/sign-in, POST /api/app/token, POST /api/app/revoke, GET /api/apps |
Sign an app in by way of the browser (OAuth 2.0 with PKCE), sign it out, and list the apps signed in (Apps) |
GET /.well-known/oauth-authorization-server |
Where an OAuth library finds those (RFC 8414), on the built-in interface's port |
WS /api/ws |
The connection: JSON messages both ways, plus binary live audio |
GET /calls/<path>.wav / .json |
A recorded call's audio and details |
The recorder listens on http://localhost:8080 unless it was started with
--port / --bind or its config's server section says otherwise.
Contents
- Quick start
- Serving your interface
- client.js
- Examples
- Access from elsewhere
- Signing in
- How a connection goes
- Concepts
- Messages from the recorder
- Commands to the recorder
- Live audio
- Recorded calls
- Recipes
- Having an LLM build an interface
- Statistics and history
- Compatibility
Quick start
Make a folder with this index.html:
<!doctype html>
<meta charset="utf-8">
<title>Calls</title>
<button id="listen">Listen live</button>
<ul id="calls"></ul>
<script type="module">
import { TrunkClient, LivePlayer } from "/api/client.js";
const rec = new TrunkClient();
const player = new LivePlayer();
rec.on("change", () => {
document.getElementById("calls").innerHTML = rec.history
.slice(0, 20)
.map((e) => `<li>${e.record.talkgroup_tag || e.record.talkgroup}: ${e.record.call_length} s
<audio controls preload="none" src="${rec.callUrl(e)}"></audio></li>`)
.join("");
});
document.getElementById("listen").onclick = async () => {
await player.resume(); // browsers only play sound after a click
rec.listen(); // every call; rec.listen({ talkgroup: 101 }) for one
};
rec.on("audio", (chunk) => player.play(chunk));
</script>Then serve it from the recorder:
trunk-pro --ui ./my-folder # your page on the next free port, http://localhost:8081/Edit the file and reload: the recorder serves the folder as it is on disk.
Without the library, the protocol is plain JSON over a WebSocket. This prints each call as it's recorded, in Node 22+ or a browser:
const ws = new WebSocket("ws://localhost:8080/api/ws");
ws.onmessage = (ev) => {
if (typeof ev.data !== "string") return; // live audio (binary), not asked for here
const m = JSON.parse(ev.data);
if (m.type === "hello") console.log(`Connected to ${m.version}`);
if (m.type === "concluded") {
const r = m.entry.record;
console.log(`${r.talkgroup_tag || r.talkgroup} on ${r.short_name}: ${r.call_length} s`);
console.log(` audio: http://localhost:8080/calls/${m.entry.path}.wav`);
}
};Serving your interface
Let the recorder serve your interface. Each interface gets a port of its
own (8081, 8082, … beside the built-in interface's 8080), and the
recorder's API is served on that port too: /api/client.js, /api/ws and
/calls/ are right there, on the page's own origin, so it needs no access
settings. And because each port is a site of its own to the browser, your
page can't read the built-in interface's storage, or another interface's,
nor they yours.
An interface is a folder with an index.html, plus whatever else it uses:
scripts, styles, images, more pages. There's no server side: everything runs
in the browser. There's no build step unless you want one; a bundler's output
folder (dist/) works too.
On the Interfaces page (or trunk-pro interface add <folder>): Add a
folder… serves it on the next free port, at once. In the config file:
"server": {
"port": 8080,
"interfaces": {
"wall": { "port": 8081, "enabled": true, "access": "listen", "path": "/home/me/wall-display" }
}
}- The key is its id: lowercase letters, digits and
-.pathis the folder: absolute,~/…, or relative to the config file's folder. Withoutpath, it's the copy installed from the interface store. accessis what the page may do with the API:"listen"(the default) or"control". See Access.- Changes to ports,
enabledandaccesstake effect at once. No restart.
For one run: trunk-pro --ui <folder> serves the folder on the next free
port with control access, and opens it. Nothing is saved, which makes it
handy while developing.
An interface.json beside index.html names it and says what it needs.
It's optional for a folder of your own, and required to publish it in the
interface store (docs/interfaces/publishing.md):
{ "id": "wall", "name": "Wall display", "version": "1.0.0", "description": "Every system's calls, big.", "api": 1, "access": "listen" }How files are served:
/is the folder'sindex.html, and/app.jsitsapp.js. A subfolder serves its ownindex.html.- A path with no extension that isn't a file (
/settings) gets the folder'sindex.html. Pages that route themselves this way work; hash routes (#/settings) work anywhere. /api/…and/calls/…are the recorder's: don't put files there.- Files are read on every request, with
Cache-Control: no-cache: edit, then reload. - Nothing outside the folder is served, symbolic links included, and no
hidden files (names starting with
.).
Access
What a page may do depends on the port it came from:
listen (an interface's default) |
control (the built-in interface) |
|
|---|---|---|
| Status, calls on the air, recorded calls, live audio, the dashboard's figures and queries | ✓ | ✓ |
| The config | only what its pages show (what View is sent) | all of it |
setConfig, start, stop, quit, plugins, interfaces, keys, the survey, files on the recorder's computer |
refused with an error |
✓ |
A listen-only connection may send subscribe, statsQuery, radioQuery,
callsQuery and listen; anything else is answered with an error. Its
hello has no configPath, and it isn't sent devices, plugins,
pluginRuntime, interfaces, store, installProgress or keys. An interface that needs more says
"access": "control" in its interface.json; the store shows that before
it's installed, and the user can change it either way at any time.
With signing in on, a page also gets no more than its user's
role allows: the lower of the two. A control user on a listen
interface's port listens; a listen user on the built-in interface's port
listens too. hello.access says what a connection got.
client.js
/api/client.js (in the repository: docs/api/client.js) is an ES module
with no dependencies. It works in browsers and in Node 22+. You don't have to
use it, since the protocol is simple, but it takes care of the fiddly parts:
reconnecting, re-sending listen after a reconnect, keeping state, safe
config edits, and gapless audio.
import { TrunkClient, LivePlayer, decodeAudioFrame, systemName, duration, mhz, escapeHtml } from "/api/client.js";From a page served elsewhere, import it by its full URL and say which
recorder to use. The page's origin must be allowed; see
Access from elsewhere. The import needs no token,
signing in on or not (client.js and the other files under /api/ are
open); connecting does (A page on another origin).
import { TrunkClient } from "http://radio.local:8080/api/client.js";
const rec = new TrunkClient({ server: "radio.local:8080" });new TrunkClient(opts?)
| Option | Default | |
|---|---|---|
server |
the page's host; Node: localhost:8080 |
host:port of the recorder |
secure |
when the page is https | use wss:// and https:// |
historyLimit |
500 | recorded calls kept in history |
token |
none | an access token's secret (trp_…), for a recorder with signing in on: added to the WebSocket's and callUrl's URLs as ?token=. Not needed with signing in off, or by a page the recorder serves once its browser is signed in |
State. Read these properties; don't change them. They are current
whenever change fires.
| Property | |
|---|---|
connected |
true while connected (from hello on) |
version |
the recorder's version |
capabilities |
what the recorder can do beyond recording (hello.capabilities): service, drivers, plugins, interfaces, host, keys, calls, history, tuneGain, releaseRadio |
access |
what this connection may do (hello.access): "listen" or "control"; null before hello |
user |
the user it signed in as, by name (hello.user), or null |
config |
the config (Config) |
phase |
{ phase: "idle" | "starting" | "running" | "stopping", error, ended, restartNeeded } |
status |
EngineStatus: nowS, totals, systems[]. The last run's after Stop; null from Start until the first |
sources |
SourceStatus[]: each radio |
calls |
CallView[]: on the air now (empty when not running) |
history |
CallEntry[]: recorded calls, newest first |
configVersion |
the config's version, which setConfig sends |
talkgroupRows |
each system's talkgroups as the recorder sent them: short name → Talkgroup[] |
log |
the latest 500 LogLines |
aliases |
talker aliases heard on the air: short name → { unit: alias } (those saved, from units, then each unitAlias) |
error |
the latest error message's text, or why a setConfig was refused |
exited |
the recorder said it was exiting (quit); it keeps trying to reconnect, and this clears when it's back |
Events. rec.on(type, fn) returns a function that removes the handler.
type |
fn gets |
When |
|---|---|---|
"change" |
the client | after any message: redraw. While a connection is being greeted, only once, at hello |
any message type, e.g. "concluded" |
the message | that message arrived (after the state was updated) |
"message" |
the message | every message |
"audio" |
{ system, callId, talkgroup, samples } |
a live-audio chunk (Float32Array, 8000 per second) |
"connection" |
true / false |
connected (at hello) / disconnected |
Methods.
send(msg) |
send a command (queued while disconnected) |
start(), stop() |
start / stop recording |
listen(), listen({ talkgroup }), listen({ system, talkgroup }), listen(false) |
live audio: every call, one talkgroup's, one system's (by short name) talkgroup's, none. Kept across reconnects. |
listen({ voice: true, audio: false }) |
digital calls' vocoder frames as voice messages, with or without the PCM; mixes with the filters above |
subscribe(topics) |
the costly messages to receive: ["log"] fills log ("log:<shortName>": one system's lines); "spectrum:0" a waterfall's spectrum. Kept across reconnects. |
setConfig(edit) |
edit(copy) changes a copy of the latest config, and the whole config is sent with configVersion. If the config changed elsewhere meanwhile it's refused, and error says so |
setTalkgroups(shortName, rows) |
replace a system's talkgroups (Talkgroup rows; [] for none) |
setTalkgroup(shortName, talkgroup, edit) |
change one talkgroup's cells ({ alphaTag, description, tag, category, ignore }, any of them) |
setUnitNames(shortName, rows, from?) |
replace a system's own names for its radios ({ unit, name } rows; [] for none); from: where they came from ({ kind: "file", name: "units.csv" }) |
setUnitName(shortName, unit, name) |
name one radio ("": its own name taken out) |
queryCalls(query) |
recorded calls, newest first (a promise): query has any of system (short name), talkgroup, unit, from / to (start time, Unix ms), cursor, limit (1 to 500, 100). Answers { entries, next?, error? }; page on with cursor while next is there. Needs the calls capability |
callUrl(entry, "wav" | "json" | "m4a") |
a recorded call's file URL (with ?token= when the client has a token) |
session() |
GET /api/session (a promise): { auth, access, user }. A WebSocket that isn't let in just closes; this tells that apart from a recorder that's down (it rejects) |
talkgroups(shortName) |
the system's talkgroups, from talkgroupRows and the edits since: Map talkgroup → { talkgroup, alphaTag, description, tag, group, mode }; a conventional system's channels (alphaTag the channel's name) |
unitName(shortName, unit) |
a radio's name, as the system's unitNames.mode says: its unit names (unitNameRows, regular-expression rows too) and the alias heard; else "" |
close() |
disconnect for good |
new LivePlayer(opts?)
Plays the chunks from on("audio"): player.play(chunk). Call
player.resume() from a click or key press first; browsers won't start
sound otherwise. It's the dashboard's player too.
| Option | Default | |
|---|---|---|
followCall |
true |
one call at a time: the first heard, until quiet for quietS; overlapping calls are skipped. false: every chunk queued in turn, one after another (so for one call at a time; to hear calls at once, a player each, below) |
quietS |
1.5 | silence that ends a call, s |
gain |
2 | volume (the vocoders' output is quiet) |
pan |
0 | where the sound sits: left (-1) to right (1) |
output |
the page's | an AudioNode the sound goes to: an interface's own EQ, meter (AnalyserNode), master volume… on the page's output (audioOut()) |
onNowPlaying |
— | (call | null) => … when the call playing changes |
player.nowPlaying |
{ callId, system, talkgroup } or null |
player.gain, player.pan |
the volume (0 mutes) and the place; set them while playing (they glide there) or before resume() |
player.skip() |
drop the call playing, the rest of it too: the next call heard plays |
player.stop() |
stop, and let go of this player's part of the output |
Every player plays into the page's one audio output, audioOut() (an
AudioContext, made on first use, kept for the page's life, woken by any
click or key press when the browser suspends it). Build your own sounds
on it too, and route a player through them with output:
const ctx = audioOut();
const meter = ctx.createAnalyser();
meter.connect(ctx.destination);
const player = new LivePlayer({ output: meter });Several calls at once: a player each — a call's, a talkgroup's or a
system's, whatever the interface places — each with its pan. They mix
in the page's output. wall.html?stereo keeps a player per call, made at
its first chunk (followCall: false), panned to its talkgroup's place,
and stopped at its onNowPlaying(null), when the call is quiet. A
player per talkgroup can keep followCall and stay for good.
Helpers: duration(s) gives "1:05", mhz(hz) gives
"155.2000 MHz", and escapeHtml(s). systemName(status, system) turns the system
number a call or audio chunk carries into its short name
(status.systemNames).
Examples
In examples/. A recorder serves them at
/api/examples/<file>, so they run as they are.
scanner.html |
Everything in one file without client.js: systems, calls on the air, recorded calls, start / stop, live audio. Read it to see the protocol at work. |
wall.html |
A wall display: calls on the air in large type, emergencies first and red, recent calls, live audio. ?talkgroups=101,202, ?system=…, ?stereo (every call at once, each talkgroup in its own place) |
talkgroup.html |
One talkgroup: pick it, see it on the air, listen live, play its recordings, play each new recording as it arrives. |
call-log.mjs |
A program (Node): append each recorded call to a CSV file, and POST it to a webhook. |
The pages' ?server= (a page opened from elsewhere, talking to a recorder at another address) works only with signing in off, or with a token the page is given: none of them passes one.
To make one of the pages your own, copy it into a folder as index.html
and add the folder as an interface.
Access from elsewhere
Signing in is off by default. Then anyone who can reach the port can change the config, start and stop recording, and list folders on the recorder's computer. Three things keep that safe:
- The recorder only listens on
127.0.0.1unless it's told otherwise (--bind 0.0.0.0orserver.bindin the config). Only do that on a network you trust. - Signing in, when it's on: every request needs a user's
access token, except what its
anonymoussetting allows. - Web pages from other sites are refused. Every web page a browser shows
could otherwise reach
ws://localhost:8080. A browser sends the page's origin with each request. Each port accepts its own pages and anything that isn't a browser (noOriginheader: scripts, Node, curl). It answers any other origin with 403 and logsRefused a page from …once. So an interface on port 8081 uses the API on 8081, with its own access: it can't borrow the built-in interface's by connecting to 8080.
To use the API from a page the recorder doesn't serve (a dev server, a
page on another machine, a file), add the page's origin to allowedOrigins
in the server section of the config, or on the Interfaces page under
Pages served elsewhere. Such a page gets the access of the port it uses
(control on the recorder's own). With signing in on, being listed only lets
it in the door: it must also send a token (below),
because the browser's sign-in cookie doesn't count for another site's page.
"server": {
"allowedOrigins": ["http://localhost:5173", "null"]
}- An origin is
scheme://host[:port], exactly as the browser sends it, e.g.http://192.168.1.50:3000. It has no path. "null"is what a page opened from a file (file://…) sends. Note that browsers don't load ES modules into such pages, so client.js needs a served page."*"allows every page. Only use it on a recorder nobody else can reach.- Allowed origins also get CORS headers, so a page can
fetch()from/calls/and/api/, and import/api/client.js. - Changing the config through the API (
setConfig) takes effect at once; editing the file needs a restart.
On a recorder bound to localhost, the Host header must also be a localhost
name. This blocks DNS rebinding, where another site points its name at
127.0.0.1. A reverse proxy that passes its own Host therefore needs its
origin listed (e.g. "https://radio.example.com").
Signing in
Signing in is optional and off unless the recorder's owner turns it on
(server.auth in the config; Setup or trunk-pro access on, see
Remote access and signing in). With it off, nothing
on this page changes and no token is needed.
With it on, every request needs a user's access token (or a browser's
session, signed in with a token or a passkey), except
GET /api/version, /api/session, /api/login, /api/logout,
/api/passkey/login/start and /finish, /signin and the API's static files (/api/client.js, /api/docs, /api/schema,
/api/protocol.ts, /api/llms.txt, /api/examples/…: nothing of the
recorder's own). A user is a person or program the owner adds: a name and
a role, listen or control (the same two as an interface's
Access; the dashboard calls them View and Admin), and an access
token to sign in with, whose secret is trp_ and 64 hex digits. The
recorder makes the secret and shows it once; the config keeps only its
SHA-256. Ask the recorder's owner for one, listen unless your program
changes things.
Without a token that gives it access, a request gets anonymous's access
(none unless set to listen). With none:
- a browser asking for a page gets the recorder's sign-in page in its place,
at the same URL (
GET /signinis the same page on purpose: a visitor with anonymouslistenaccess goes there to sign in, and is sent on to/after); - everything else gets 401 with
WWW-Authenticate: Bearer. A WebSocket is refused before it opens, so a browser only sees it close: askGET /api/sessionto tell why.
Three ways to send the token, any of them, on any route (the WebSocket
and /calls/ too):
| How | For |
|---|---|
Authorization: Bearer trp_… |
Scripts and programs, in any language, and WebSocket libraries that can set headers |
The cookie POST /api/login sets, body {"token": "trp_…"} |
Browsers. It holds a signed session, not the secret, and covers the WebSocket and <audio> too, on every port of that host name, for 30 days or until POST /api/logout |
?token=trp_… in the URL |
Browser pages that can't set a header (a WebSocket, an <audio src>) and can't use the cookie (another origin's page) |
Prefer Authorization: Bearer. A ?token= is part of the URL, so the
secret ends up wherever URLs go: browser history, bookmarks, the logs of
any proxy or tunnel in front, and screenshots of the address bar. (The
recorder's answers carry Referrer-Policy: no-referrer, so its own pages
don't pass their URL on to other sites.) Use it only where nothing else
can carry the token. The cookie only counts for requests from the
recorder's own pages (same origin), never from another site's.
A fourth: a proxy in front that signs people in (Authelia, oauth2-proxy,
Cloudflare Access, tailscale serve; server.auth.proxy, see
Behind a proxy that signs people in).
The proxy says who in a header (Remote-User by default), which the
recorder believes from the proxy's addresses alone, and only where the
cookie would count. Cloudflare Access (proxy.cloudflare) says who in the
token it signs (Cf-Access-Jwt-Assertion), which the recorder checks
against the team's keys, from any address; its plain email header counts
for nothing. A token or the cookie says who first. A program going
through such a proxy signs in at the proxy; a token works there as ever.
POST /api/logout doesn't sign out someone the proxy signed in: that's the
proxy's.
What you get is the lower of the port's access and the user's role.
GET /api/session answers { "auth": true, "access": "listen" | "control" | null, "user": "kiosk" | null, "proxy": true | false, "passkeys": true | false, "passkeyOrigin": "https://radio.example.com", "ownPasskeys": [{ "id": "…", "name": "Laptop", "created": 1767225600 }], "appSignIn": true | false, "apps": [{ "id": "…", "name": "Trunk Monitor on Luke's Mac", "user": "luke", "access": "listen", "created": 1767225600, "until": 1769817600 }], "app": { "id": "…", "name": "…", "until": 1769817600 } }
for the request it's asked with (proxy: the proxy in front signed it in; passkeys: whether they work on this port, the built-in interface's, for the host it asked at; passkeyOrigin, from any port: the one origin they work at, left out where there's none; a page at another origin links there; ownPasskeys: the user's own passkeys, never their keys, left out when there are none or it isn't signed in as a user; appSignIn: an app signs in by way of the browser here, the built-in interface's port with signing in on, see Apps; apps: the apps signed in as the user, every user's for one with control access on the built-in interface's port, left out when there are none; app: the app asking, when it's one, with when its token ends), and hello carries access and user.
POST /api/login answers { "access": "listen" | "control", "user": "kiosk" }
(the user's role and name, whatever the port; signing in on or off) with the
cookie, or 401. When the owner changes access (a user removed, a role or an
interface's access changed, signing in turned on), connections it affects
are closed; reconnect, and the new hello says what you have now
(client.js does this). A connection opened with a session (the cookie) or
Cloudflare Access's token is closed when that expires.
Signing out everywhere. POST /api/logout with {"all": true}, on
the built-in interface's port, signs the user this request is out
everywhere: every browser's session of theirs signed in until now ends
(their connections close), this one's cookie too; 204. {"all": true, "user": "kiosk"} does it for another user, with control access. It's
kept beside the config (access-state.json), not in it: no config
message follows. It ends sessions only: an
access token sent with each request (Authorization: Bearer, ?token=)
still works, so a token that may have been seen is to be made again.
An interface the recorder serves needs no change. The browser signs in once, on the sign-in page, and the cookie covers the dashboard and every interface's port on that host name.
Over plain HTTP the token travels in the clear, like everything else the
recorder sends. That's fine on your own network, a VPN or an SSH tunnel.
Otherwise the owner can turn on HTTPS (server.tls, see
HTTPS), or put a reverse proxy
that adds it in front; across the internet, use a VPN or tunnel rather than
exposing the port. Over HTTPS, or behind a proxy that sets
X-Forwarded-Proto: https, the cookie is marked Secure. Sent over plain
HTTP to a recorder that serves HTTPS, a request that carries a token, the
cookie or a sign-in isn't redirected but refused (400): the secret already
crossed the network; make that token again.
Passkeys
Browsers sign in with a passkey too: the sign-in page and Setup do it, and
another page on the built-in interface's origin can (never another origin's:
these routes have no CORS). Passkeys work where browsers allow them, on
localhost or over HTTPS on the recorder's server.hostname, and at one
origin there, the dashboard's, which the recorder works out itself
(passkeyOrigin; see
Passkeys): an answer made at
any other origin, another port of the same name included, is refused. On
an interface's port these routes answer 403 (an interface's page links to
the dashboard's /signin instead); on a host with no passkeys, 400 and
"passkeys": false. Each is a WebAuthn ceremony in two steps, all POST
and JSON, its binary values base64url (no padding), as webauthn-rs reads them:
| Route | Body | Answer |
|---|---|---|
/api/passkey/login/start |
none | { id, options }: options.publicKey for navigator.credentials.get (no credentials listed: the passkey says whose it is), options.mediation "conditional" (for autofill; leave it out to ask at once) |
/api/passkey/login/finish |
{ id, credential }: what get answered (id, rawId, type, response: authenticatorData, clientDataJSON, signature, userHandle) |
As /api/login: the cookie and { access, user }, or 401 |
/api/passkey/register/start |
{ name }: what to call it (1–40 characters) |
{ id, options }: options.publicKey for navigator.credentials.create |
/api/passkey/register/finish |
{ id, credential }: what create made (id, rawId, type, response: attestationObject, clientDataJSON) |
{ name, id }: its name (made the user's alone: "iPhone 2") and credential id, saved to the config |
Registering is for a user signed in (a session or a token), and adds the
passkey to that user alone. Signing in needs nothing. A ceremony waits 5
minutes for its finish, and signs in once (a sign-in's id is the waiting
state itself, signed by the recorder: nothing's kept for it until it
finishes). A session signed in with a passkey ends when the passkey is
removed from the config.
Apps
An app (Trunk Monitor, a script with a browser to hand, another site's
page) signs in by way of the browser, so it's never handed the user's
token and needs no passkey of its own: the user signs in on the recorder's
page, as they always do, and allows the app there. It's OAuth 2.0's
authorization code flow with PKCE, as native apps use it (RFC 8252), so an
OAuth library does all of it; GET /.well-known/oauth-authorization-server
on the built-in interface's port names the endpoints. Nothing is
registered beforehand: client_id is the name the user is shown, and
there's no client secret. GET /api/session says whether a recorder does
this (appSignIn: the built-in interface's port, signing in on).
The app makes a secret, the verifier (32 random bytes as base64url will do), and opens this in the browser, on the built-in interface's port (on a Mac or iPhone, in a web authentication session):
/app/sign-in?response_type=code&client_id=<name>&redirect_uri=<return link> &code_challenge=<challenge>&code_challenge_method=S256&scope=listen&state=<anything>Parameter client_idWhat the page, the log and the Users table call the app ("Trunk Monitor on Luke's Mac"), 64 characters at most redirect_uriWhere the browser takes the code: see below. Left out: the page shows the code, to copy into the app code_challengeThe SHA-256 of the verifier, base64url, no padding (43 characters). code_challenge_method:S256, the only onescopeThe most the app wants: listen(the default) orcontrol. It never gets more than the user's role, and the user may allow lessstateHanded back as it came, for the app to tell its own request by response_typecode, or left outThe user signs in if they aren't (a token, a passkey, or the proxy in front), and the page asks whether to allow the app, naming it, them, what it may do and where it returns. Allow sends the browser to
<redirect_uri>?code=<code>&state=<state>; Cancel to<redirect_uri>?error=access_denied&state=<state>.The app posts
{ "code": "…", "code_verifier": "…" }(JSON, or a form as OAuth libraries send it,grant_type=authorization_codeandredirect_urichecked if sent) toPOST /api/app/token, within two minutes, and is answered{ "access_token": "trpa_…", "token_type": "Bearer", "expires_in": 2592000, "scope": "listen", "user": "luke", "access": "listen", "until": 1769817600, "id": "9f2c…" }or 400
{ "error": "invalid_grant", "error_description": "…" }: not a code for that verifier, used already, too old, or the user signed out everywhere since. A code works once.It sends the token as an access token goes:
Authorization: Bearer trpa_…with every request,?token=on the WebSocket where a header can't go.
Where the code may go (redirect_uri), with nothing registered:
| Return link | For | |
|---|---|---|
com.example.app:/signin |
An app on a Mac, iPhone, Android or Windows | A scheme of the app's own: a domain name backwards (it has a dot), so it can't be javascript:, file: or another app's short name |
http://127.0.0.1:<port>/…, http://[::1]:…, http://localhost:… |
A program or script on a computer | The program listens there until the browser arrives. On the device the browser is on, wherever the recorder is |
https://site.example/… |
Another site's page | Only an origin in server.allowedOrigins, by name (not *): the recorder's owner let that site in |
| none | A device with no browser, a terminal over SSH | The page shows the code and a Copy button |
Anything else, and the page says why instead of asking. The page says which it is before the user clicks (This device, the other site's name, or Copy a code).
What the app holds is a token of its own, not the user's and not a
browser's session: good until until (Unix seconds, 30 days on; then the
app signs in again), for what the user allowed and never more than their
role is now. It's the user, less what's theirs alone: an app's token
doesn't allow another app, add a passkey, make an access token, or change
who signs in (server.auth). GET /api/session asked with it carries
app: { id, name, until }.
Ending it. The app signs itself out with POST /api/app/revoke { "token": "trpa_…" } (RFC 7009; 200 whether it was one or not), or
POST /api/logout with its token. Its user removes it in the dashboard
(the top bar's key, or Setup → Access), which is POST /api/app/revoke { "id": "…" }; a user with control access removes anyone's, on the
built-in interface's port. It ends too when its user is removed or
signed out everywhere, or the token or passkey they allowed
it with is made again or removed. Then its connection closes and its
requests answer 401. GET /api/apps lists [{ id, name, user, access, created, until }]: an app's own, a user's, or everyone's for control on
the built-in port. Never the tokens: the recorder keeps their SHA-256,
beside the config with the rest of the sign-in state.
The log names each app as it's signed in and removed (User luke: app "Trunk Monitor on Luke's Mac" signed in, View (allowed by them, with a passkey "Laptop")), and what an app changes says so (User luke (app "…")).
Why it's safe to leave open. The code is nothing without the
verifier, so another program that sees the return link gets nothing for
it; it's sealed by the recorder, good for two minutes and once. The page
that allows is the recorder's own, on the built-in interface's port:
POST /api/app/approve answers 403 from an interface's port or another
origin, the page isn't shown in a frame, and only a person signed in
allows (not an app, not an anonymous visitor). The return link is checked
when the page opens, again when the user allows, and the code carries it:
a token request that names another is refused.
The server on one computer, the browser and app on another is the
ordinary case: nothing in the flow is the recorder's address but the page
the app opens. Two things to know. Passkeys work at one origin
(passkeyOrigin); opened anywhere else, the sign-in page's passkey link
goes there with the app's request intact, and the app trades the code at
the address it was given. And over plain HTTP the page says
Unencrypted: the code and the token cross the network in the clear, as
everything else does there, so give the app an HTTPS or VPN address
(Remote access).
Behind a proxy that signs people in, whoever the proxy says is at the
browser allows the app, as they'd do anything else; the app's token then
ends with the user (removed, signed out everywhere). The app's own
requests still have to get through the proxy: tailscale serve passes
them; Cloudflare Access wants a service token's CF-Access-Client-Id and
CF-Access-Client-Secret headers, which let a program through and sign
nobody in.
curl
TOKEN=trp_… # from the recorder's owner
curl -H "Authorization: Bearer $TOKEN" "http://radio.local:8080/api/v1/calls?limit=5"
curl -H "Authorization: Bearer $TOKEN" -o call.wav "http://radio.local:8080/calls/<path>.wav"
curl http://radio.local:8080/api/session -H "Authorization: Bearer $TOKEN"Python (WebSocket)
With websockets 14 or later
(pip install websockets; older versions call the argument extra_headers):
import asyncio, json, os
from websockets.asyncio.client import connect
async def main():
headers = {"Authorization": f"Bearer {os.environ['TRP_TOKEN']}"}
async with connect("ws://radio.local:8080/api/ws", additional_headers=headers) as ws:
async for text in ws:
if isinstance(text, bytes):
continue # live audio
m = json.loads(text)
if m["type"] == "hello":
print("access:", m["access"], "as", m.get("user"))
elif m["type"] == "concluded":
print(m["entry"]["record"]["talkgroup"], m["entry"]["path"])
asyncio.run(main())A wrong token, or a removed user's, fails the handshake with HTTP 401.
A page on the recorder's own origin
A page the recorder serves is behind the sign-in page already, so by the
time it runs the browser is signed in and new TrunkClient() just works. A
page that offers its own sign-in (say, to step up from anonymous listen to
control) posts the secret, then connects:
import { TrunkClient } from "/api/client.js";
async function signIn(secret) {
const r = await fetch("/api/login", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ token: secret }) });
if (!r.ok) throw new Error(await r.text()); // 401: not a token of this recorder
return r.json(); // { access, user }: who signed in
}
const session = await (await fetch("/api/session")).json();
if (session.access !== "control") console.log(await signIn(prompt("Access token")));
const rec = new TrunkClient();
rec.on("hello", (m) => console.log(`${m.access} access, as ${m.user ?? "nobody"}`));The cookie is HttpOnly: the page never reads it back (signing in again
replaces it). Sign in before
making the client; a client already connected keeps the access it was
greeted with until it reconnects. After a sign-out (POST /api/logout), the
recorder closes nothing by itself (signing out everywhere does); reload the page. A page that would rather
not ask for the secret itself links to /signin, the recorder's sign-in
page, which goes on to / once signed in (the dashboard's Sign in does
this).
A page on another origin
A page served by something else (a dev server, another machine) needs its
origin in server.allowedOrigins (above) and a
token: the cookie doesn't count for it. Send it as a Bearer header on
fetch() (the recorder answers the CORS preflight that brings). A browser
can't put a header on a WebSocket, so client.js puts the token on the
WebSocket's URL, and on callUrl's for <audio>:
const server = "radio.local:8080";
const token = localStorage.getItem("trpToken"); // however your page keeps it
const { TrunkClient } = await import(`http://${server}/api/client.js`);
const rec = new TrunkClient({ server, token });
const res = await fetch(`http://${server}/api/v1/calls?limit=20`, { headers: { Authorization: `Bearer ${token}` } });
const { entries } = await res.json();client.js and the rest of /api/'s static files are open, so the import
needs no token; everything that shows the recorder (the WebSocket,
/api/v1/, /calls/) does.
Making users
The owner adds users in Setup (New token) or with trunk-pro access add <name> [--access listen|control]. A program with control access can add one
too: {"type": "createToken", "id": 1, "name": "wall", "access": "listen"}
makes user wall with an access token, answered to it alone with
tokenCreated (id, name, and the token's secret, or error). It works
with signing in off too. Removing a user is a setConfig without them in
server.auth.users. A listen-only connection's config has no server.auth, nor anything else its pages don't show (what View is sent). Each comes as its default or is left out.
How a connection goes
- Connect to
ws://<host>:<port>/api/ws(wss://when the recorder serves HTTPS: a page served by it uses its own scheme,wss:from anhttps:page; client.js does this). SetbinaryType = "arraybuffer"if you'll want live audio. With signing in on, bring an access token (Signing in). - The greeting. The recorder sends how things are now as ordinary
messages, the same ones it sends later when they change:
state,config,talkgroupsandunitNames(one for each system),unitsandmdcUnits(each system with some),heard,history(the last 300 recorded calls),radios,survey,tune(the last gain tuning, if any),monitorEvent(each recent event),host; with control access alsodevices,keys,pluginsandinterfaces.hellocomes last. It means you're caught up: draw the first screen then, and don't treat something missing as missing before it (a system with notalkgroupsmessage has no talkgroups). - Then messages as things happen, to every connected client:
statewhen recording starts or stopsstatusabout twice a second while recording: systems, sources and the calls on the airstatsonce a second while recording: every measured series' value (see Statistics and history)hostevery 2 s: the computer and the plugins (desktop app)concludedfor each recorded callmonitorEventwhen something notable happensconfigwhen anyone changes the config (with itsversion)- …the full list is below.
- Subscribe to what costs the recorder something to make, while you
show it:
{"type": "subscribe", "topics": ["spectrum:0", "log"]}. A connection gets none of these until it asks; eachsubscribereplaces the last. Topics:spectrum:<source>(the waterfall, ~7/s),log(every control channel message as a line;log:<shortName>one system's),rf:<source>(rfDetail, 1/s),decode:<shortName>(decodeDetail, 1/s),platform(per-core and per-interface figures inhost),unit(unitEvent: what each radio does on the control channel, as it happens). With nobody subscribed the recorder doesn't compute them. - Send commands as JSON text whenever you like. Answers to your own
commands (
error,notice,dir,trConfig,devices,radios,store,configSaved,subscribed,statsResult,radioResult,callsResult,licenseResult,callSignResult,pluginActionResult, andpluginswhen you sentplugins) come to your connection only. A command the recorder can't read (a field missing or of the wrong kind, an unknowntype) is answered with anerror. Everything else goes to every client: afteraddPlugin,removePluginor a plugin'sinstalleveryone getsplugins, and aftersetConfigorchannelFileeveryone getsconfig; everysetConfigis answered to its sender withconfigSaved. - Reconnect when the socket closes: the recorder may have restarted, or
your access changed (Signing in). A new greeting brings you
up to date,
hello.accessincluded. Per-connection settings (live audio, subscriptions) must be sent again after it. quitmeans the recorder is exiting (Quit, Ctrl-C, a service stop or restart). The built-in interface stops there. A display that should come back after a restart keeps trying, more slowly. client.js retries every 5 s and setsexited.
Unknown message types should be ignored: new ones may be added.
Concepts
Phase. The recorder is idle, starting, running or stopping.
The state message carries it, with error (why it stopped
or couldn't start), ended (a capture file played to its end) and restartNeeded (the config was edited since Start, in what a run reads only when it starts: Stop, then Start, to take it).
Systems. config.systems are trunked systems: P25, SmartNet, DMR,
NXDN and EDACS. Each has its own shortName, which is also the folder its calls are
saved in, and its sites, each a control channel it is recorded from. A call
heard on several sites of a system is one call: every copy is recorded and the best saved (recording.dropDuplicateCalls off saves every copy); a call's site
(and alsoOn, the other sites carrying it) are site names. While running,
status.status.systems[i].index is the number that calls and live audio
carry as system, and systems[i].sites[] has each site's control channel,
identity and decode counts. A site's identity (nac, wacn, sysId, rfss, site, and for DMR and NXDN colorCode, network, ran) leaves out
what hasn't been heard yet, so test a field with != null. It is the system's position among the systems
being recorded (enabled, with a site that has a control channel), so
match on shortName rather than on positions in the config.
Conventional systems. config.conventional[k] are groups of fixed
frequencies. Their calls are numbered after the trunked systems' (and
status.systemNames names every number); while running they're in
status.systems too, after the trunked ones, with sites: [] and
conventionalOpen (channels open now). Each channel's calls are filed under
a talkgroup: the channel's talkgroup (TG Number); without one, a digital
channel's (P25, DMR, NXDN) the talkgroup the air names, an analog channel's
its frequency in kHz (a later row on one frequency adds a digit: 1543251).
Calls and transmissions. A call is usually a talkgroup's conversation, its
transmissions until it has been quiet for the call timeout. A system with
recording.conversationMode false (its own recording rules) makes each
transmission a call of its own. On a system with several sites every copy is
recorded and the best saved; a copy is dropped only when the saved one holds
all of it, so a few may be saved twice. Copies of one transmission saved share
their CallRecord.transmission_id.
Calls on the air vs. recorded calls.
status.calls(CallView[]) are the calls happening right now. That includes ones being followed but not recorded:state: "monitoring"with areasonsuch as"encrypted"or"unknown_tg".- A recorded call arrives once, finished, as
concluded. Itsentryis aCallEntry:path(where its files are) andrecord, Trunk Recorder's call JSON (CallRecord). The same entries make up thehistorymessage, newest first.
Talkgroups are numbers. Their names (alphaTag / talkgroup_tag) come
from each system's talkgroup file (the talkgroups message), and are
"" when the talkgroup isn't in it. Units (radios) are numbers too:
CallView.sources, CallRecord.srcList. Their names come from the
user's unit names (the unitNames messages), the talker
aliases heard on the air (the units messages, then the unitAlias messages),
and srcList[].tag.
Times. Engine times (nowS, startS, timeS) are seconds since
recording started. Times in call records are Unix seconds / milliseconds.
Frequencies are Hz everywhere.
Messages from the recorder
Every message is a JSON object with a type. Exact fields are in
FromRecorder in protocol.ts.
type |
When | What's in it |
|---|---|---|
hello |
Last of a connection's greeting: you're caught up | version, platform, api, configPath (control access only), surveyBands, access ("listen" or "control": what this connection may do), user (the user it signed in as, by name; absent without one), capabilities: what it can do beyond recording, of service (a program of its own: quit, files by path, the log, M4A encoding), drivers (USRP, Airspy, SoapySDR, finding radios), plugins, interfaces, host, keys, tuneGain (tuning a radio's gain), releaseRadio (releasing a radio while recording, and resuming it), calls (the call store, for callsQuery) and history (the dashboard's history further back than a week, for statsQuery's 30d, 90d and 1y; the desktop app has all of them, calls and history while its call store is open, and the browser build none: show only what works, and a command for one it lacks gets an error). The rest of the greeting is the messages below, sent first |
history |
On connecting | entries: the latest calls (≤ 300 CallEntry), newest first; next?: where older calls go on from (a callsQuery cursor), present when there are more; dropped: this run's calls lost in the last 30 minutes (≤ 200 DroppedCall, newest first, each as a callDropped without its type). Then concluded and callDropped for each new one |
units |
On connecting, for each system with some | system (short name), csv: the talker aliases saved, as CSV: unit,alias,source,time,wacn,sys,tg, the newest line per unit wins. Then unitAlias for each new one |
talkgroups |
On connecting, for each system with some; whenever they're replaced | system (short name), talkgroups: its talkgroups, a row each in Trunk Recorder's columns: number, mode, alphaTag, description, tag, category, priority (1 unless set; −1 means ignore), preferredNac (0: none), preferredSite, ignore, and comment (the # lines above its row in the file it came from), extra ([column, value] pairs of columns Trunk Recorder doesn't know) and origin when it has them. []: none now. A row's origin is where its names came from — its last change, not its history: kind ("file", "radioReference", "directory", "trunkRecorder", "edited"), name (the file's or directory's), at (Unix s) |
talkgroupEdited |
One talkgroup of a system's was edited (setTalkgroup) |
system, talkgroup, edit: the cells it set; origin: its origin when the edit changed its names (not for Ignore alone). Make the same edit to the rows you keep: only that row changes, and a row is added when missing and something is set (client.js does this) |
unitNames |
On connecting, for each system with some; whenever they're replaced | system, unitNames: the system's own names for its radios (Trunk Recorder's unitTagsFile), in order, a row each: unit (a unit ID, or a regular expression between slashes, /^1(\d{3})$/), name (a pattern's groups as $1 or \1: Engine $1), origin. The first row that matches names a radio. []: none now |
unitNameEdited |
A radio was named (setUnitName) |
system, unit, name ("": its own row taken out), origin. Make the same edit: its own row (unit the ID) gets the name, added before the first pattern when it has none (client.js does this) |
mdcUnits |
On connecting, for each system with some | system (short name), units: the radios whose IDs came in MDC1200 (the radio registry's; show them in hex). Each call's srcList says it after |
plugins |
On connecting (control access); after plugin changes; answers plugins |
plugins (PluginInfo[]), encoderFound |
state |
Recording starts / stops | phase, error, ended, restartNeeded |
status |
~2/s while running | status (EngineStatus: totals, systemNames: every system's short name by its number, systems[] (trunked, then conventional) with share (a system shared with the directory: `{ state: "needsCallSign" |
spectrum |
Topic spectrum:<source>: ~7/s while running |
source, centerHz, rateHz, bins: 512 levels in dBFS, lowest frequency first, spanning centerHz ± rateHz/2 |
stats |
1/s while running | t (Unix s), values: series name → value now (Statistics and history) |
host |
Every 2 s (desktop app) | t, values (the computer's and plugins' series), platform (OS, cores, container and its limits, disks[] ({ name, path, mount, totalBytes, freeBytes }; the RAM spool's as spool, with kind ("RAM disk", "tmpfs" (/dev/shm), "service" (systemd's runtime folder) or "folder"), calls overflowed to disk, times it was removed while running, and missing: gone and not made again), folders[] (the folders calls are written to, recordings and, while it's on, spool: { name, path, ok }, ok null until checked; while one can't be written to, why in a few words, detail (what was being done and what the system said), fix, since and lost: files not written since), probes[] (connectivity checks), clock (the clock's health: the operating system's sync and time service, a measured offset from server, driftMs (the recording's own clock against the wall clock: shown, not judged, since call times are corrected for it), the radio systems' clocks, and problem: the recorder's verdict), spotlight (macOS: whether Spotlight indexes the recordings folder), reach (where the built-in interface can be reached this run: now, the address listened on, and saved, server.bind as saved, each { address, listen } with listen "thisComputer", "every" or "one"; flag: now is --bind's; routes[], { via, url, iface?, public, direct }, via "local", "network", "tailnet", "tailscaleServe", "funnel", "cloudflare" or "hostname", public from anywhere on the internet, direct gone when it listens on this computer only), unavailable: what this platform can't tell and why) |
rfDetail |
Topic rf:<source>: 1/s |
source, profile (the noise floor in 64 slices across the band, dBFS per FFT bin), channels (each channel on it: power, floor, SNR, carrier offset, the receiver's eye opening or CQPSK phase error) |
decodeDetail |
Topic decode:<shortName>: 1/s |
system, channels (the system's channels as received now, each with its site), sites (each running site's index, name, and what its control channel announces: dmr, nxdn), patches (the patches standing now, each once: supergroup and members) |
monitorEvent |
Something notable happened | t, level (info, ok, warn, bad), kind and its fields: control channels (controlLost, controlRegained; system, site), talkgroups and radios (tgFirstSeen, tgActive, unitFirstSeen, unitActive, unitAffiliated, callVolume), tones (tonePattern: talkgroup, alphaTag (its name, as its call has it), text, signals), radios (sourceDrops, sourceClipping, sourceQuiet with peakDb (gain may be low; info), sourceRecovered), plugins (pluginHealth), the computer (linkDown, linkUp, diskLow), the folders calls are written to (folderUnwritable with folder, path, why, detail and fix; folderWritable with lost), the RAM spool (spoolLow with critical, spoolFull with calls, spoolRecovered, spoolRemoved with spool (its kind) and remade), the clock (clockOff with why and bad, clockOk, clockStep with byMs). The event feed's kinds are listed in protocol.ts (MonitorEvent) |
unitEvent |
Topic unit: as it happens |
event: what a radio did on the control channel, as the unit plugin topic has it (UnitEvent): system, system_id, short_name, site, site_id, kind (registration, deregistration, affiliation, acknowledge, location, data_grant, answer_request, call_alert, emergency_alarm), unit and its tag, talkgroup and its alpha_tag, emergency, time (Unix s). Calls (grants) come as status and concluded |
subscribed |
Answers subscribe |
topics |
callsResult |
Answers callsQuery |
id (as asked), entries (CallEntry[], newest first, ordered by start time then path), next? (present only when more calls remain: send it back as cursor for the next page), error? (the call store is off or failed: the page is the recent calls alone) |
keys |
On connecting, and after an unlock, a lock or a config change (control access) | sources[]: { name, systems, unlocked }, each key container that waits for a password |
statsResult |
Answers statsQuery |
id, from, to, loading (the history files are still being read), series: name → { t0, stepS, v, lo, hi, n } |
radioResult |
Answers radioQuery |
id, what, and by what: rows (talkgroups / radios / frequencies / tone patterns heard), outOfBand (freqs), row and its detail, systems (summary), histogram |
pluginActionResult |
Answers pluginAction, to its sender |
id, ok, message: what the plugin said of it (or why there's no answer: it isn't running, or didn't answer within 15 s) |
concluded |
A call was recorded | entry: { path, record, audio, json, products? }; audio / json: whether they stay in the recordings folder once the plugins are done (audio: some audio, .wav or .m4a, stays: Keep .wav / Keep .m4a; json: Keep call JSON; false: deleted then); products: what plugins made of it so far (a product each, without its call) |
product |
A plugin made something of a call | A product: transmission_id, by, time, call (system_id, short_name, talkgroup, talkgroup_tag, freq_hz, path), kind and data (transcript, page, acars, or a plugin's own; each has a text). It belongs to every CallEntry whose record.transmission_id is its: add it to their products |
callDropped |
A call was lost, as the recorder decides | A DroppedCall: callNum (as a saved call's call_num and status.calls[].id), system, site?, talkgroup, alphaTag, freqHz, source? (the radio it was recorded on), startTime (Unix s), lengthS (grant to loss), stage and why: notSaved (recorded, not kept) for silent (no voice, Keep silent calls off), short (under minCallS), encrypted (the voice turned out encrypted, Record encrypted off) or writeFailed (its files couldn't be written; detail says why) or noData (a Data only system's call nothing was decoded from); notRecorded (never recorded) for noSource (no radio's band takes in its frequency) or noRecorder (every recorder busy). A recorded one has signal, noise (dBFS) and, unless its write failed, voiceFrames, badFrames: strong signal and no frames is a radio keyed without talking, weak or many bad frames a reception problem. Calls passed over on purpose (an encrypted grant, a talkgroup not on the list) aren't lost. Each notSaved one is one of notSaved |
callFiles |
A call's upload plugins are done, and it kept other than its entry said (an upload failed and its files stay) | path, audio, json |
log |
Topic log (warnings and errors always) |
lines[]: { timeS, kind, text, system?, site?, time?, level? } — kind e.g. "error", "control", "alias", "plugin", "info", or a control-message kind; the decoder's lines have timeS (seconds into the recording), the recorder's own time (Unix seconds) and level |
voice |
Live voice, while listening with voice |
chunk: the voice plugin topic's chunk (Vocoder frames) |
unitAlias |
A talker alias was heard | system (short name), unit, alias |
heard |
On connecting; conventional codes heard changed | heard: frequency (Hz, as a string) → HeardCode[] |
config |
On connecting; the config changed (anyone's setConfig, a plugin added…) |
config, version (what an edit is sent with) |
configSaved |
Answers setConfig, to its sender |
version (the config's now), error when the edit wasn't taken (the config changed elsewhere meanwhile, or it's bad) or couldn't be saved |
tokenCreated |
Answers createToken, to its sender |
id, name, secret (the new user's access token's, shown this once: the config keeps its hash) or error (a bad or taken name) |
devices |
On connecting (control access); answers devices |
devices: RTL-SDR dongles plugged in (busy when another program has one) |
radios |
On connecting; answers findRadios; again when a saved config names a radio on the network anew |
radios: the drivers beyond RTL-SDR (USRP, Airspy, bladeRF, SoapySDR…; the Airspy and HydraSDR ones are built in, the rest optional) and their devices, and network: the radios on the network the sources name (an RTL-SDR's rtl_tcp server, a SpyServer), each kind, address, and what it said (model, rates, gains) or error |
dir |
Answers listDir |
a folder: path, parent, dirs, files (.json), home, sep, error |
trConfig |
Answers readTrConfig |
a Trunk Recorder config.json's text, the files it names, or error |
survey |
The survey's progress | stage (idle / scanning / monitoring / done), candidates, the channel monitored, the suggested system |
licenseResult |
Answers licenseQuery, to its sender |
id, results[] of { freqHz, historical, licenses[] } (each license: callSign, licensee, serviceCode, serviceDesc, freqHz, emission, distanceM, bearingDeg, bearingCardinal, city, state, status, locationKind; historical: none active, so lapsed ones), or error |
surveySpectrum |
While surveying | like spectrum |
tune |
A radio's gain being tuned, each time it moves; on connecting, the last (control access); answers tuneGain with check |
phase (planned / running / done / stopped / failed), source, radio, plan (its steps, in words), scored, watched, start, tried[] (each candidate, against, cmp { diff, se, snr? { diff, se } } (snr: the control channel SNR's, dB, the tie-break where decoding is already full) or why it was refused, kept, systems[] figures, clipPct), now, estimateS, elapsedS, best, applied, outdated (the radio was changed in Setup since it was done), error. A gain setting is [knob, value][]: lna, mixer, vga, amp, step (an Airspy table's), gain (dB) |
sourceProfile |
Answers profileSource |
source, then error, or centerHz, rateHz, spectrum / floor (1024 points, dB, −rate/2 … +rate/2), rows (a waterfall), referenceDb, lowHz / highHz (how far in the floor is 3 dB down), lowDropDb / highDropDb, suggestedGuardHz |
pluginRuntime |
A plugin's totals changed (control access) | id, runtime (state, counts, recent log; metrics — queue, upload time, endpoints — when the plugin reports them; restarts, events dropped, uptime; results per minute for the last hour) |
interfaces |
On connecting (control access); after interface changes; answers interfaces |
interfaces (InterfaceInfo[]: each one's port, access, whether it's served and why not), api |
store |
Answers store |
kind (plugin: the plugin registry; interface: the interface store), source, fetched, problem, listings (a plugin store also says this computer's target) |
installProgress |
As an install goes (control access) | kind, key (what was asked for), id, stage (finding … done / failed), message |
iqCaptures |
Answers iqCaptures, iqCaptureStart, iqCaptureCancel, iqCaptureSend, iqCaptureWithdraw and iqCaptureDelete (control access) |
id, active (the capture of every radio being made: name, seconds, elapsedS), waiting (captures asked for that wait on the air: key, text, seconds?, elapsedS), captures (the captures on disk in root, newest first), root, recording (the radios are running), presets (the capture rules shipped), canSend (there's a corpus service to send captures to), error (why the last request or capture failed) |
iqCaptureReview |
Answers iqCaptureReview |
id, name, metadata, diagnostics, waterfalls: what capture name would publish; error |
iqRuleChecked |
Answers iqRuleCheck |
id, error: why the rule can't run, if so |
dataSummary |
Answers dataSummary |
id, systems[]: what the store keeps of each system it has (the config's, and those removed from it whose data stayed): id, shortName, inConfig, and counts of calls, talkgroups, unitNames, talkerAliases, radios, heardTalkgroups, historySeries; error when it couldn't say |
dataDeleted |
Answers deleteData |
id, deleted: how much went (the same counts); error: not all of it did |
dataCompacted |
Answers compactData |
id, beforeBytes, afterBytes: the store's size (SQLite: its files; PostgreSQL: its tables and indexes); error: it couldn't |
error |
A command failed | message, for the user |
notice |
A command worked and has something to say | message |
quit |
The recorder is exiting (it may be restarted) | — |
Commands to the recorder
Send JSON text. Exact fields are in ToRecorder in protocol.ts. A command that can't be read
(unknown type, a field missing or of the wrong kind) is answered with an error saying what was
wrong; one a listen-only connection may not send, or the browser build can't do, with an error
too.
type |
Fields | Does |
|---|---|---|
start |
— | Start recording with the saved config. state follows; error if it can't. |
stop |
— | Stop recording. Calls in progress are saved. |
listen |
on, system (a short name, or null), talkgroup (number or null), voice (optional, false), audio (optional, true) |
Live audio on this connection: every call (both null), one system's, one talkgroup's, or both. voice: true adds digital calls' vocoder frames; audio: false leaves out the PCM. on: false stops it. |
setConfig |
config, version |
Replace the whole config, edited from version (the last config message's): saved, and sent to everyone as config. Refused if the config has changed since (another browser saved). Always answered with configSaved. Takes effect at the next start (plugin settings at once). |
setTalkgroups |
system (short name), talkgroups: rows as the talkgroups message has them; from (optional): where they came from, an origin without at ({ kind: "file", name: "dc.csv" }) |
Replace all of a system's talkgroups ([] removes them; a number twice: the later row, in the first's place). A row whose names were already there keeps its origin; the others get from, at the recorder's time (no from: each keeps the origin it's sent with). Everyone gets them as talkgroups; a recording takes them at once. CSV is only for files: read a talkgroup file yourself and send its rows. |
setUnitNames |
system, unitNames: rows as the unitNames message has them; from (optional) |
Replace all of a system's own names for its radios, as setTalkgroups (a unit twice: the later row, in the first's place). Everyone gets them as unitNames; a recording names its calls' talkers by them at once. |
setUnitName |
system, unit (number), name |
Name one radio: its own row, before the patterns so it wins ("" takes its own row out, so a pattern may name it). Its origin is edited. Everyone gets it as unitNameEdited; a recording takes it at once. |
setTalkgroup |
system, talkgroup, edit: any of alphaTag, description, tag, category (text), ignore (true/false) |
Change one talkgroup's row: only the cells given (a row added when there's none and something is set). An edit that changes its names makes edited its origin. Everyone gets it as talkgroupEdited; a recording takes it at once. For an Ignore button or a name edit, rather than sending them all. |
channelFile |
index, path |
Link conventional system index's channels to a CSV, reload it (same path), or unlink (""). |
devices |
— | List RTL-SDR dongles (→ devices). |
findRadios |
— | Look for USRP / Airspy / SoapySDR devices, and ask the radios on the network the sources name (→ radios; takes a few seconds). |
listDir |
path ("" = home) |
List a folder on the recorder's computer (→ dir). |
readTrConfig |
path |
Read a Trunk Recorder config.json and its files, to import (→ trConfig). |
surveyStart |
source, radio (optional: a spare radio no source uses, to survey beside the recording), bands (ids from hello.surveyBands), ranges (optional: ranges of one's own, [{ loHz, hiHz }], Hz; neither: the bands on by default), findGain, lookFor (optional: just its sites' frequencies, freqsHz, sites[], type?, listenS?, the sites judged) |
Scan for systems with radio source (or radio), or look for one (not while recording, unless on a spare radio). |
surveyListen |
freqHz |
Monitor this signal. |
surveyRescan / surveyStop |
— | Scan again / end the survey. |
tuneGain |
source, and optionally systems[], protect, sliceS, settleS, rounds, maxSteps, margin, mode, try (a gain setting), apply, check |
While recording: tune radio source's gain by what its systems decode, following the plan for its kind (→ tune as it goes). Each candidate goes on the radio as a trial, never saved; at the end it goes back, or apply saves the best. check: only the plan (→ tune, phase planned), nothing changed. One at a time; stopping recording, or editing that radio, stops it. See trunk-pro tune. |
tuneStop |
— | Stop tuning: the radio goes back as it was. |
releaseRadio / resumeRadio |
source |
While recording: close radio source (its index in status.sources) so it can be swapped or looked at, the other sources recording on, or open it again at the centre and gain it had. To the engine a released radio is one gone quiet, as an unplugged one is. Not saved: Stop or the next Start takes it back. Radios only, not capture files or streams. status.sources[].released says which are. |
licenseQuery |
id, lat, lon, radiusM, signals[] of { freqHz, widthHz? } |
Who is licensed on these frequencies within radiusM (at most 150 km) of the location (→ licenseResult). The recorder sends the frequencies and the location to trunkrecorder.pro (server.trpApi); only when the user asks. |
callSignQuery |
id, callSigns[] |
Who holds these call signs (heard on the air), from trunkrecorder.pro, no location (→ callSignResult: id, results[] of { callSign, licensee, serviceCode, serviceDesc, status, city, state } for each active one, or error). |
profileSource |
source, centerHz |
Look at radio source's band for a couple of seconds, tuned to centerHz (a capture keeps its own), and measure how it rolls off at the edges (→ sourceProfile; not while recording). |
plugins |
— | List plugins again (→ plugins). |
addPlugin |
path |
Add a plugin executable of your own. |
removePlugin |
id |
Remove a plugin. |
interfaces |
— | List the interfaces again (→ interfaces). |
store |
kind (plugin or interface), refresh? |
A store's list (→ store). |
install |
kind, then id, or repository and tag? |
Install or update a plugin or an interface from its store or a GitHub release (→ installProgress as it goes). A new interface is served at once on the next free port. |
addInterface |
path |
Serve a folder on the recorder's computer as an interface. |
removeInterface |
id |
Stop serving it and forget it; an installed copy is deleted. |
subscribe |
topics |
What this connection watches (replaces the last): spectrum:<source>, log, log:<shortName>, rf:<source>, decode:<shortName>, platform, unit (→ subscribed). |
statsQuery |
id, series (names, or prefixes ending in *), range (10m / 1h / 6h / 24h / 7d / 30d / 90d / 1y) or from / to (Unix s), points? |
The history of series, averaged down to about points steps (→ statsResult). Up to a day (a week without a store) is answered from memory by the minute; further back (7d with a store, 30d, 90d, 1y, or an older from) is the store's hours, needs history in hello.capabilities, and its steps are whole hours or days, as far back as storage.statsDays keeps. |
radioQuery |
id, what, system?, key?, hours?, limit? |
The radio registry: summary, talkgroups, units, tg (key: the talkgroup), unit (key: the radio), freqs, lengths, tones (→ radioResult). hours (default 24) is how far back a row must have been heard; limit (default 500) is the most rows returned, up to the registry's cap (summary answers it as caps: storage.registryRadios, 20,000 by default; null for none, with days, storage.registryDays), so a limit of caps.radios is every radio heard. |
pluginAction |
id, plugin, action, value |
Press one of a plugin's buttons (its settings schema's x-actions) on value, the settings object it's on as edited (→ pluginActionResult, once the plugin answers). Control access; plugins run only while recording. |
callsQuery |
id, system? (short name), talkgroup?, unit? (a radio), from? / to? (start time, Unix ms: from inclusive, to exclusive), cursor? (the previous page's next), limit? (1 to 500, default 100) |
Recorded calls, newest first (→ callsResult). Talkgroup and radio numbers are a system's own: asked without system, each configured system's calls are searched. The desktop app answers from its call store with the latest calls included; the browser build from its own list. Listen-only connections may send it. |
unlockKeys |
source, password |
Open a key container that has no password file; the password is kept in memory only. keys follows. |
lockKeys |
source |
Forget a container's keys: its systems stop decrypting at once. |
createToken |
id, name (1–64 characters, not taken), access ("listen" or "control") |
Add a user with an access token for signing in, saved in server.auth.users (control access, signing in on or off). Answered with tokenCreated, its secret in it. |
iqCaptures |
id |
The radios' captures on disk (→ iqCaptures). Control access. |
iqCaptureStart |
id, seconds, note?, what?, problem? |
Record what (every radio by default; { kind: "radios" }, { kind: "control", site } or { kind: "call", system, talkgroup? }) to files, nothing sent anywhere: for seconds (every radio: 5 to 300; a control channel: 5 to 60; the next call: as long as it is), showing a problem (problem) or everything working (→ iqCaptures). |
iqCaptureCancel |
id, key |
Give up capture key, asked for and still waiting or running (→ iqCaptures). |
iqCaptureReview |
id, name |
What capture name would publish (→ iqCaptureReview). |
iqCaptureSend |
id, name |
Send capture name, reviewed, to the public corpus (→ iqCaptures). |
iqCaptureWithdraw |
id, name |
Withdraw capture name from the corpus (→ iqCaptures). |
iqRuleCheck |
id, rule |
Whether capture rule rule could run (→ iqRuleChecked). |
iqCaptureDelete |
id, name |
Delete capture name (→ iqCaptures). |
dataSummary |
id |
What the store keeps of each system (→ dataSummary). A table's CSV is GET /api/v1/export/{table}. |
deleteData |
id, kinds (of calls, talkgroups, unitNames, talkerAliases, registry, dashboardHistory), system? (its id; none: every system's) |
Delete these kinds of data from the store and from what the recorder holds; recordings stay on disk (→ dataDeleted). |
compactData |
id |
Give the space deleted data left in the store back to the disk (SQLite: VACUUM; PostgreSQL: VACUUM FULL); writes wait meanwhile (→ dataCompacted). |
quit |
— | Stop recording and exit the recorder. |
A listening-only interface needs nothing but listen (and subscribe and the queries). start and stop need "access": "control".
Live audio
After {"type": "listen", "on": true, "system": null, "talkgroup": null},
the recorder sends each call's audio as it's decoded, as binary WebSocket
messages:
| Bytes | Type | |
|---|---|---|
| 0 | u8 | version: 2 |
| 1–2 | u16 LE | system: the system's number this run (as in CallView.system; status.systems[].index) — map it to its short name |
| 3–6 | u32 LE | call id (CallView.id) |
| 7–10 | u32 LE | talkgroup |
| 11– | i16 LE … | samples: mono, 8000 per second |
function decode(buf) {
const v = new DataView(buf);
if (v.getUint8(0) !== 2) return null;
const samples = new Float32Array((buf.byteLength - 11) >> 1);
for (let i = 0; i < samples.length; i++) samples[i] = v.getInt16(11 + 2 * i, true) / 32768;
return { system: v.getUint16(1, true), callId: v.getUint32(3, true), talkgroup: v.getUint32(7, true), samples };
}Audio arrives in bursts (digital voice is decoded a fraction of a second at a
time), and calls on different talkgroups can interleave. To play it, queue
each chunk right after the previous one on an AudioContext, a little ahead
of currentTime. After a gap, start again a little ahead. To follow one call
at a time, keep playing the callId you started with until it goes quiet.
client.js's LivePlayer does all this; examples/scanner.html shows the
simplest version by hand.
Browsers only start audio after a click or key press: create or resume()
the AudioContext in a click handler. Listening is per connection and off
after a reconnect, so send listen again after hello.
Vocoder frames
With "voice": true in listen, digital calls (P25, DMR, NXDN, ProVoice)
also come as the vocoder frames their audio was made from, in a voice
message just before each audio chunk: chunk is the voice plugin topic's
chunk, as plugins get it. Add "audio": false for the frames alone. Analog
calls have none.
{"type":"voice","chunk":{"call_id":42,"system":0,"system_id":3,"short_name":"dcfd","talkgroup":101,"unit":1234,"unit_name":"E1","decrypted":false,
"frames":[{"codec":"imbe","bits":"a1b2c3d4e5f60718293a4b","e0":0,"errs":2,"erased":false,"kind":"voice"}]}}Each frame (VoiceFrame, a line of the voice.frames signal tap's sidecar too) is 20 ms:
codec (imbe: P25 Phase 1, ProVoice, 88 bits; ambe: AMBE+2 half rate,
P25 Phase 2, DMR, NXDN, 49 bits), its information bits after FEC as hex
(MSB first, the last byte zero-padded), the bit errors corrected (errs,
and IMBE's e0), erased when it was lost, what the vocoder made of it
(kind: voice, repeat, muted, erasure, tone) and an AMBE+2 frame's
tone. The talker is on each chunk, so a change of talker shows as the
next chunk's unit.
Recorded calls
The call store is a database of every recorded call, kept beside the config (trunk-pro.sqlite). callsQuery searches it by system, talkgroup, radio and time, as far back as it keeps calls (storage.retentionDays); history, GET /api/v1/calls and plugins' calls.query are the same query. Every answer includes the latest calls, the store's not-yet-committed ones too. hello.capabilities has calls while the store is open; when it's off, the same messages answer from the recent calls alone (callsResult.error says so).
Each recorded call's files are under the recordings folder at
CallEntry.path:
/calls/<path>.wav: the audio, 8 kHz mono/calls/<path>.json: the sameCallRecordthat came inconcluded/calls/<path>.m4a: when an .m4a was kept (recording.archiveM4a). The server falls back between the.wavand the.m4afor whichever exists
URL-encode each segment of the path:
path.split("/").map(encodeURIComponent).join("/"). An <audio> element can
play the .wav directly. Range requests are answered (206), so an <audio> element can seek; any other file under the recordings folder (or the RAM spool) is served too. The files can be deleted once the plugins are done
with them (recording.archiveWav and archiveM4a off), so older calls in the history
may have no files.
CallRecord is Trunk Recorder's call JSON, so tools written for Trunk
Recorder's files read it too. The fields you'll want most: talkgroup,
talkgroup_tag, short_name, start_time (Unix s), call_length (s),
freq, emergency, encrypted, srcList (the radios that talked, with
names in tag), and the reception fields signal / noise / snr (dB).
Beyond Trunk Recorder's: transmission_id (the same on every copy of one
transmission saved, above), end_reason (why it ended: terminator, squelch,
next_transmission, timeout, too_long, reassigned or stopped), site, system_id and site_id
(its system's and site's ids, the same across renames and runs), sites (every
site it was recorded on, { id, name } each, site first), system_type and
voice_mode, clean_voice_pct, nac (hex), color_code / ran,
talkgroup_ota (a conventional call's talkgroup as the air named it),
decrypted with algid / key_id, clock_off, and the call's in-band
tones, the tone_patterns they make up (each with text in words) and the
system's signals it carried. docs/guides/recordings.md lists every field.
The call store over HTTP
The same store answers plain HTTP GETs, for a plugin or an interface on
another machine that has no WebSocket to keep. Every door that serves the API
serves these (the built-in interface and each interface's port), to a
connection with listen or control access, as callsQuery is; a door that is
off answers 404. All answers are JSON. When the call store could not be
opened, GET /api/v1/storage answers 503 {"error": "the call store is off"}; the calls routes answer from the recent calls alone (below). (Plugins ask
over their own channel instead: calls.query, in the plugin SDK.)
| Route | Answers |
|---|---|
GET /api/v1/calls |
{ entries, next?, error? }, the page callsResult has: CallEntrys, newest first. With the call store off it answers 200 with the recent calls and an error, "the call store is off: only the recent calls". Parameters, all optional: system (short name; its sites' old names too), talkgroup, unit (a radio), from (start time, Unix ms, inclusive), to (exclusive), cursor (pass the last answer's next for the next page), limit (1 to 500, default 100). A parameter given empty counts as not given; a bad number answers 400 {"error": "<name> must be a number"}. |
GET /api/v1/calls/<path> |
One CallEntry: { path, record, audio, json, products? }, for the path its entry has (slashes stay slashes); 404 {"error": "no such call"} when there is none. With the call store off it answers a recent call if it has it, else 404. |
GET /api/v1/storage |
{ backend, path, schemaVersion, calls, oldestMs, newestMs, retentionDays, commitSeconds }: which backend (sqlite, postgres) and where the store is (a PostgreSQL database without its password), how many calls it holds and the start times of the oldest and newest committed (null when empty), and the settings storage.retentionDays and storage.commitSeconds. |
GET /api/v1/export/{table} |
A table as a CSV file (Setup → Data's Export), control access only: calls, transmissions, talkgroups, unit-names, talker-aliases, radios, heard-talkgroups or dashboard-history; ?system=<id> (the config's system id) for one system's. Times are local; it's named <system or all>-<table>-<date>-<time>.csv. dataSummary says what each system has, deleteData deletes it. |
The routes are described in calls.openapi.yaml (OpenAPI 3.0).
Recipes
Each recipe shows the raw protocol, then the client.js equivalent.
Show what's on the air. Redraw from each status: m.calls is the
complete list each time. A call with state: "recording" is being recorded.
With client.js: rec.calls, on change.
How long a call has been going. status.nowS - call.startS (both engine
seconds). With client.js: rec.status.nowS - c.startS.
A call log. Start from the history message and put each concluded.entry at
the front. It's the same shape either way. With client.js: rec.history.
Listen to one talkgroup. Send {"type": "listen", "on": true, "system": null, "talkgroup": 1234}. Add system when talkgroup numbers repeat across
systems. With client.js: rec.listen({ talkgroup: 1234 }). For several
talkgroups, listen to everything and drop the chunks you don't want.
Play new recordings one after another (no live audio needed): on each
concluded, queue /calls/<path>.wav, and play the queue with one <audio>
element. examples/talkgroup.html does this.
Change a setting. Take the latest config message, change it, and send
the whole object back with setConfig, with that message's version.
Then wait for the config message that everyone gets, and the configSaved
that answers you: if its error is set the edit wasn't taken (the config
changed elsewhere meanwhile: take the new one and make the change again).
Never build a config from scratch: fields you leave out are reset to defaults.
const next = structuredClone(config);
next.recording.minCallS = 2;
send({ type: "setConfig", config: next, version });
// client.js:
rec.setConfig((c) => { c.recording.minCallS = 2; });Start and stop. Send start / stop and draw from state. Don't assume
the command worked: error says why it didn't.
A talkgroup's name. In a call: alphaTag (live) or talkgroup_tag
(recorded). Otherwise, each system's talkgroup file comes in a
talkgroups message (Trunk Recorder's CSV format); change one with
setTalkgroups. With
client.js: rec.talkgroups(shortName).get(1234)?.alphaTag.
A radio's name. In a recorded call: srcList[].tag. Live: the user's
names come in a unitNames message for each system (then
unitNameEdited): rows of unit and name; a unit between slashes is a
regular expression whose groups ($1 or \1) may appear in the name
(/^1(\d{3})$/, Engine $1); the first matching row wins. The aliases heard on the air are in
the units message for the system (Trunk Recorder's unitTagsOTA CSV:
unit,alias,source,time,wacn,sys,tg, the newest line per unit wins), then
in the unitAlias messages. unitNames.mode says which to use:
"user" (the default) the user's name first, then the alias; "ota" the
alias first; "user_only"; "none".
With client.js: rec.unitName(shortName, unit).
Having an LLM build an interface
llms.txt (served at /api/llms.txt) is written for an LLM. It
covers what to build, how to deliver it, client.js, the data, the messages,
the rules that trip people up, and a template. Give it that, plus
protocol.ts for exact field names, and describe what you want:
Read llms.txt and protocol.ts (attached). Build me an interface for Trunk Recorder Pro: a single index.html, no build step, using /api/client.js. It should show the calls on the air in large text for a wall display: the talkgroup's name, the system, and how long it's been going, with emergencies in red at the top. Under it, list the last 20 recorded calls with a play button each. Add a toggle for live audio of one talkgroup, chosen from the talkgroups heard.
More ideas to ask for:
- A phone page: a big Listen button, the talkgroup now playing, skip and mute buttons for talkgroups.
- A daily summary: calls per talkgroup per hour, from
history, as a heatmap. - A monitor for one incident: a list of talkgroups to follow, live audio of those only, and a transcript-ready list of their calls with unit names.
- A status board for the recorder: each system's decode rate, each radio's dropped samples and frequency error, the recorder's load.
An agent that can run commands (Claude Code, for example) can do the whole loop:
- Make the folder.
- Run
trunk-pro --ui <folder>, or add the folder as an interface. - Open the address it prints (
http://localhost:8081/), check it, and iterate.
The recorder serves the files as they are on disk, so a reload shows each change.
Statistics and history
While recording, the recorder measures itself once a second and keeps the
last day of it in memory, a minute at a time (a week when the call store is
off); the call store keeps each series' hours for storage.statsDays (365 by
default). The live values come in stats (and host); the history answers
statsQuery. Each value has a name:
| Series | What |
|---|---|
src/<label>/noise, peak, clipPct, quiet |
A radio's noise floor (dBFS per FFT bin), its peaks (dBFS), the share of samples at full scale, and 1 while its samples are too small (gain may be low: the last minute's peaks under −30 dBFS on an 8-bit radio, −50 dBFS on others, and no call on it in the last day; absent otherwise) |
src/<label>/samples, dropped, errors |
Samples a second, samples lost a second, driver errors |
src/<label>/ppm, tune |
Its frequency error as measured on the control channels, and the correction applied (ppm) |
sys/<short>/cc/good, bad |
Control messages decoded / lost a second |
sys/<short>/cc/locked, snr, signal, noise, offset, sep, phaseErr |
Decoding (1/0), the channel's SNR and levels, its carrier offset (Hz), the C4FM receiver's eye opening, the CQPSK receiver's phase error (RMS degrees: under 10 clean, ~25 noise) |
sys/<short>/cc/syncs, nidFails, flywheels, eqResets |
P25 framing: syncs found, headers failed, frames carried over a missed sync, equaliser resets (a second) |
sys/<short>/cc/airSym |
P25: symbols of control channel air decoded a second; over 4800, the coverage |
sys/<short>/calls, airMs, audioBytes, active, recording, notSaved, dup |
Calls ending a second, airtime (ms a second, counted while the calls are on the air), audio written, calls on the air and being recorded now, calls not saved, duplicate copies dropped (a second) |
sys/<short>/notSaved/why/<why> |
Calls not saved a second, by why: silent, short, encrypted, writeFailed, noData; together, notSaved |
<site>/calls/started, recorded, skipped |
Each copy of a call, where it was heard: started, recorded, skipped (a second) |
<site>/calls/why/<reason> |
Calls not recorded a second, by why: ignored, unknownTg, encrypted, noSource, noRecorder, noFrequency |
<site>/notSaved/why/<why> |
Calls recorded there and not saved a second, by why: silent, short, encrypted (a write that failed is counted by its system alone) |
<site>/voice/<imbe|ambe>/frames, bad, errors |
Voice frames decoded, frames lost, bit errors corrected (a second) |
all/…, day/…, eng/… |
Every system together; this run's totals today; the decoder's load and recorders |
plat/cpu, proCpu, mem, memAvail, swap, memPsi, memLevel, temp, disk/<name>/free, freePct (the RAM spool's as disk/spool/…), … |
The computer (desktop app) |
net/up, rtt, dns, rx, tx, errors, probe/<target> |
Connectivity checks (share answering, connect time, each target's), name lookup time, traffic |
clock/synced, maxErrMs, offsetMs, delayMs, driftMs, radioMs |
The clock: synchronized (1/0) and the OS's error bound, the offset measured from the time server and its round trip, the recording's own clock's drift (call times are corrected for it), the radio systems' clocks against the calls' times |
plg/<id>/ok, failed, queued, latency, state |
Each plugin |
Running totals arrive as rates (per second); everything else as it is.
<label> is the source's label with / made _. <site> is sys/<short> for a
site named as its system (a system of one site), sys/<short>/site/<site> for the
others, and sys/<short>/ch/<Hz> for a conventional channel; the
sys/<short>/cc/… series are a site's too (<site>/cc/…). In a statsResult, v
is each step's average, lo / hi its lowest and highest minute, and n
the minutes measured in it — so a rate's amount over a step is v × n × 60.
The radio registry (radioQuery) is what the recorder has heard of each
system: talkgroups (first and last heard, calls and airtime by hour, whether
in the talkgroup file or ignored), radios (transmissions, affiliation, the
talkgroups they use, the radios heard with them), and each frequency's voice
quality and calls out of band (freqs: rows, the frequencies with a call
recorded; outOfBand, those granted calls no source covered). It is kept in the call store between runs (storage.registryRadios and storage.registryDays bound it); with the store off it isn't kept.
Compatibility
protocol.ts is the definition. The recorder's tests check what it actually
sends against the schema generated from protocol.ts: every message type in
both directions, and the shapes of the main messages (hello, status,
concluded, config, the survey's, the plugins'…). So this page and the
types stay true to the recorder you're running.
The protocol can grow: new message types, new fields. Write clients that
ignore what they don't know. Fields may be removed or renamed between
versions; the changes are noted in CHANGELOG.md. hello.version (or
GET /api/version) says which version you're talking to, and hello.api
(/api/version's api) the interface API version an interface.json's
api is checked against: an interface that needs a newer one isn't
installed.
spectrum and the control channel log lines come only to
connections that subscribe to them.
The browser version of Trunk Recorder Pro (WebAssembly, no server) speaks the same messages between its page and a worker, but has no network API for other pages to use.