Commit Graph
471 Commits
Author SHA1 Message Date
ew8bakandClaude Opus 4.8 6b695ce756 feat: unify sample-rate presets across desktop + web UIs
Sample-rate (span) presets were duplicated in three places and none was
authoritative: HPSDR set hardcoded in the desktop overlay (SPAN_RATES),
Pluto set in backend caps, and a separate hardcoded list in the web JS.
The web showed HPSDR rates even on Pluto, and the web adapter silently
dropped any rate outside a hardcoded HPSDR whitelist (so Pluto-only rates
like 960k/2304k never switched).

Single source of truth = backend caps -> controller:
- HPSDRNetwork.Caps now fills RatePresets [48k..1536k] (was nil).
- RadioBackend: named type TBackendRateArray.
- TRadioController.SampleRatePresets returns BackendCaps.RatePresets.

Both UIs derive from it:
- Desktop: ApplyBackendCapsToUI always feeds the overlay from
  SampleRatePresets (overlay no longer owns the HPSDR list).
- Web: WebServer.SetRatePresets + rate_presets in state JSON; hosts
  (daemon OnState/startup, GUI ApplyBackendCapsToUI/startup) push
  SampleRatePresets; JS builds span buttons dynamically from it.
- WebAdapter.SyncSpan validates against SampleRatePresets instead of a
  hardcoded whitelist, so any backend rate is accepted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 13:52:03 +03:00
ew8bakandClaude Opus 4.8 d78d835485 feat: Pluto support in headless daemon (connect/autostart/discover/dev_add) + headless audio
The headless daemon (ewsdrd) only ever built HPSDR devices, so Pluto
could not be used: backend is chosen by Dev.Kind and Pluto opens by URI,
neither of which the daemon propagated. Also local audio played on the
host and web Discover never probed network Plutos.

Shared, backend-agnostic helpers in TRadioController (used by GUI + daemon):
- ResolveDevice(IP): discovered->saved lookup restoring Kind/URI/Serial/
  BoardType/MAC. MainForm.ResolveDevice now delegates here.
- AddSavedDevice(name, addr): web dev_add saves Pluto when addr has a URI
  scheme (ip:/usb:/local:), else HPSDR. Both web hosts use it.
- SeedPlutoProbeFromSaved: seed network-probe URIs from saved Plutos
  (no mDNS -> a network Pluto is only found by direct URI probe).
- LocalAudioEnabled flag (GUI=True): when False the local sound card is
  neither opened nor written; RX audio goes only to web (OnAudioConsume).

DeviceStore.AutoStartDevice(out Dev): full autostart record (Kind/URI/
Serial) so a saved Pluto (URI-addressed, empty IPAddress on USB) can
autostart.

Daemon (ewsdrd.lpr): LocalAudioEnabled:=False; SyncConnect via
ResolveDevice; autostart via AutoStartDevice; SyncDiscover seeds probe
URIs then Discover; SyncDevAdd via AddSavedDevice.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 13:32:05 +03:00
ew8bakandClaude Opus 4.8 3115b2b5bf feat: add LO Error field to QO-100 settings tab
Expose the QO-100 slot's LOError (Hz) on the QO-100 settings page,
placed right after LNB LO. Maps to Entries[QO100_SLOT].LOError — the
live LNB-drift calibration that the beacon lock folds its correction
into. Group height extended to 8 rows and the info label shifted down.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 12:06:07 +03:00
ew8bak 0906f854fb Merge feature/qo100-decoder-lock: decoder-based QO-100 beacon lock
Replace the display-FFT centroid beacon lock with a decoder-based loop that
trims the active transverter's LOError from the beacon decoder's precise NCO
carrier estimate, compensating LNB drift so the whole downlink (incl. FT8)
stays put. Single BEACON button (lock = decoder). Also unifies the beacon
decoder filter marker between the CPU and OpenGL spectrum renderers.

Verified on air: lock holds, FT8 decodes cleanly.
2026-06-22 22:14:35 +03:00
ew8bakandClaude Opus 4.8 3f0e4204c2 fix: unify beacon decoder filter marker (CPU matches GL)
The narrow beacon decoder filter marker rendered differently in the two
spectrum views: CPU drew a translucent filled band (BlendBand) plus a centre
line, while OpenGL drew three plain vertical lines (both edges + centre), so
it looked like one band on CPU and "two parts" on GL.

Make the CPU path draw the same three lines as GL — consistent look and
cheaper (drops the per-frame per-pixel alpha blend for this marker; BlendBand
is kept for the RX/TX passband shading).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 22:06:44 +03:00
ew8bakandClaude Opus 4.8 6246b6bad4 feat: QO-100 decoder-based beacon lock (replace FFT lock)
Replace the display-FFT centroid beacon lock with a decoder-based loop.
The beacon decoder already tracks the carrier precisely via its NCO
(squaring-FFT acquisition + Costas offload); its residual ResidHz+CarFreqHz
is an exact measurement of the beacon's offset from the aim point. Feed that
into LOError of the active transverter so the LO retunes to compensate LNB
drift — the whole downlink stays put, calibration persists.

RadioController:
- Remove MeasureBeaconFFT and all display-FFT lock state/constants
  (lobe/search/track/slew/sym/shape/seed-gain/prom), fields
  FBeaconManualSeed/FBeaconPromDB/FBeaconDecOn, methods
  SetBeaconDecode/SetBeaconDecodeAtHz/BeaconDecodeEnabled.
