Skip to content

Radio bridge

A bridge holds one outbound WebSocket to the server, and you can run any number of bridges. The code lives in the shackworks-bridge repository, in scripts/ and windows-app/.

Edition Notes
scripts/flex-bridge.ps1 PowerShell 5.1, with nothing to install. The Windows app replaces it.
scripts/flex-bridge.mjs Node 22, with a Hamlib backend. The Windows app replaces it.
windows-app/ Avalonia on .NET 10. It supports Flex and Hamlib radios and is replacing the scripts.

The scripts share a config.json with the keys app, token, radio, name, bind, backend and hamlib. scripts/sim-radio.py simulates a Flex radio.

Flex. The bridge finds the radio by UDP discovery on port 4992, subscribes over SmartSDR’s TCP API and reports the transmit slice. With bind: "auto" on v3 firmware, it follows the first GUI client that is not a bridge. A tune runs slice tune and slice set mode=, and the mode is USB above 10 MHz and on 60 m, otherwise LSB. The radio link and the server link reconnect independently, and a lost radio shows as disconnected rather than stale.

Hamlib. The bridge talks to rigctld, a separate program, because Hamlib is LGPL. It polls f and m, because rigctld does not push changes, and tunes with F and then M. The Hamlib mode PKTUSB and its relatives map to DIGITAL. The radio’s id is stored as transmitter_id. scripts/hamlib.mjs and windows-app/Core/HamlibRadio.cs implement the same behavior, and both are tested against a fake rigctld.

Project Role
Core/ The Flex and Hamlib clients, the server link (key header, backoff, state replay), the WSJT-X listener, the operator desk, the uploader and the engine.
Core.Tests/ xUnit tests with a fake radio, a fake rigctld and a fake server, plus an opt-in end-to-end test.
BridgeApp/ The window. It stores keys with DPAPI encryption.
PolicyTest/ Checks whether a locked-down PC permits an unsigned app.

Both radio clients implement IRadio, and BridgeEngine runs whichever one the selected radio needs.

The operator desk decides who owns a WSJT-X contact: the chosen operator, a queue, clearing after an idle period, then asking, then Unknown. A contest contact takes its exchange from WSJT-X plus the contest’s defaults, and the app holds a refused contact for correction. Builds are unsigned and must ship as a folder, because a single-file build unpacks to %TEMP%.

server/realtime/radio.ts authenticates the bridge key in constant time on /api/radio/bridge.

  • Identity. radioKey() in shared/radios.ts uses the radio’s id if the bridge sends one, otherwise the model, nickname and IP. A bridge appears in the list once it has reported a radio.
  • Replacement. A second connection for a radio that is already connected replaces the older one, because the old socket may not yet be known to be dead. This covers a bridge restart.
  • Lost radio. A radio the bridge reports as lost stays listed under its last name with nothing tuned.
  • Names. radioName() returns the nickname, or the model if there is none, and adds the address to duplicates.
  • The radio topic. It carries {type:'radios', radios}, where each entry is {key, name, detail, state}, and a new subscriber gets the whole list.
  • Radio choice. The choice belongs to the browser (web/src/lib/radioChoice.ts and useRadio()) and is never server state. tune, verify_start and unlock name the radio. A client may omit the name while exactly one radio is connected. With several, the server answers Choose a radio first.
  • Liveness. The server pings each bridge and drops only one that stays silent, within about 12 seconds. It does not await close, and it does not rebroadcast identical states.
  • Tunes. Each tune gets a server-unique id. An ack reaches only the requester, and only when it comes from the bridge that was asked.
  • Challenge and unlock. Both are per socket and per radio. See Authentication and roles.

server/routes/bridge-api.ts implements the REST interface, which the Bridge API page documents. Bridge contacts deduplicate on call, band, mode and minute, and the audit log records them with a null actor and source: bridge.

In the shackworks repository, npm test covers the protocol on the server side. In the bridge repository, npm test covers the Hamlib script, and cd windows-app/Core.Tests && dotnet test runs the app’s tests.

For an end-to-end run, start the server from a shackworks checkout with a bridge key and start scripts/sim-radio.py. Then run the opt-in EndToEnd tests with BRIDGE_E2E_URL, BRIDGE_E2E_KEY and BRIDGE_E2E_RADIO_PORT set. A protocol change touches server/realtime/radio.ts, both script editions and Core/.