mmdvm/tokio_shell/
event.rs

1//! Events emitted by the modem loop to consumers.
2
3use mmdvm_core::{ModemStatus, NakReason, VersionResponse};
4
5/// Events emitted by the modem loop to the consumer via
6/// [`super::AsyncModem::next_event`].
7#[derive(Debug, Clone)]
8#[non_exhaustive]
9pub enum Event {
10    /// Modem firmware version + capabilities (one-shot, typically at
11    /// init).
12    Version(VersionResponse),
13    /// Modem status update — periodic (from internal 250 ms poll) OR
14    /// unsolicited (from the modem itself after TX transitions etc.).
15    Status(ModemStatus),
16    /// Positive acknowledgement for a sent command.
17    Ack {
18        /// The command byte the modem ACK'd.
19        command: u8,
20    },
21    /// Negative acknowledgement for a sent command.
22    Nak {
23        /// The command byte the modem rejected.
24        command: u8,
25        /// The reason the modem gave.
26        reason: NakReason,
27    },
28    /// D-STAR header received from the radio's MMDVM TX (41 bytes).
29    DStarHeaderRx {
30        /// The 41 raw header bytes.
31        bytes: [u8; 41],
32    },
33    /// D-STAR voice data received from the radio (9 AMBE + 3 slow
34    /// data = 12 bytes).
35    DStarDataRx {
36        /// The 12 raw voice-frame bytes.
37        bytes: [u8; 12],
38    },
39    /// D-STAR signal lost from the radio side.
40    DStarLost,
41    /// D-STAR end-of-transmission from the radio side.
42    DStarEot,
43    /// Debug text from the modem firmware
44    /// (`MMDVM_DEBUG1..DEBUG5`).
45    Debug {
46        /// Debug level (1..=5).
47        level: u8,
48        /// Decoded UTF-8 text (NUL-trimmed, lossy where needed).
49        text: String,
50    },
51    /// Serial passthrough data from the modem.
52    SerialData(Vec<u8>),
53    /// Transparent data from the modem.
54    TransparentData(Vec<u8>),
55    /// The modem sent a mode we don't fully model yet
56    /// (DMR/YSF/P25/NXDN/POCSAG/FM), but the raw frame was accepted —
57    /// payload preserved verbatim.
58    UnhandledResponse {
59        /// The command byte.
60        command: u8,
61        /// The raw payload bytes.
62        payload: Vec<u8>,
63    },
64    /// The transport closed gracefully (e.g. serial device unplug).
65    TransportClosed,
66}