- SetBeaconLock is now the master switch (lock = decoder); BeaconSeedAtHz
  aims the decoder; ServiceBeaconLock measures beacon freq from the decoder
  scope and trims LOError (gain 0.5, deadband 20 Hz, step clamp 400 Hz,
  settle 8 ticks). Feed-forward of the aim keeps the decoder locked through
  the retune (net baseband ~0). Lock/SNR now come from the decoder.

MainForm: single BEACON button — left-click toggles lock (+ opens the
constellation/bulletin scope, arms the spectrum click for aiming),
right-click shows/hides the scope. Spectrum click (armed or Shift) aims via
BeaconSeedAtHz. Simplified status field and markers.

Both targets build (lazbuild --ws=qt6 + build-ewsdrd.sh). Not yet verified
on air. Risk: BEACON_RESID_SIGN=+1.0 — flip to -1.0 if the loop runs away.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 19:51:01 +03:00
ew8bak 59338b2d04 Merge feature/qo100-beacon-decode: QO-100 central beacon decoder (BPSK 400 / AO-40 FEC → bulletin text)
M1: stable BPSK demod. M2: AO-40 FEC decode end-to-end (libfec). Phase C:
decode 256-byte frame as ASCII bulletin (CRC), display in BeaconScopeForm.
2026-06-22 11:26:38 +03:00
ew8bakandClaude Opus 4.8 37eb8065d6 chore: remove QO-100 beacon decoder debug instrumentation
After successful on-air validation, drop the temporary diagnostics:
- IQ baseband dump to ~/ewsdr_beacon_iq.f32 (FDbgStream/DbgWrite2).
- BeaconLog file logger (~/ewsdr_beacon.log) and per-second STATE / AIM lines.
- Dead Gardner timing fields (FMidI/FMidQ/FHalf/FPrevI/FPrevQ), superseded by
  the ML signal×slope TED.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 10:45:52 +03:00
ew8bakandClaude Opus 4.8 8e4106b822 feat: QO-100 beacon bulletin text display (Phase C)
Decode and show the AO-40 frame payload as text in the beacon scope window.

- RadioController.GetBeaconFrame exposes the latest 256-byte frame.
- BeaconScopeForm: poll the frame counter; on each new frame, parse the
  payload (drop trailing 2-byte CRC, printable ASCII, 64-char lines, as in
  gr-satellites qo100.parse) and append to a scrolling read-only memo.
- Window widened/heightened; constellation size capped to leave room.

Frame format verified offline against a real on-air capture: the decoder
produces the live QO-100 AMSAT bulletin text (RS errors=0).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 10:30:36 +03:00
ew8bakandClaude Opus 4.8 afc8775ddb feat: QO-100 beacon AO-40 FEC decode end-to-end (Milestone 2)
Full chain now decodes the QO-100 central beacon to 256-byte AO-40 frames
on-air (frames>0, RS errors=0). Builds on M1 (stable BPSK demod).

FEC backend (BeaconFEC.pas, TBeaconFEC):
- AO-40 FEC: distributed sync (65 bit, step 80) -> 80x65 deinterleave ->
  Viterbi r=1/2 k=7 -> CCSDS descramble -> 2x RS(160,128). Links system
  libfec (Karn) load-time (libfec.so/.dll/.dylib). Viterbi AO-40 [0x4F,-0x6D]
  remapped to libfec [0x6D,0x4F]. Validated against gr-satellites reference
  vectors (fectest2: exact 256-byte frame, 0 mismatches).

DBPSK Manchester frontend (BeaconDecoder.pas):
- Chip-rate (800) processing: RRC matched filter -> ML signal-times-slope
  timing recovery -> Costas -> Manchester combine (block phase select) ->
  differential decode -> soft symbols to FEC.
- Carrier acquisition: squaring-FFT estimates the residual (carrier at +-pi/chip
  defeats decision-directed Costas), one-shot pulls it to DC via residual NCO.
- Costas frequency offload into pre-RRC NCO (with deadband) tracks LNB drift
  without hitting the +-pi Costas clamp.
- ML TED replaces Gardner, which degenerates on the Manchester chip stream.

Temporary on-air diagnostics retained (IQ dump + STATE log) pending wider
signal validation; to be removed before final cleanup.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 10:21:33 +03:00
ew8bakandClaude Opus 4.8 c063d7a197 feat: QO-100 central beacon BPSK decoder (Milestone 1 — stable demod)
Декодер центрального маяка QO-100 (10489.750, AO-40 BPSK 400 бод): фронтенд
до мягких символов + констелляция, с устойчивым захватом несущей/символа.

Цепочка (BeaconDecoder.pas): NCO-снос смещения → boxcar-децим до 9600 →
RRC матч-фильтр → AGC-нормировка → Gardner timing → Costas BPSK с frequency
offload в пред-RRC NCO. squaring-FFT оставлена индикатором несущей (prom).

Ключевые решения по итогам эфирной отладки:
- invert=True для тракта QO-100 (LNB+трансвертер зеркалит спектр).
- Декодер развязан от beacon-lock (тот ретюнил железо, рвал IQ).
- AGC-нормировка петель: сигнал ~-60 dBFS замораживал Costas/Gardner.
- Frequency offload: накопл. снос Costas стекает в FResidInc (без потолка
  ±π/символ) → держит ошибку наведения (1пкс≈300Гц) + дрейф LNB.

