Skip to content

Commit

Permalink
Merge pull request #82 from helium/lthiery/add-more-sfs
Browse files Browse the repository at this point in the history
add Spreadings Factors 5 and 6
  • Loading branch information
madninja authored Aug 2, 2023
2 parents 86dd011 + e77a030 commit f7ab77c
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/packet/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -82,6 +85,8 @@ pub mod data_rate {
type Err = ParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"SF5" => Ok(SpreadingFactor::SF5),
"SF6" => Ok(SpreadingFactor::SF6),
"SF7" => Ok(SpreadingFactor::SF7),
"SF8" => Ok(SpreadingFactor::SF8),
"SF9" => Ok(SpreadingFactor::SF9),
Expand All @@ -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,
Expand All @@ -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,
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f7ab77c

Please sign in to comment.