[feat](trx-rs): add WFM RDS and playback controls

Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-02-27 23:57:46 +01:00
parent f77d0b0bb1
commit fffc4c6b90
21 changed files with 659 additions and 21 deletions
+1 -1
View File
@@ -13,5 +13,5 @@ pub type DynResult<T> = Result<T, Box<dyn std::error::Error + Send + Sync>>;
pub use rig::command::RigCommand;
pub use rig::request::RigRequest;
pub use rig::response::{RigError, RigResult};
pub use rig::state::{RigFilterState, RigMode, RigSnapshot, RigState};
pub use rig::state::{RdsData, RigFilterState, RigMode, RigSnapshot, RigState};
pub use rig::AudioSource;
+1
View File
@@ -33,5 +33,6 @@ pub enum RigCommand {
ResetWsprDecoder,
SetBandwidth(u32),
SetFirTaps(u32),
SetWfmDeemphasis(u32),
GetSpectrum,
}
@@ -516,6 +516,7 @@ pub fn command_from_rig_command(cmd: RigCommand) -> Box<dyn RigCommandHandler> {
| RigCommand::ResetWsprDecoder
| RigCommand::SetBandwidth(_)
| RigCommand::SetFirTaps(_)
| RigCommand::SetWfmDeemphasis(_)
| RigCommand::GetSpectrum => Box::new(GetSnapshotCommand),
}
}
+10
View File
@@ -155,6 +155,16 @@ pub trait RigCat: Rig + Send {
)))
}
fn set_wfm_deemphasis<'a>(
&'a mut self,
_deemphasis_us: u32,
) -> Pin<Box<dyn Future<Output = DynResult<()>> + Send + 'a>> {
Box::pin(std::future::ready(Err(
Box::new(response::RigError::not_supported("set_wfm_deemphasis"))
as Box<dyn std::error::Error + Send + Sync>,
)))
}
/// Return the current filter state if this backend supports filter controls.
fn filter_state(&self) -> Option<state::RigFilterState> {
None
+22
View File
@@ -269,6 +269,12 @@ pub struct RigFilterState {
pub bandwidth_hz: u32,
pub fir_taps: u32,
pub cw_center_hz: u32,
#[serde(default = "default_wfm_deemphasis_us")]
pub wfm_deemphasis_us: u32,
}
fn default_wfm_deemphasis_us() -> u32 {
75
}
/// Spectrum data from SDR backends (FFT magnitude over the full capture bandwidth).
@@ -280,6 +286,22 @@ pub struct SpectrumData {
pub center_hz: u64,
/// SDR capture sample rate in Hz; the displayed span is ±sample_rate/2.
pub sample_rate: u32,
/// Decoded Radio Data System state, when available for WFM.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub rds: Option<RdsData>,
}
/// Live RDS metadata decoded from a WFM broadcast.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct RdsData {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pi: Option<u16>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub program_service: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pty: Option<u8>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub pty_name: Option<String>,
}
/// Read-only projection of state shared with clients.