diff --git a/src/packet/types.rs b/src/packet/types.rs index 3cabee0..21a7487 100644 --- a/src/packet/types.rs +++ b/src/packet/types.rs @@ -68,8 +68,11 @@ pub mod data_rate { } } - #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] + #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default)] pub enum SpreadingFactor { + SF5, + SF6, + #[default] SF7, SF8, SF9, @@ -82,6 +85,8 @@ pub mod data_rate { type Err = ParseError; fn from_str(s: &str) -> Result { match s { + "SF5" => Ok(SpreadingFactor::SF5), + "SF6" => Ok(SpreadingFactor::SF6), "SF7" => Ok(SpreadingFactor::SF7), "SF8" => Ok(SpreadingFactor::SF8), "SF9" => Ok(SpreadingFactor::SF9), @@ -93,15 +98,11 @@ pub mod data_rate { } } - impl Default for SpreadingFactor { - fn default() -> Self { - SpreadingFactor::SF7 - } - } - impl SpreadingFactor { pub fn to_u8(&self) -> u8 { match self { + Self::SF5 => 5, + Self::SF6 => 6, Self::SF7 => 7, Self::SF8 => 8, Self::SF9 => 9, @@ -112,9 +113,10 @@ pub mod data_rate { } } - #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)] + #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default)] pub enum Bandwidth { BW125, + #[default] BW250, BW500, } @@ -143,12 +145,6 @@ pub mod data_rate { } } - impl Default for Bandwidth { - fn default() -> Self { - Bandwidth::BW250 - } - } - impl Bandwidth { pub fn to_hz(&self) -> u32 { match self {