-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add shared modulation types for gfsk, lora
- Loading branch information
Showing
5 changed files
with
99 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! Common GFSK modulation options | ||
|
||
/// Basic GFSK channel configuration | ||
#[derive(Clone, PartialEq, Debug)] | ||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] | ||
pub struct GfskChannel { | ||
/// Channel frequency in kHz | ||
pub freq_khz: u32, | ||
|
||
/// Channel bandwidth in kHz | ||
pub bw_khz: u16, | ||
|
||
/// Bitrate in bps | ||
pub bitrate_bps: u32, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//! Common LoRa modulation options | ||
|
||
/// LoRa mode channel configuration | ||
#[derive(Clone, PartialEq, Debug)] | ||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] | ||
|
||
pub struct LoRaChannel { | ||
/// LoRa frequency in kHz | ||
pub freq_khz: u32, | ||
/// LoRa channel bandwidth | ||
pub bw_khz: u16, | ||
/// LoRa Spreading Factor | ||
pub sf: SpreadingFactor, | ||
/// LoRa Coding rate | ||
pub cr: CodingRate, | ||
} | ||
|
||
/// Spreading factor for LoRa mode | ||
#[derive(Copy, Clone, PartialEq, Debug)] | ||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] | ||
#[non_exhaustive] | ||
pub enum SpreadingFactor { | ||
/// LoRa Spreading Factor 5, 32 chips / symbol | ||
Sf5, | ||
/// LoRa Spreading Factor 6, 64 chips / symbol | ||
Sf6, | ||
/// LoRa Spreading Factor 7, 128 chips / symbol | ||
Sf7, | ||
/// LoRa Spreading Factor 8, 256 chips / symbol | ||
Sf8, | ||
/// LoRa Spreading Factor 9, 512 chips / symbol | ||
Sf9, | ||
/// LoRa Spreading Factor 10 1024 chips / symbol | ||
Sf10, | ||
/// LoRa Spreading Factor 11 2048 chips / symbol | ||
Sf11, | ||
/// LoRa Spreading Factor 12 4096 chips / symbol | ||
Sf12, | ||
} | ||
|
||
#[derive(Copy, Clone, PartialEq, Debug)] | ||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] | ||
#[non_exhaustive] | ||
pub enum CodingRate { | ||
/// LoRa Coding rate 4/5 | ||
Cr4_5, | ||
/// LoRa Coding rate 4/6 | ||
Cr4_6, | ||
/// LoRa Coding rate 4/7 | ||
Cr4_7, | ||
/// LoRa Coding rate 4/8 | ||
Cr4_8, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//! Shared types for radio channel / modulation configuration | ||
|
||
use core::fmt::Debug; | ||
|
||
pub mod gfsk; | ||
|
||
pub mod lora; | ||
|
||
/// Common modulation configuration errors | ||
/// | ||
/// These are provided as a helper for `TryFrom` implementations, | ||
/// and not intended to be prescriptive. | ||
#[derive(Copy, Clone, Debug, PartialEq)] | ||
#[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
#[non_exhaustive] | ||
pub enum ModError { | ||
UnsupportedBitrate, | ||
UnsupportedFrequency, | ||
UnsupportedBandwidth, | ||
} |