diff --git a/Cargo.lock b/Cargo.lock index 50ac034..e336b4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2650,6 +2650,16 @@ dependencies = [ "trx-core", ] +[[package]] +name = "trx-reporting" +version = "0.1.0" +dependencies = [ + "serde", + "tokio", + "tracing", + "trx-core", +] + [[package]] name = "trx-server" version = "0.1.0" @@ -2678,6 +2688,7 @@ dependencies = [ "trx-decode-log", "trx-ft8", "trx-protocol", + "trx-reporting", "trx-vdes", "trx-wspr", "uuid", diff --git a/Cargo.toml b/Cargo.toml index 797270c..e4c9105 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ members = [ "src/trx-core", "src/trx-protocol", "src/trx-app", + "src/trx-reporting", "src/trx-server", "src/trx-server/trx-backend", "src/trx-server/trx-backend/trx-backend-ft817", diff --git a/src/trx-reporting/Cargo.toml b/src/trx-reporting/Cargo.toml new file mode 100644 index 0000000..81ee993 --- /dev/null +++ b/src/trx-reporting/Cargo.toml @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: 2026 Stanislaw Grams +# +# SPDX-License-Identifier: BSD-2-Clause + +[package] +name = "trx-reporting" +version.workspace = true +edition = "2021" + +[dependencies] +tokio = { workspace = true, features = ["full"] } +tracing = { workspace = true } +serde = { workspace = true, features = ["derive"] } +trx-core = { path = "../trx-core" } diff --git a/src/trx-server/src/aprsfi.rs b/src/trx-reporting/src/aprsfi.rs similarity index 99% rename from src/trx-server/src/aprsfi.rs rename to src/trx-reporting/src/aprsfi.rs index 5d88201..03e30e3 100644 --- a/src/trx-server/src/aprsfi.rs +++ b/src/trx-reporting/src/aprsfi.rs @@ -14,7 +14,7 @@ use tracing::{debug, info, warn}; use trx_core::decode::{AprsPacket, DecodedMessage}; -use crate::config::AprsFiConfig; +use crate::AprsFiConfig; /// Compute the APRS-IS passcode for a callsign. /// diff --git a/src/trx-reporting/src/lib.rs b/src/trx-reporting/src/lib.rs new file mode 100644 index 0000000..e7d419a --- /dev/null +++ b/src/trx-reporting/src/lib.rs @@ -0,0 +1,61 @@ +// SPDX-FileCopyrightText: 2026 Stanislaw Grams +// +// SPDX-License-Identifier: BSD-2-Clause + +//! Reporting uplink tasks: PSK Reporter and APRS-IS IGate. + +pub mod aprsfi; +pub mod pskreporter; + +use serde::{Deserialize, Serialize}; + +/// PSK Reporter uplink configuration. +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(default)] +pub struct PskReporterConfig { + /// Whether PSK Reporter uplink is enabled + pub enabled: bool, + /// PSK Reporter host + pub host: String, + /// PSK Reporter UDP port + pub port: u16, + /// Receiver locator (Maidenhead, 4 or 6 chars). If omitted, derived from + /// [general].latitude/[general].longitude when available. + pub receiver_locator: Option, +} + +impl Default for PskReporterConfig { + fn default() -> Self { + Self { + enabled: false, + host: "report.pskreporter.info".to_string(), + port: 4739, + receiver_locator: None, + } + } +} + +/// APRS-IS IGate uplink configuration. +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(default)] +pub struct AprsFiConfig { + /// Whether APRS-IS IGate uplink is enabled + pub enabled: bool, + /// APRS-IS server hostname + pub host: String, + /// APRS-IS server port + pub port: u16, + /// APRS-IS passcode. -1 = auto-compute from [general].callsign. + pub passcode: i32, +} + +impl Default for AprsFiConfig { + fn default() -> Self { + Self { + enabled: false, + host: "rotate.aprs.net".to_string(), + port: 14580, + passcode: -1, + } + } +} diff --git a/src/trx-server/src/pskreporter.rs b/src/trx-reporting/src/pskreporter.rs similarity index 99% rename from src/trx-server/src/pskreporter.rs rename to src/trx-reporting/src/pskreporter.rs index d9771f2..c493632 100644 --- a/src/trx-server/src/pskreporter.rs +++ b/src/trx-reporting/src/pskreporter.rs @@ -13,7 +13,7 @@ use tracing::{info, warn}; use trx_core::decode::DecodedMessage; use trx_core::rig::state::RigState; -use crate::config::PskReporterConfig; +use crate::PskReporterConfig; const PSK_REPORTER_IDENTIFIER: u16 = 0x000A; const RECEIVER_FLOWSET: u16 = 0x9992; diff --git a/src/trx-server/Cargo.toml b/src/trx-server/Cargo.toml index 3ae7a9e..98dd98f 100644 --- a/src/trx-server/Cargo.toml +++ b/src/trx-server/Cargo.toml @@ -39,4 +39,5 @@ trx-cw = { path = "../decoders/trx-cw" } trx-decode-log = { path = "../decoders/trx-decode-log" } trx-ft8 = { path = "../decoders/trx-ft8" } trx-wspr = { path = "../decoders/trx-wspr" } -trx-protocol = { path = "../trx-protocol" } \ No newline at end of file +trx-protocol = { path = "../trx-protocol" } +trx-reporting = { path = "../trx-reporting" } \ No newline at end of file diff --git a/src/trx-server/src/config.rs b/src/trx-server/src/config.rs index 8675f69..6360417 100644 --- a/src/trx-server/src/config.rs +++ b/src/trx-server/src/config.rs @@ -276,56 +276,7 @@ impl Default for AudioConfig { } } -/// PSK Reporter uplink configuration. -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(default)] -pub struct PskReporterConfig { - /// Whether PSK Reporter uplink is enabled - pub enabled: bool, - /// PSK Reporter host - pub host: String, - /// PSK Reporter UDP port - pub port: u16, - /// Receiver locator (Maidenhead, 4 or 6 chars). If omitted, derived from - /// [general].latitude/[general].longitude when available. - pub receiver_locator: Option, -} - -impl Default for PskReporterConfig { - fn default() -> Self { - Self { - enabled: false, - host: "report.pskreporter.info".to_string(), - port: 4739, - receiver_locator: None, - } - } -} - -/// APRS-IS IGate uplink configuration. -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(default)] -pub struct AprsFiConfig { - /// Whether APRS-IS IGate uplink is enabled - pub enabled: bool, - /// APRS-IS server hostname - pub host: String, - /// APRS-IS server port - pub port: u16, - /// APRS-IS passcode. -1 = auto-compute from [general].callsign. - pub passcode: i32, -} - -impl Default for AprsFiConfig { - fn default() -> Self { - Self { - enabled: false, - host: "rotate.aprs.net".to_string(), - port: 14580, - passcode: -1, - } - } -} +pub use trx_reporting::{AprsFiConfig, PskReporterConfig}; /// Top-level SDR configuration (only used when [rig.access] type = "sdr"). #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/src/trx-server/src/main.rs b/src/trx-server/src/main.rs index bc8b08a..a4efa0c 100644 --- a/src/trx-server/src/main.rs +++ b/src/trx-server/src/main.rs @@ -2,13 +2,11 @@ // // SPDX-License-Identifier: BSD-2-Clause -mod aprsfi; mod audio; mod config; mod error; mod history_store; mod listener; -mod pskreporter; mod rig_handle; mod rig_task; @@ -489,7 +487,7 @@ fn spawn_rig_audio_stack( let pr_shutdown_rx = shutdown_rx.clone(); handles.push(tokio::spawn(async move { tokio::select! { - _ = pskreporter::run_pskreporter_uplink( + _ = trx_reporting::pskreporter::run_pskreporter_uplink( pr_cfg, cs, latitude, @@ -516,7 +514,7 @@ fn spawn_rig_audio_stack( let ai_shutdown_rx = shutdown_rx.clone(); handles.push(tokio::spawn(async move { tokio::select! { - _ = aprsfi::run_aprsfi_uplink(ai_cfg, cs, ai_decode_rx) => {} + _ = trx_reporting::aprsfi::run_aprsfi_uplink(ai_cfg, cs, ai_decode_rx) => {} _ = wait_for_shutdown(ai_shutdown_rx) => {} } }));