[feat](trx-server): populate server callsign/version and default to N0CALL
Set server_callsign and server_version on the rig state so they are included in snapshots sent to clients. Default callsign is N0CALL when not configured. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
@@ -34,7 +34,7 @@ pub struct ServerConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// General application settings.
|
/// General application settings.
|
||||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct GeneralConfig {
|
pub struct GeneralConfig {
|
||||||
/// Callsign or owner label
|
/// Callsign or owner label
|
||||||
@@ -43,6 +43,15 @@ pub struct GeneralConfig {
|
|||||||
pub log_level: Option<String>,
|
pub log_level: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for GeneralConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
callsign: Some("N0CALL".to_string()),
|
||||||
|
log_level: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Rig backend configuration.
|
/// Rig backend configuration.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ fn resolve_config(cli: &Cli, cfg: &ServerConfig) -> DynResult<ResolvedConfig> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_initial_state(cfg: &ServerConfig) -> RigState {
|
fn build_initial_state(cfg: &ServerConfig, callsign: &Option<String>) -> RigState {
|
||||||
RigState {
|
RigState {
|
||||||
rig_info: None,
|
rig_info: None,
|
||||||
status: RigStatus {
|
status: RigStatus {
|
||||||
@@ -209,6 +209,8 @@ fn build_initial_state(cfg: &ServerConfig) -> RigState {
|
|||||||
clar_on: None,
|
clar_on: None,
|
||||||
enabled: Some(false),
|
enabled: Some(false),
|
||||||
},
|
},
|
||||||
|
server_callsign: callsign.clone(),
|
||||||
|
server_version: Some(env!("CARGO_PKG_VERSION").to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,6 +232,8 @@ fn build_rig_task_config(
|
|||||||
),
|
),
|
||||||
initial_freq_hz: cfg.rig.initial_freq_hz,
|
initial_freq_hz: cfg.rig.initial_freq_hz,
|
||||||
initial_mode: cfg.rig.initial_mode.clone(),
|
initial_mode: cfg.rig.initial_mode.clone(),
|
||||||
|
server_callsign: resolved.callsign.clone(),
|
||||||
|
server_version: Some(env!("CARGO_PKG_VERSION").to_string()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +284,7 @@ async fn main() -> DynResult<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let (tx, rx) = mpsc::channel::<RigRequest>(RIG_TASK_CHANNEL_BUFFER);
|
let (tx, rx) = mpsc::channel::<RigRequest>(RIG_TASK_CHANNEL_BUFFER);
|
||||||
let initial_state = build_initial_state(&cfg);
|
let initial_state = build_initial_state(&cfg, &resolved.callsign);
|
||||||
let (state_tx, state_rx) = watch::channel(initial_state);
|
let (state_tx, state_rx) = watch::channel(initial_state);
|
||||||
// Keep receivers alive so channels don't close prematurely
|
// Keep receivers alive so channels don't close prematurely
|
||||||
let _state_rx = state_rx;
|
let _state_rx = state_rx;
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ pub struct RigTaskConfig {
|
|||||||
pub retry: ExponentialBackoff,
|
pub retry: ExponentialBackoff,
|
||||||
pub initial_freq_hz: u64,
|
pub initial_freq_hz: u64,
|
||||||
pub initial_mode: RigMode,
|
pub initial_mode: RigMode,
|
||||||
|
pub server_callsign: Option<String>,
|
||||||
|
pub server_version: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for RigTaskConfig {
|
impl Default for RigTaskConfig {
|
||||||
@@ -47,6 +49,8 @@ impl Default for RigTaskConfig {
|
|||||||
retry: ExponentialBackoff::default(),
|
retry: ExponentialBackoff::default(),
|
||||||
initial_freq_hz: 144_300_000,
|
initial_freq_hz: 144_300_000,
|
||||||
initial_mode: RigMode::USB,
|
initial_mode: RigMode::USB,
|
||||||
|
server_callsign: None,
|
||||||
|
server_version: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,6 +84,8 @@ pub async fn run_rig_task(
|
|||||||
// Initialize state machine and state
|
// Initialize state machine and state
|
||||||
let mut machine = RigStateMachine::new();
|
let mut machine = RigStateMachine::new();
|
||||||
let emitter = RigEventEmitter::new();
|
let emitter = RigEventEmitter::new();
|
||||||
|
let server_callsign = config.server_callsign.clone();
|
||||||
|
let server_version = config.server_version.clone();
|
||||||
let mut state = RigState {
|
let mut state = RigState {
|
||||||
rig_info: None,
|
rig_info: None,
|
||||||
status: RigStatus {
|
status: RigStatus {
|
||||||
@@ -106,6 +112,8 @@ pub async fn run_rig_task(
|
|||||||
clar_on: None,
|
clar_on: None,
|
||||||
enabled: Some(false),
|
enabled: Some(false),
|
||||||
},
|
},
|
||||||
|
server_callsign,
|
||||||
|
server_version,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Polling configuration
|
// Polling configuration
|
||||||
|
|||||||
Reference in New Issue
Block a user