1pub enum Mode {
2 Test,
3 Otaa,
4 Abp,
5}
6
7impl Mode {
8 pub fn as_str(&self) -> &str {
9 match self {
10 Mode::Test => "TEST",
11 Mode::Abp => "LWABP",
12 Mode::Otaa => "LWOTAA",
13 }
14 }
15}
16
17#[derive(Debug, Clone, Copy)]
18pub enum Region {
19 Eu868,
20 Us915,
21}
22
23impl Region {
24 pub fn as_str(&self) -> &str {
25 match self {
26 Region::Eu868 => "EU868",
27 Region::Us915 => "US915",
28 }
29 }
30}
31
32#[derive(Debug, Clone, Copy)]
33pub enum DR {
34 _0,
35 _1,
36 _2,
37 _3,
38 _4,
39}
40
41use super::Error;
42use std::str::FromStr;
43
44impl FromStr for DR {
45 type Err = Error;
46
47 fn from_str(s: &str) -> Result<Self, Self::Err> {
48 match s {
49 "0" => Ok(DR::_0),
50 "1" => Ok(DR::_1),
51 "2" => Ok(DR::_2),
52 "3" => Ok(DR::_3),
53 "4" => Ok(DR::_4),
54 _ => Err(Error::InvalidDatarateStr(s.to_string())),
55 }
56 }
57}
58
59impl DR {
60 pub fn as_str(&self) -> &str {
61 match self {
62 DR::_0 => "0",
63 DR::_1 => "1",
64 DR::_2 => "2",
65 DR::_3 => "3",
66 DR::_4 => "4",
67 }
68 }
69
70 pub fn termination_pattern(&self) -> &str {
71 match self {
72 DR::_0 => "US915 DR0 SF10 BW125K \r\n",
73 DR::_1 => "US915 DR1 SF9 BW125K \r\n",
74 DR::_2 => "US915 DR2 SF8 BW125K \r\n",
75 DR::_3 => "US915 DR3 SF7 BW125K \r\n",
76 DR::_4 => "US915 DR4 SF8 BW500K \r\n",
77 }
78 }
79
80 pub fn all_patterns() -> [&'static str; 5] {
81 [
82 DR::_0.termination_pattern(),
83 DR::_1.termination_pattern(),
84 DR::_2.termination_pattern(),
85 DR::_3.termination_pattern(),
86 DR::_4.termination_pattern(),
87 ]
88 }
89}