Интеграция: тап IQ в WDSPEngine.PushIQItemToDSP; RadioController владеет
декодером, клик-наведение (ПКМ BEACON + ЛКМ/Shift+ЛКМ по спектру); узкий
фильтр-маркер в SpectrumView/GL; окно констелляции BeaconScopeForm; файловый
лог HOME/ewsdr_beacon.log для диагностики.

Milestone 2 (далее): FEC — Viterbi k=7 + RS(160,128) + интерливер + дескремблер.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-21 18:15:00 +03:00
ew8bakandClaude Opus 4.8 28adf9508a chore: bump build number / widget-type macro count (ewsdr.lpi)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 22:52:17 +03:00
ew8bakandClaude Opus 4.8 c849058d36 fix: DUP button state consistent with QO-100 auto-duplex
The DUP toggle wrote FDisplayDuplex directly, bypassing the controller's
SetDuplex (which also sets KeepRXDuringTX live and fires rfDuplex). And
MainForm had no rfDuplex render case, so QO-100 auto-enabling duplex
(ActivateXvtr → SetDuplex) left the button unlit while FDisplayDuplex=True
— pressing DUP then turned it OFF when the user expected ON.

Single path now: ApplyDUP just calls SetDuplex; a new rfDuplex render case
styles the button and (when transmitting) switches the display source.
Both the button and QO-100 auto-enable go through it, so the button always
reflects state and KeepRXDuringTX stays in sync.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 22:42:41 +03:00
ew8bakandClaude Opus 4.8 17d0af4910 docs: update Pluto integration plan for recent TX fixes
Document the TX-path work landed this session:
- §4.6: polyphase FIR interpolator + sample-rate-scaled TX buffer +
  SoapyPlutoSDR confirmation of 32768 full-scale.
- §4.8 (new): power-linear drive→atten mapping, full WDSP digital level,
  TX LO powerdown gated by PTT.
- Phase 4 status updated.
- Related fixes: per-band FM settings (SQL/CTCSS/step/repeater) restore on
  startup — was dropped by LoadDevice; affects all backends.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 22:08:45 +03:00
ew8bakandClaude Opus 4.8 ff331fa2a0 feat: Pluto TX LO powerdown gated by PTT
TX LO (altvoltage1) is now powered down on RX and enabled on PTT, instead
of staying on continuously. Removes the TX carrier leakage that showed up
at the VFO frequency in the RX spectrum (and persisted after MOX), and
stops idle TX-LO radiation. ApplyTxLO sets powerdown from FTransmitting,
which also recovers the LO if external software (e.g. SDR Console) left it
powered down. RX LO (altvoltage0) is kept on — receive is continuous; QO-100
full-duplex still works (RX LO separate).

Trade-off: re-enabling the TX LO re-runs the AD9361 synth calibration
(a few ms), so the first syllable on SSB may be slightly clipped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 22:07:06 +03:00
ew8bakandClaude Opus 4.8 2ab1f4f9ac fix: restore per-band FM settings on startup (SQL/CTCSS/step/repeater)
LoadDevice (bulk startup band loader) parsed only freq/mode/filter/AGC/
CTun/center/span and skipped the FM fields, while SaveBand writes them and
LoadBand reads them. So FM squelch, CTCSS, step and repeater shift were
saved on exit but reset to defaults on the next start (band switching kept
working — that path goes through the in-memory band cache, not disk).

Added the missing fmsq_on/fmsq_level/ctcss_on/ctcss_idx/fmstep_on/
fmstep_idx/fmrpt_dir/fmrpt_offset reads to LoadDevice, mirroring LoadBand.
Affects all backends, not just Pluto.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 21:31:38 +03:00
ew8bakandClaude Opus 4.8 09c9109491 fix: Pluto TX drive mapping — power-linear + full digital level
TUN produced no tone: TUNLevel default 10% mapped via the old dB-linear
attenuation curve (−89.75..ceiling) to −81.8 dB → effectively off. Now
power-linear: dB = ceiling + 20*log10(pct/100), so 10%→−30, 50%→−16,
100%→ceiling — usable across the whole slider.

Also keep WDSP digital level at full-scale for Pluto (ApplyWDSPDrive):
power is set once via hardware attenuation, not by scaling the WDSP path.
HPSDR unchanged (drive byte still drives the radio PA).

Note: at a given slider position Pluto TX is now much hotter than before
(50%: −49.9→−16 dB). Ceiling stays PlutoTxMaxAttDb (default −10 dB).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 21:20:57 +03:00
ew8bakandClaude Opus 4.8 be684545c8 feat: Pluto TX polyphase FIR interpolator (anti-imaging)
Replaced linear interpolation upsampling (192k→device-rate) with a
polyphase FIR interpolator ×L. Prototype: windowed-sinc lowpass (Blackman,
~-58 dB sidelobes), TAPS*L long, cutoff TX_FIR_CUT=40k, normalized to unity
per-phase DC gain (loudness unchanged). Images at multiples of 192k are now
suppressed ~-58 dB instead of only sinc², cleaning up the uplink spectrum.

