From 894b7c57bea9029f1ea8aa2483826c0d6a96b187 Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Sun, 19 Apr 2026 19:49:57 +0200 Subject: [PATCH] [feat](trx-protocol): add SubscribeMeter command and MeterUpdate DTO Adds a dedicated one-way JSON-line stream for high-rate signal-strength samples so meter updates bypass full-RigState diffing in the control path. Co-Authored-By: Claude Opus 4.7 Signed-off-by: Stan Grams --- src/trx-protocol/src/lib.rs | 2 +- src/trx-protocol/src/mapping.rs | 2 +- src/trx-protocol/src/types.rs | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/trx-protocol/src/lib.rs b/src/trx-protocol/src/lib.rs index 86843f3..4d44b70 100644 --- a/src/trx-protocol/src/lib.rs +++ b/src/trx-protocol/src/lib.rs @@ -18,4 +18,4 @@ pub use auth::{NoAuthValidator, SimpleTokenValidator, TokenValidator}; pub use codec::{mode_to_string, parse_envelope, parse_mode}; pub use decoders::{DecoderActivation, DecoderDescriptor, DECODER_REGISTRY}; pub use mapping::{client_command_to_rig, rig_command_to_client}; -pub use types::{ClientCommand, ClientEnvelope, ClientResponse, RigEntry}; +pub use types::{ClientCommand, ClientEnvelope, ClientResponse, MeterUpdate, RigEntry}; diff --git a/src/trx-protocol/src/mapping.rs b/src/trx-protocol/src/mapping.rs index 1d5d08a..f2e54f9 100644 --- a/src/trx-protocol/src/mapping.rs +++ b/src/trx-protocol/src/mapping.rs @@ -102,7 +102,7 @@ macro_rules! define_command_mapping { define_command_mapping! { // ── Client-only variants (no RigCommand counterpart) ───────────── - client_only: GetRigs, GetSatPasses; + client_only: GetRigs, GetSatPasses, SubscribeMeter; // ── Unit variants (no payload) ─────────────────────────────────── unit: diff --git a/src/trx-protocol/src/types.rs b/src/trx-protocol/src/types.rs index bb968fe..91ef978 100644 --- a/src/trx-protocol/src/types.rs +++ b/src/trx-protocol/src/types.rs @@ -61,6 +61,24 @@ pub enum ClientCommand { SetSamCarrierSync { enabled: bool }, SetRecorderEnabled { enabled: bool }, GetSpectrum, + /// Subscribe to a per-rig meter stream on this connection. After the + /// server receives this command, the connection becomes a one-way flow of + /// newline-delimited `MeterUpdate` JSON frames and no further commands or + /// regular responses are sent. Intended for a dedicated TCP connection. + SubscribeMeter, +} + +/// Fast meter sample pushed by the server on a dedicated meter stream. +/// +/// Emitted at ~30 Hz for SDR backends and ~6–7 Hz for CAT backends. +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +pub struct MeterUpdate { + /// Rig identifier this sample belongs to. + pub rig_id: String, + /// Receive signal strength in dBm (rig/DSP-reported). + pub sig_dbm: f64, + /// Monotonic millisecond timestamp from the server's steady clock. + pub ts_ms: u64, } /// Envelope for client commands with optional authentication token and rig routing.