pamoja_lora/region/kind.rs
1//! Whether a region's channels are created by the network or numbered in advance.
2
3use super::FixedChannelList;
4
5/// How a region defines its channels, which decides what a network can change on a device.
6///
7/// RP002-1.0.5 splits the regions in two. A dynamic plan gives every device a few default
8/// channels and lets the network add more, with `NewChannelReq` or a join accept's channel
9/// list, and answers in the first receive window on the uplink's own frequency. A fixed plan
10/// numbers every channel in advance, and a network only enables and disables them.
11///
12/// # Examples
13///
14/// ```
15/// use pamoja_lora::region::{FixedChannelList, PlanKind, Region};
16///
17/// assert_eq!(
18/// Region::Eu868.plan().kind,
19/// PlanKind::Dynamic { channel_list: Some(FixedChannelList::Mhz800) }
20/// );
21/// assert_eq!(Region::Us915.plan().kind, PlanKind::Fixed);
22/// ```
23#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
24pub enum PlanKind {
25 /// Default channels every device has, and more the network creates.
26 Dynamic {
27 /// The published numbering a type 1 channel list is read against, for a region
28 /// whose regional parameters name one, and `None` where the region takes only a
29 /// list of frequencies.
30 channel_list: Option<FixedChannelList>,
31 },
32 /// Every channel numbered in advance, enabled and disabled by channel masks.
33 Fixed,
34}
35
36impl PlanKind {
37 /// Reports whether a network may create channels in this plan.
38 ///
39 /// # Returns
40 ///
41 /// `true` for a dynamic plan, which is the kind `NewChannelReq` and `DlChannelReq`
42 /// apply to.
43 pub const fn is_dynamic(self) -> bool {
44 matches!(self, PlanKind::Dynamic { .. })
45 }
46}