BuildTxResampler designs coefficients per FTxRatio in StartTX; FTxDlI/Q
delay line persists across SendDUCIQ calls, reset on StartTX/ClearDUCIQQueue.
Removed FTxPrevI/Q.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 20:25:52 +03:00
ew8bakandClaude Opus 4.8 071ffa476d fix: Pluto TX buffer scaled by sample-rate (SoapyPlutoSDR model)
Fixed 4096-pair TX buffer was too small for full-duplex above ~1 Msps
("not enough ... samples getting dropped" per SoapyPlutoSDR), causing
clicks/dropouts. Now sized as round(rate/60) rounded up to a power of 2,
clamped [4096..65536] (576k→16384, 1536k→32768). FIFO cushion (~4 buffers)
resizes to match in StartTX.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 20:20:41 +03:00
ew8bakandClaude Opus 4.8 3fe5cf3fad feat: QO-100 mode — separate RX/TX LO + dedicated settings page
QO-100 reuses the transverter path (VFO/band-stack/beacon-lock untouched)
with a split LO for the geostationary transponder:
- TXvtrEntry += FullDuplexTx + TxLOOffset (persisted). Reserve the last
  XVTR slot (QO100_SLOT) for QO-100; migration restores the template when
  the slot is unset or has empty offsets (fixes old configs showing zeros).
- XvtrTranslateTX: TX LO = visible - TxLOOffset (no LNB LOError) for QO-100;
  identical to RX translate for normal transverters. Switched all TX-side
  translate calls (controller + MainForm).
- SetDuplex wired (live KeepRXDuringTX); auto display-duplex on QO-100 entry.
- New "QO-100" settings page (LNB LO / transponder offset / downlink edges /
  RX gain / TX ceiling + live RX-IF/TX readout); QO slot hidden from the
  transverter table. Reuses OnXvtrChange — no MainForm wiring needed.
- doc/PLUTO_INTEGRATION_PLAN.md: phase 5 done.

Builds clean (headless + qt6 GUI). Not yet verified on hardware.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 15:30:23 +03:00
ew8bakandClaude Opus 4.8 c6660891c0 feat: drive slider value label — % (openHPSDR) / dB (Pluto)
Show current drive value next to the slider: percent for openHPSDR,
TX attenuation in dB for Pluto (via controller PlutoTxAttForDrive;
unit flips on backend connect). Refreshed on drive change, device
render, and TX max-att change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 14:50:39 +03:00
ew8bakandClaude Opus 4.8 d08fc17056 feat: Pluto TX path — attenuation-based power, full-duplex IQ stream
TX path for Pluto/AD936x (RX was already working):
- PlutoBackend: continuous full-duplex TX stream (cf-ad9361-dds-core-lpc)
  with FIFO + push thread; SendDUCIQ upsamples WDSP 192k -> device rate
  (integer, linear interp), 24->16 bit, Q inverted; zeros on underrun.
- Power via output attenuator (ADI-recommended): SetTxAtten writes
  hardwaregain on voltage0(out). Controller maps drive% -> dB
  (PlutoTxAttForDrive/ApplyPlutoTxAtten); -89.75 dB on RX (~off),
  ceiling PlutoTxMaxAttDb on 100% drive.
- Configurable max-att (default -10 dB, ADI-linear) for external amp:
  persisted in global settings, UI spin on PA page, routed through
  controller SetPlutoTxMaxAtt (UI stays decoupled from logic).
- RadioBackend: virtual SetTxAtten (no-op for HPSDR).
- Update doc/PLUTO_INTEGRATION_PLAN.md: phases 3/4/5 + risks.

Builds clean (headless + qt6 GUI). Not yet verified on hardware.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 12:27:49 +03:00
ew8bakandClaude Opus 4.8 1321e415f7 feat: Pluto board name + hardware telemetry in status bar
- Status bar / web now show Pluto/LibreSDR model + serial instead of
  "Unknown Board" (BoardDisplayName in controller; UI just renders it).
- Field 3 shows AD936x chip temperature + RX RSSI for Pluto (no PA →
  Supply only for openHPSDR). Polled via backend.ReadTelemetry (~2 Hz),
  filtered for sensor glitches (plausibility window + slew-limit, with
  anti-stick) — fixes rare bogus -15°C readings.
- Add libiio binding iio_channel_attr_read_double.
- Remove stale root pluto_integration.MD (superseded by
  doc/PLUTO_INTEGRATION_PLAN.md).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 11:31:27 +03:00
ew8bak 4d253909ca Merge feature/qo100-beacon-lock: QO-100 beacon lock (LNB drift stabilisation) 2026-06-19 10:09:11 +03:00
ew8bakandClaude Opus 4.8 4728e02459 feat: QO-100 beacon lock — robustness, persistence, FT8-aware UI
Builds on the beacon-lock baseline: keeps the proven display-FFT control
path (hardware-LO trim folded into the active transverter LOError), and
hardens it. The narrowband NCO/FLL scaffold (BeaconLock.pas) is removed —
it was never in the control path.

- RadioController:
  * Persist live: each correction folds straight into the active xvtr
    LOError (visible in Settings, survives restart as LNB calibration);
    disk writes throttled. FBeaconLockHz is now only a session indicator.
  * Robust tracking vs nearby signals: narrow ±2 kHz gate while locked
    (±6 kHz only for acquisition), slew-rate outlier rejection (a sudden
    centroid jump = interferer, not slow LNB drift → ignored), and lobe
    shape validation in MeasureBeaconFFT (width + power symmetry) so a CW
    carrier / one-sided neighbour isn't mistaken for the BPSK beacon.
    Prominence measured over the in-window noise floor (gate-width robust).
  * Fast convergence: feed-forward (predict post-retune position so the
    window follows the beacon through the jump) + near-deadbeat correction
    on the manual click → one click locks instead of repeated tapping.
  * Single central BPSK beacon (10489.750); dead CoarseBeaconOffset and
    unused throttle counters removed; stale NCO/FLL/4 Hz comments fixed.
- WDSPEngine: drop the per-sample TBeaconTracker RX-IQ tap (tracker gone).
- MainForm: BEACON is now a plain button, shown only on Pluto in a
  transverter. Lock status (off / click / search / LOCK + correction +
  prominence) moves to status-bar field 7 in place of PLL on Pluto;
  openHPSDR keeps PLL there.
- SettingsForm/StatusBar: widen LO Error field to ±10 MHz (QO-100 LNBs
  drift hundreds of kHz) and widen status field 7 for the beacon text.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-19 10:02:48 +03:00
ew8bak 3b09c909bc Merge feature/qo100-beacon-lock: QO-100 beacon lock (LNB drift stabilisation) 2026-06-18 11:04:23 +03:00
ew8bakandClaude Opus 4.8 42610b304e feat: QO-100 beacon lock — stabilise LNB drift to NB transponder beacon
Click the beacon on the spectrum; the controller tracks it and continuously
trims the transverter LO so the whole downlink stays put as the LNB drifts.

- BeaconLock.pas: TBeaconTracker scaffold (narrowband NCO/FLL) — kept but no
  longer in the control path (FLL diverged on the suppressed-carrier BPSK
  beacon + Pluto DC offset). Measurement now uses the proven display-FFT path.
- RadioController: FBeaconLockHz folded into XvtrTranslate (on top of LOError).
  MeasureBeaconFFT finds the beacon by POWER-WEIGHTED CENTROID of the lobe
  (BPSK has a suppressed carrier → broad symmetric ~2.4 kHz lobe, not a line;
  a peak-finder jitters, the centroid sits on the carrier). Track position in
  ABSOLUTE display Hz (FBeaconTrackHz) so scrolling the waterfall/centre never
  moves the search window off the beacon. Closed loop: e = tracked - ref,
  d(e)/d(LockHz) = -1 -> LockHz += gain*e; settle cooldown after each correction
  (display-FFT lags the LO retune -> avoids overshoot); deadband 75 Hz +
  centroid/prominence smoothing + lock hysteresis for a steady lock.
  Correction applied only after the user clicks (manual seed), so a crowded
  band can't pull a neighbour to the reference.
- WDSPEngine: SetBeaconTracker + RX-IQ tap (tracker idle now, ~1 check/sample).
- SpectrumView + GL: beacon markers — green = reference (10489.750), orange =
  tracked centroid.
- MainForm: BEACON button (RX block, XVTR-only). Flow: BEACON -> "CLICK BCN"
  -> click beacon -> "L<corr> /<prom>". ServiceBeaconLock driven by MeterTimer.

Reference defaults to the middle BPSK beacon 10489.750. Tested on-air against
Es'hail-2: locks and holds, survives waterfall drag.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 11:04:14 +03:00
ew8bakandClaude Opus 4.8 40dca01c40 fix: persist CTun center + save VHF/UHF bands (Pluto); QO-100 transverter template
CTun position was lost on band restore / restart, and VHF/UHF bands were
never saved on Pluto.

- SaveCurrentBand: the >61 MHz guard (HPSDR HF-only) skipped saving native
  Pluto VHF/UHF bands → 2m/70cm reverted to defaults. Now HPSDR-only; Pluto
  saves VU-plan bands (FreqToBandIdx guards cross-band pollution).
- Persist DDC center for CTun: new TBandSettings.CenterHz (+ JSON center_hz)
  and TXvtrEntry.LastCenterHz (+ last_center_hz). RestoreBand / ActivateXvtr
  restore the saved center when CTun is on and the offset fits the span,
  instead of forcing center := VFO (which re-centered the receiver).
- UpdateFreqDisplayMax: freq-display upper bound from active transverter's
  FreqEnd (lets QO-100 show 10 GHz past the 6 GHz Pluto cap).
- QO-100 transverter template (slot 2, disabled): downlink 10489.5–10490.0,
  LO 9750. MigrateXvtrTemplate injects it into the first free slot for
  devices that already have a saved xvtr config (template was otherwise
  masked by the loaded slots).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 22:02:01 +03:00
ew8bakandClaude Opus 4.8 24f74357cd feat: Pluto RX hw-gain control + AD9361 cold-init (FIR via libad9361)
- RX hw-gain (Pluto/AD936x): backend SetRxGain(ModeIdx, GainDb) — gain_control_mode
  (manual/fast_attack/slow_attack/hybrid) + hardwaregain. Controller FRxGainMode/
  FRxGainDb, commands SetRxGainMode/SetRxGain/RxGainBy, rfRxGain event, snapshot,
  applied in StartRunning. Persisted per-device (rx_gain_mode/rx_gain_db). HPSDR
  unaffected (backend no-op).
- UI: separate "RF AGC" panel below the (unchanged) WDSP AGC block, shown only for
  Pluto — FAST/SLOW/HYB/MAN mode buttons + manual GAIN slider. LayoutLeftPanel
  reflows lower panels via RelayoutBelowBands; no layout shift on HPSDR.
- Cold-init fix: direct sampling_frequency write doesn't load the AD9361 FIR
  decimation filter, so a cold-booted Pluto showed a wide centre spike that didn't
  track tuning (worked only after SDR Console pre-initialised it). Add optional
  libad9361 binding (dynamic) and call ad9361_set_bb_rate() in ApplySampleRate,
  which configures BBPLL + loads the FIR; falls back to direct write if absent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-17 12:06:59 +03:00
