vsergeev/radfly
An SDR-based listening server for AM medium wave and shortwave radio stations built with Zig
master
master
radfly is a self-hosted, SDR-based listening server for AM medium wave and short-wave radio stations with a simple web frontend. radfly is built on ZigRadio and http.zig, and currently supports rtl-sdr and AirSpy HF+ SDRs.
The web frontend streams audio, supports scanning, bookmarks, and configuring options like audio bandwidth and AGC mode. radfly can be run on Raspberry Pi 4 and similar single-board computers.
radfly requires Zig version 0.14.
$ git clone https://github.com/vsergeev/radfly.git
$ cd radfly
$ zig build
Install optional (but recommended) acceleration libraries:
sudo apt install -y libvolk-dev libliquid-dev libfftw3-dev
on Debian-based systemssudo pacman -S libvolk liquid-dsp fftw
on Arch Linux-based systemsStart radfly with an SDR source, e.g. mock
(for testing), rtlsdr
, or airspyhf
:
$ ./zig-out/bin/radfly --source airspyhf
radfly will be accessible at http://localhost:8000
.
Due to the dependency on AudioWorklet for streaming audio in the browser, the radfly frontend must be served over a secure context (HTTPS) to be accessed by other machines on a local network. Caddy can be used as a secure reverse proxy for this.
Start caddy
(replace radio-pi4
with your machine's hostname):
$ sudo caddy reverse-proxy --from radio-pi4.local --to :8000
radfly will now be accessible on the local network at https://radio-pi4.local
.
caddy
uses self-signed certificates for *.local
hostnames, which can't be
trusted automatically by browsers and results in an insecure connection
warning. To remove this warning, import caddy's generated root certificate,
located at /root/.local/share/caddy/pki/authorities/local/root.crt
, into your
browser's certificate manager.
Usage: radfly [options]
Radio Configuration
--source <mock,rtlsdr,airspyhf> SDR Source (default mock)
--bias-tee <true/false> Bias tee (default false)
--tune-offset <value in KHz> Tune offset (default 50 KHz)
--initial-frequency <value in KHz> Initial frequency (default 5000 KHz)
Server Configuration
--http-port <port number> HTTP listening port (default 8000)
--http-address <address> HTTP listening address (default 127.0.0.1)
Miscellaneous
--help Display usage
--version Display version
--debug Enable debug mode
The ZigRadio flowgraph consists of audio demodulation and power measurement
signal chains that feed into their respective ApplicationSink
. Audio and
power samples are consumed by an application thread and pushed to active
clients via WebSockets. An RPC protocol over WebSockets allows clients to scan,
tune, and change various parameters in the flowgraph.
flowchart LR
A[Source] --> B[TunerBlock]
B --> G[LowpassFilterBlock]
subgraph s2 [Power Measurements]
G --> H[PowerMeterBlock]
H --> I[ApplicationSink]
end
B --> C[AMEnvelopeDemodulator]
subgraph s1 [Audio]
C --> D[AGCBlock]
D --> E[DownsamplerBlock]
E --> F[ApplicationSink]
end
Run unit tests with:
$ zig build test
radfly is MIT licensed. See the included LICENSE file.