[feat](trx-server): add configurable display name for rigs

Add optional `name` field to RigInstanceConfig to allow long-form rig names
(e.g., "HF Transceiver"). The name defaults to rig id if not configured.
Add display_name() method to get display name with fallback to id.
Propagate display_name through RigHandle to listener for GetRigs response.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-26 23:46:02 +01:00
parent 68944f7d78
commit 8297af8302
4 changed files with 17 additions and 0 deletions
+13
View File
@@ -32,6 +32,9 @@ use trx_core::rig::state::RigMode;
pub struct RigInstanceConfig {
/// Stable rig identifier used in protocol routing.
pub id: String,
/// Display name for the rig (e.g., "HF Transceiver", "VHF/UHF SDR").
/// If not specified, defaults to the rig id.
pub name: Option<String>,
/// Rig backend configuration.
pub rig: RigConfig,
/// Polling and retry behavior.
@@ -52,6 +55,7 @@ impl Default for RigInstanceConfig {
fn default() -> Self {
Self {
id: "default".to_string(),
name: None,
rig: RigConfig::default(),
behavior: BehaviorConfig::default(),
audio: AudioConfig::default(),
@@ -63,6 +67,14 @@ impl Default for RigInstanceConfig {
}
}
impl RigInstanceConfig {
/// Get the display name for this rig.
/// Returns the configured name if set, otherwise the id.
pub fn display_name(&self) -> &str {
self.name.as_deref().unwrap_or(&self.id)
}
}
/// Top-level server configuration structure.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
@@ -618,6 +630,7 @@ impl ServerConfig {
}
vec![RigInstanceConfig {
id: "default".to_string(),
name: None,
rig: self.rig.clone(),
behavior: self.behavior.clone(),
audio: self.audio.clone(),
+1
View File
@@ -243,6 +243,7 @@ async fn handle_client(
if let Some(snapshot) = state.snapshot() {
entries.push(RigEntry {
rig_id: handle.rig_id.clone(),
display_name: Some(handle.display_name.clone()),
state: snapshot,
audio_port: Some(handle.audio_port),
});
+1
View File
@@ -798,6 +798,7 @@ async fn main() -> DynResult<()> {
rig_cfg.id.clone(),
RigHandle {
rig_id: rig_cfg.id.clone(),
display_name: rig_cfg.display_name().to_string(),
rig_tx,
state_rx,
audio_port: rig_cfg.audio.port,
+2
View File
@@ -16,6 +16,8 @@ use trx_core::rig::state::RigState;
pub struct RigHandle {
/// Stable rig identifier, matches the key in the HashMap.
pub rig_id: String,
/// Display name for the rig (from config, or rig_id if not set).
pub display_name: String,
/// Send commands to the rig task.
pub rig_tx: mpsc::Sender<RigRequest>,
/// Watch the latest rig state for fast GetState/GetRigs responses.