ew8bakandClaude Opus 4.8 a988849d3e feat: Pluto/AD936x SDR backend (discovery, RX, VHF band plan)
Add ADALM-Pluto / AD9361 support as a second hardware backend alongside
openHPSDR, sharing the WDSP DSP pipeline and the existing controller API
(UI stays decoupled from logic).

- RadioBackend.pas: abstract TRadioBackend + TBackendCaps + TRadioDevice
  (Kind/URI/Serial). THPSDRNetwork now derives from it (state via virtual
  getters); TRadioController.FNetwork is the base type.
- IIOBindings.pas: dynamic libiio loader (runs without libiio present).
- PlutoBackend.pas: scan/probe-by-URI, connect, LO/rate/bandwidth/gain
  control, RX streaming thread (int16->24bit BE -> OnDDCIQ), Q conjugated
  to match WDSP IQ convention. Verified on LibreSDR (AD9361) over network.
- Unified discovery: TDiscoverThread scans both backends; network Plutos
  found via direct ProbeURI (no mDNS needed). ConnectDevice dispatches by
  Dev.Kind (EnsureBackend swaps backend, preserving callbacks).
- DeviceStore/DeviceForm: persist Kind/URI/Serial; save Pluto via
  AddSavedPluto so saved/autostart devices reconnect across restarts.
- VHF/UHF band plan (BoardUtils, kind-aware): 6m..ADS-B for Pluto; fixes
  HF clamps (band detect, mouse-wheel 60 MHz cap, freq-display max).
- SampleRateOverlay: configurable presets (Pluto 576k..5760k, >520 ksps),
  auto-width to fit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 18:55:20 +03:00
ew8bakandClaude Opus 4.8 0d82d1d8e6 fix: refresh S-meter in headless daemon
FLastSMeter is sourced from WDSP (GetSMeterDBm), not the network HP-status,
so only the GUI timer (MainForm) ever updated it. In headless mode nothing
did, leaving PushState to send web clients a frozen -130 dBm. Refresh it in
the daemon Run loop before each PushState, mirroring the GUI timer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 20:17:07 +03:00
ew8bakandClaude Opus 4.8 341bb249fd fix: four logic bugs in RadioController
1. StartRunning applied AGC mode via a raw enum cast (TWDSPAGCMode(FAGCMode))
   instead of the index→enum table, inverting Fast↔Off on every connect/go-live
   (GUI and daemon). Now uses ApplyAGCToEngine like the rest of the unit.
2. SetFilterIdx indexed the per-mode BW/deviation tables with an unchecked Idx
   (FM tables hold only 2 entries) — out-of-bounds when driven from CAT/web.
   Now clamps Idx per mode (EnsureRange).
3. ConnectDevice loaded FActiveVfo / FCurrentBand straight from config without
   range validation; a corrupt/old blob could leave FCurrentBand invalid and
   make later SetMode/SetFilterIdx write past FBandCache. Both now clamped.
4. VfoSwap did not run the bandstack DSP restore that SetActiveVfo does, so a
   swap to a VFO on another band kept the old mode/filter/AGC while the band
   button highlighted the new band. Now mirrors SetActiveVfo.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 20:02:17 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 1cbc5a2307 chore: gitignore PROJECT_NOTES_FOR_CLAUDE.md (local onboarding doc)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 10:06:26 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 8fd45bc266 Phase 5 (D4 fix): daemon WDSP wisdom, spectrum width, shutdown order
Three runtime fixes found testing the daemon on real hardware:

- WDSP opened in ~47s (vs <1s GUI): WDSPEngine.Open never imports FFTW wisdom;
  the GUI does it separately in EnsureWDSPWisdom before Open. Daemon now calls
  WDSPwisdom(GetAppCfgDir) before Open (imports the existing wdspWisdom00 in ms;
  builds it once if absent). Verified: open is now instant.

- Web waterfall/spectrum filled only the left ~6%: the analyzer's pixel width
  defaults to DISPLAY_BLOCK_SIZE (64). The GUI calls SetSpectrumWidth(panel) every
  tick; headless never did, so only 64 of the 1024 web buffer points had data.
  Daemon now calls SetSpectrumWidth(1024) after Open (== SPECTRUM_PIXELS / web
  buffer). FLastSpectrumW survives channel recreation.

- SIGINT during the (blocking) autostart connect was lost because Run set
  FRunning:=True *after* the connect, overwriting RequestStop. Set FRunning:=True
  before autostart so a stop during connect exits the loop.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 10:04:25 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 db361a274b Phase 5 (D4 fix): daemon shares GUI config dir (EWSDR app name)
