[feat](trx-rs): add ft8 decoder
Co-authored-by: Codex <codex@openai.com> Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
@@ -13,6 +13,7 @@ pub const AUDIO_MSG_RX_FRAME: u8 = 0x01;
|
||||
pub const AUDIO_MSG_TX_FRAME: u8 = 0x02;
|
||||
pub const AUDIO_MSG_APRS_DECODE: u8 = 0x03;
|
||||
pub const AUDIO_MSG_CW_DECODE: u8 = 0x04;
|
||||
pub const AUDIO_MSG_FT8_DECODE: u8 = 0x05;
|
||||
|
||||
/// Maximum payload size (1 MB) to reject bogus frames early.
|
||||
const MAX_PAYLOAD_SIZE: u32 = 1_048_576;
|
||||
|
||||
@@ -26,8 +26,10 @@ pub enum ClientCommand {
|
||||
SetCwAuto { enabled: bool },
|
||||
SetCwWpm { wpm: u32 },
|
||||
SetCwToneHz { tone_hz: u32 },
|
||||
SetFt8DecodeEnabled { enabled: bool },
|
||||
ResetAprsDecoder,
|
||||
ResetCwDecoder,
|
||||
ResetFt8Decoder,
|
||||
}
|
||||
|
||||
/// Envelope for client commands with optional authentication token.
|
||||
|
||||
@@ -14,6 +14,8 @@ pub enum DecodedMessage {
|
||||
Aprs(AprsPacket),
|
||||
#[serde(rename = "cw")]
|
||||
Cw(CwEvent),
|
||||
#[serde(rename = "ft8")]
|
||||
Ft8(Ft8Message),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -46,3 +48,17 @@ pub struct CwEvent {
|
||||
/// Whether a CW tone is currently detected
|
||||
pub signal_on: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Ft8Message {
|
||||
/// UTC timestamp (milliseconds since epoch)
|
||||
pub ts_ms: i64,
|
||||
/// Approximate SNR (dB)
|
||||
pub snr_db: f32,
|
||||
/// Time offset within slot (seconds)
|
||||
pub dt_s: f32,
|
||||
/// Audio frequency (Hz)
|
||||
pub freq_hz: f32,
|
||||
/// Decoded message text
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ pub enum RigCommand {
|
||||
SetCwAuto(bool),
|
||||
SetCwWpm(u32),
|
||||
SetCwToneHz(u32),
|
||||
SetFt8DecodeEnabled(bool),
|
||||
ResetAprsDecoder,
|
||||
ResetCwDecoder,
|
||||
ResetFt8Decoder,
|
||||
}
|
||||
|
||||
@@ -507,8 +507,10 @@ pub fn command_from_rig_command(cmd: RigCommand) -> Box<dyn RigCommandHandler> {
|
||||
| RigCommand::SetCwAuto(_)
|
||||
| RigCommand::SetCwWpm(_)
|
||||
| RigCommand::SetCwToneHz(_)
|
||||
| RigCommand::SetFt8DecodeEnabled(_)
|
||||
| RigCommand::ResetAprsDecoder
|
||||
| RigCommand::ResetCwDecoder => Box::new(GetSnapshotCommand),
|
||||
| RigCommand::ResetCwDecoder
|
||||
| RigCommand::ResetFt8Decoder => Box::new(GetSnapshotCommand),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ pub struct RigState {
|
||||
#[serde(default)]
|
||||
pub cw_decode_enabled: bool,
|
||||
#[serde(default)]
|
||||
pub ft8_decode_enabled: bool,
|
||||
#[serde(default)]
|
||||
pub cw_auto: bool,
|
||||
#[serde(default)]
|
||||
pub cw_wpm: u32,
|
||||
@@ -37,6 +39,8 @@ pub struct RigState {
|
||||
pub aprs_decode_reset_seq: u64,
|
||||
#[serde(default, skip_serializing)]
|
||||
pub cw_decode_reset_seq: u64,
|
||||
#[serde(default, skip_serializing)]
|
||||
pub ft8_decode_reset_seq: u64,
|
||||
}
|
||||
|
||||
/// Mode supported by the rig.
|
||||
@@ -87,6 +91,7 @@ impl RigState {
|
||||
cw_auto: self.cw_auto,
|
||||
cw_wpm: self.cw_wpm,
|
||||
cw_tone_hz: self.cw_tone_hz,
|
||||
ft8_decode_enabled: self.ft8_decode_enabled,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -134,6 +139,8 @@ pub struct RigSnapshot {
|
||||
#[serde(default)]
|
||||
pub cw_decode_enabled: bool,
|
||||
#[serde(default)]
|
||||
pub ft8_decode_enabled: bool,
|
||||
#[serde(default)]
|
||||
pub cw_auto: bool,
|
||||
#[serde(default)]
|
||||
pub cw_wpm: u32,
|
||||
|
||||
Reference in New Issue
Block a user