Skip to main content

rds_rs/
rds.rs

1use crate::alt_freq_decoder::AfDecoder;
2use crate::alt_freq_table::AfTable;
3use crate::oda::OdaEntry;
4use crate::ps::PsData;
5use crate::ptyn::PtynData;
6use crate::radiotext::RtData;
7use crate::types::{
8    Clock, Content, DiCodes, EwsData, Pin, ProgramInformation, ProgramType, SlcData, TdcData,
9    TrafficCodes, ValidFields,
10};
11use heapless::LinearMap;
12
13#[derive(Default, Clone, PartialEq)]
14pub struct NetworkInfo {
15    /// Program Item Number Code
16    pub pin: Pin,
17    /// Program Type (PTY)
18    pub program_type: ProgramType,
19    /// Traffic Program / Announcement codes.
20    pub traffic: TrafficCodes,
21    /// Program Service name (8 bytes, not null-terminated)
22    pub ps: PsData,
23}
24
25/// Container for all decoded RDS data.
26///
27/// This struct is populated by the `Decoder`, which is passed many blocks
28/// of raw RDS data to decode. Depending what information is broadcast
29/// and passed to the decoder, some of the fields in this struct will contain
30/// valid data. The `valid` field is a bitmask that should be used first before
31/// dereferencing any members of this struct.
32#[derive(Default, Clone, PartialEq)]
33pub struct RdsData {
34    /// Program Identification Code
35    pub program_information: ProgramInformation,
36
37    /// Tuned network (TN) info.
38    pub tn: NetworkInfo,
39
40    /// Other network (ON) info.
41    pub on: NetworkInfo,
42
43    /// Music/Speech flag.
44    pub content: Content,
45
46    /// Radiotext
47    pub rt: RtData,
48
49    /// Clock time
50    pub clock: Clock,
51
52    /// Slow labelling codes
53    pub slc: SlcData,
54
55    /// Program Type Name (extended PTY)
56    pub ptyn: PtynData,
57
58    /// Active Open Data Applications
59    pub oda: LinearMap<u16, OdaEntry, 10>,
60
61    /// Transparent Data Channels
62    pub tdc: TdcData,
63
64    /// Emergency Warning System
65    pub ews: EwsData,
66
67    pub did_pty: DiCodes,
68
69    pub alt_freqs: AfTable, // Alternative frequency table from group 0A.
70    pub alt_freq_decoder: AfDecoder,
71
72    pub on_freqs: AfTable, // Other network AFs. See RBDS spec. sect. 3.2.1.6.6.
73    pub on_freq_decoder: AfDecoder,
74
75    pub map_freqs: AfTable, // Mapped AFs. See RBDS spec. sect. 3.1.5.19 and 3.2.1.6.6.
76
77    /// Bitmask of which fields are valid
78    pub valid: ValidFields,
79}