GetAppConfigDir derives the dir from ApplicationName, which defaulted to the
binary name 'ewsdrd' -> a separate empty ~/.config/ewsdrd/. With no per-device
settings the daemon never configured WDSP's FFT/spectrum/waterfall display (web
showed a white waterfall and no spectrum), never resolved a saved board type
(Board=0), and -- critically -- found no FFTW wisdom, so WDSP recomputed it from
scratch on Open (~48s vs <1s in the GUI). Set OnGetApplicationName := 'EWSDR'
(matching the GUI's Application.Title) before constructing the controller, so the
daemon reads the same ~/.config/EWSDR/ (settings, saved devices, wdspWisdom00).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 15:55:34 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 de234b56e5 Phase 5 (D4): headless daemon entry point (ewsdrd)
ewsdrd.lpr — a console daemon that runs TRadioController + TWebAdapter WITHOUT
TMainForm/LCL, proving the Phase-5 goal: web-only headless operation. THeadlessHost
wires the data-path callbacks to the controller, the web command handlers to the
adapter (lifecycle ones marshalled to the main thread via FCtrl.Invoke =
TThread.Synchronize), opens WDSP synchronously, autostarts the saved device, and
runs a CheckSynchronize + periodic PushState loop. SIGINT/SIGTERM → graceful
StopAndDisconnect (persist + Run=0).

To keep the controller graph truly LCL-free, PlatformUtils now guards its only
Forms dependency (Screen.PixelsPerInch in CurrentScreenDPI) behind {$IFNDEF
HEADLESS}; the GUI build is byte-identical (HEADLESS undefined). build-ewsdrd.sh
compiles the headless graph from source with -Mobjfpc (nested comments) -dHEADLESS
into a separate lib-headless/ output dir, untouching the GUI .ppu.

Verified: builds clean; runs headless, web server up (HTTP 401 = serving), no LCL;
SIGINT shuts down gracefully. Radio-connect + web round-trip need hardware to test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 15:26:44 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 b9c358789d Phase 5 (D3): lift connect/disconnect orchestration into the controller
ConnectAndRun (ConnectDevice + RestoreBand + XVTR restore + active-VFO retune +
StartRunning) and StopAndDisconnect (StopRunning + settings persist + Disconnect)
move into TRadioController, making the full connect/disconnect lifecycle callable
headless. MainForm.DoConnectDevice/DoStopAndDisconnect become thin wrappers that
only add UI-extras (status strings, AGCTop mirror, spectrum reset/resize,
offline status, A-VFO highlight). Behavior-preserving: status/highlight now run
after bring-up, consistent with the batch-29 precedent (no packets yet, safe).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 14:50:38 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 f122079b83 Phase 5 (D2): move spectrum/waterfall raw frames into the controller
OnSpectrumReady/OnWaterfallReady move into TRadioController. The controller now
owns the last spectrum/waterfall frame (FSpectrumBuf/FWaterfallBuf) for the web
mirror and emits raw pixels via OnSpectrumData/OnWaterfallData. MainForm
subscribes for FSpecView rendering (+ waterfall scroll decimation, a UI concern).
TWebAdapter.PushState now reads the frame from the controller (no buffer params).
Behavior-preserving; removes the last spectrum/waterfall data-path coupling.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 14:46:39 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 7c8fd298ae Phase 5 (D1): move RX audio routing into the controller
OnAudioReady moves from MainForm into TRadioController (radio-speaker push +
local AudioOut). The web steal becomes a route hook: controller fires
OnAudioConsume; TWebAdapter.AudioConsume mixes to mono and pushes to the web
client, returning True to skip local AudioOut. Behavior-preserving; removes the
last audio-path coupling to MainForm.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 14:43:04 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 682025e99b Phase 4: extract CAT into its own adapter (CATAdapter.pas)
CAT becomes a peer adapter over the controller, alongside WebAdapter. TCATAdapter
owns the CAT engine + serial/TCP transports and builds the TCATContext: getters
read FController directly (CAT thread), setters/commands call controller commands
marshaled via FController.Invoke. No MainForm or WebAdapter dependency — the
historical CAT->WebAdapter.OnXxx coupling (Mode/AGC/Band/etc.) is gone; CAT talks
only to the controller.

MainForm keeps CAT *settings* (FCATLastGlobal + OnCATSettingsChange + SettingsForm
wiring), now calling FCATAdapter.ApplySettings on change/connect. Removed
InitCATEngine, CATApplySettings, all CATGet*/CATSet*/CATDo*/SyncCAT* and the
FCATEngine/FCATSerial/FCATTcp/FCATSyncFreq fields.

Fixes a latent bug: CATSetFilterIdx routed a filter index through the web BW handler
as a negative-encoded value, but that branch was dead since batch 21 — CAT now calls
FController.SetFilterIdx directly. Adds StoreVfoA (store VFO A without retune when B
is active) and uses the now-real SetBand/BandUp/BandDown/TuneActiveBy commands.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 14:29:56 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 daee5672a9 Phase 5: fill SetBand as a real band-by-index command
SetBand was a skeleton (FCurrentBand := Idx + Changed), leaving BandUp/BandDown
non-functional. Fill it with the band-change logic (XVTR-exit + persist + restore)
that WebAdapter.SyncBand had inline; SyncBand now just calls FController.SetBand.
Gives CAT band up/down/by-index a controller command to call (Phase 4) instead of
routing through the web adapter.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 10:22:15 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 0a0a5c455e Phase 3 (WA2e): move web Freq/FreqA handlers into the adapter
With ApplyVfoA now a thin SetVfoA delegate (channel orchestration on the
OnAfterTune hook), the web Freq/FreqA handlers carry no MainForm logic — move
them to TWebAdapter.OnFreq (active-VFO routing → SetVfoA/SetVfoB) and OnFreqA
(SetVfoA). CAT freq (CATSetVfoA/SyncCATVfoA) left as-is — moves with the CAT
adapter (Phase 4).

Remaining host-coupled web handlers: Run / Connect / device CRUD (daemon entry).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 10:18:59 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 7630172e50 Phase 3 (WA2d): move web Band/XvtrBand handlers into the adapter
Now that RestoreBand and XVTR enter/exit are full controller commands, the web
Band and XvtrBand handlers carry no MainForm orchestration — move them to
TWebAdapter.OnBand/OnXvtrBand (validation + SaveCurrentBand/persist + command).
CAT Ctx.DoBandByIndex and CAT band up/down repointed to FWebAdapter.OnBand.

Remaining host-coupled web handlers: Freq/FreqA (ApplyVfoA channel orchestration),
Run/Connect/device CRUD (daemon entry).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 10:09:06 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 cc8380ae85 Phase 5: make XVTR enter/exit full controller commands
Move the xvtr wrapper render-extras (wideband view + web push) into the rfXvtr
render handler, and the HF-return (RestoreBand) into core DeactivateXvtr — emitting
rfXvtr *after* RestoreBand so the extras render sees the settled HF state.
MainForm.ActivateXvtrBand/DeactivateXvtr collapse to thin delegates.

ChannelController drops its OnActivateXvtr/OnDeactivateXvtr host callbacks and calls
FRadio.SetXvtrBand directly — no host coupling left, only the OnActiveChanged out-event.

Also fixes a latent regression from the OnAfterTune hook: an intermediate SetVfoA
during channel Apply (xvtr-exit → RestoreBand → retune to the old freq) fired
OnVfoTuned and deactivated the channel mid-apply. Apply is now atomic w.r.t.
channel orchestration via an FApplying guard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 09:59:20 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 de1f4b772d Phase 5: make RestoreBand a full controller command (self-retune)
controller.RestoreBand now does the final receiver retune on the active VFO
(SetVfoA/SetVfoB) itself — channel orchestration rides the OnAfterTune hook — and
emits rfBandRestore so the UI resets the waterfall-average buffer (desktop-only,
fires on explicit band change, not per-tune). MainForm.RestoreBand collapses to a
thin delegate.

RestoreBand is now headless-complete: desktop band buttons, channels, connect-
restore, and (soon) web/CAT can call it directly. Preserves the active-VFO retune
(active B no longer centers on A) from the batch-15 fix.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 09:52:11 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 7b40eae174 Phase 5: add OnAfterTune hook so all tune paths run channel orchestration
Channel orchestration (deactivate-on-tune-away, auto-CTCSS/pre-channel-drive
restore) was glued to MainForm.ApplyVfoA, so only desktop/web-freq tuning ran it.
Add TRadioController.OnAfterTune, fired at the very end of SetVfoA (after the
rfVfoA render returns — outside its guard, no re-entrancy), wired to
ChannelController.OnVfoTuned.

Now every SetVfoA caller (desktop, web, CAT, encoder TuneActiveBy, SetActiveVfo,
channel apply) is uniformly channel-aware and headless-compatible. ApplyVfoA
becomes a thin delegate. Minor improvement: encoder tune-away now deactivates an
active channel like desktop; SetActiveVfo/channel-apply are no-ops (freq matches).

Foundation for moving RestoreBand's retune into the controller (Band command).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 09:49:16 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 5f5558e4a2 Phase 3 (WA2c): move web Span into the adapter; SetSampleRate self-persists
Now that global-settings persistence is controller-owned, fold the persist into
SetSampleRate (sample rate is global; self-gated on FDevConnected). OnSampleRateSelect
becomes a thin wrapper. Web Span moves to TWebAdapter.OnSpan (keeps the valid-span
whitelist), so the last span coupling to MainForm is gone.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 21:03:47 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 2c356beb77 Phase 5: move global-settings persistence into the controller
MakeGlobalSettings (the central persist builder, ~50 fields) lived in MainForm
and mixed radio state with UI fields, blocking headless persistence. Replace it
with TRadioController.BuildGlobalSettings (radio fields from live state) +
SaveGlobalSettings (self-gated on FDevConnected). The 7 scattered
SaveGlobal(FDevMAC, MakeGlobalSettings) call-sites collapse to FController.
SaveGlobalSettings.

Non-radio fields (theme/FPS/MHz-digits/CAT) are NOT controller state — they ride
through FLoadedGlobal (the loaded persist record the controller already holds for
round-trip). The GUI mirrors them into FLoadedGlobal at their change-points
(SetLightTheme/ApplyFPS/ApplyFreqMhzDigits/OnCATSettingsChange + connect for the
app-global theme). Controller never reads or acts on them.

Behavior-preserving (same blob, same save points); makes the daemon able to
persist radio settings without the UI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 21:00:57 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 e1ecf947b8 Phase 3 (WA3): move outgoing web state-mirror into the web adapter
The per-tick PushSpectrum mirror (status strings + ~40 state values + spectrum/
waterfall buffers) moves out of SpectrumTimerTick into TWebAdapter.PushState,
which reads FController for everything and takes the pixel buffers as params.
MainForm's timer now just calls FWebAdapter.PushState(FSpectrumBuf, FWaterfallBuf).

Server lifecycle/ownership stays in MainForm for now — it's still driven by the
remaining host-coupled handlers (PushXvtrToWeb, device CRUD); ownership transfer
completes when those move.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 20:36:01 +03:00
Uladzimir KarpenkaandClaude Opus 4.8 e5a13096dc Phase 3 (WA2b): move web Drive handler into the web adapter
Now that SetDrive is a complete command, the web/CAT Drive handler moves into
TWebAdapter.OnDrive (the one handler WA1 left behind). CAT context SetDriveLevel
repointed to it too.

Makes the channel-power-clear reactive: ChannelController.OnDriveChanged fires on
the rfDrive event and clears FPreChannelPower for any external drive change
(slider/web/encoder), guarded by FRestoringDrive for the unit's own apply/restore.
This removes the imperative ClearPreChannelPower coupling so SetDrive callers need
no channel knowledge.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 20:26:30 +03:00