Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Spreadings Factors 5 and 6 #82

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading