pub struct Css {
pub sf: u32,
pub oversampling: usize,
pub waveform: Waveform,
pub sample_rate: Hertz,
}Expand description
A chirp spread-spectrum link (see the module): a configuration with public fields,
built by Css::lora and changed by struct update, checked by Css::check when it
is used.
Fields§
§sf: u32Spreading factor: M = 2^SF chips per symbol.
oversampling: usizeSamples per chip (1: the chip rate B).
waveform: WaveformThe family of waveforms.
sample_rate: HertzThe sample rate of the signal of the verb traits, J times the chip rate B
(1 Hz by default: time in samples).
Implementations§
Source§impl Css
impl Css
Sourcepub fn lora(sf: u32) -> Result<Css>
pub fn lora(sf: u32) -> Result<Css>
The LoRa waveform at one sample per chip, at 1 Hz.
§Errors
As Css::check: the spreading factor lies in 1..=16.
§Examples
use comnum_waveform::css::Css;
let css = Css { oversampling: 4, ..Css::lora(7)? };
assert_eq!(css.symbol_len(), 4 * 128);
assert!(Css::lora(17).is_err());Sourcepub fn symbol_len(&self) -> usize
pub fn symbol_len(&self) -> usize
Samples per symbol, J M.
Sourcepub fn check(&self) -> Result<()>
pub fn check(&self) -> Result<()>
Check the configuration.
§Errors
comnum_core::Error::Config unless the spreading factor lies in 1..=16, the
oversampling factor is at least 1 (exactly 1 for the FSK reference) and the sample
rate is positive and finite.
Sourcepub fn modulate(&self, symbols: &[usize]) -> Result<Vec<C64>>
pub fn modulate(&self, symbols: &[usize]) -> Result<Vec<C64>>
The samples of a sequence of symbols (the chirps tabulated once, see the module).
§Errors
comnum_core::Error::Config for invalid parameters or a symbol ≥ M.
Sourcepub fn energies(&self, r: &[C64]) -> Result<Vec<f64>>
pub fn energies(&self, r: &[C64]) -> Result<Vec<f64>>
The energy of the M candidate symbols of every received symbol: the squared
magnitudes of the DFT of the dechirped samples, bins a and, when oversampled,
a - M (after the fold) added.
§Errors
comnum_core::Error::Config for invalid parameters, comnum_core::Error::Shape for
a number of samples that is not a multiple of J M.
Sourcepub fn demodulate(&self, r: &[C64]) -> Result<Vec<usize>>
pub fn demodulate(&self, r: &[C64]) -> Result<Vec<usize>>
The noncoherent decisions: the candidate of largest energy in every symbol.
§Errors
As Css::energies.
Sourcepub fn interferer(&self, s1: usize, s2: usize, tau: f64) -> Result<Vec<C64>>
pub fn interferer(&self, s1: usize, s2: usize, tau: f64) -> Result<Vec<C64>>
One symbol of an interferer of the same spreading factor, not synchronised: the
end of its symbol s1 then the start of its symbol s2, which begins tau chips
after the symbol of interest, 0 ≤ tau < M (Afisiadis et al. 2020, eq. (21)), at
one sample per chip.
§Errors
comnum_core::Error::Config for another waveform than LoRa at one sample per chip,
symbols ≥ M or tau outside [0, M).
Trait Implementations§
Source§impl Demodulate<Labels> for Css
CSS as a Demodulate block: the noncoherent decisions of Css::demodulate on one
stream of samples at Css::sample_rate.
impl Demodulate<Labels> for Css
CSS as a Demodulate block: the noncoherent decisions of Css::demodulate on one
stream of samples at Css::sample_rate.
Source§fn demodulate_into(&mut self, y: &Signal, out: &mut Labels) -> Result<()>
fn demodulate_into(&mut self, y: &Signal, out: &mut Labels) -> Result<()>
§Errors
comnum_core::Error::Config for several streams or a signal at another sample rate,
and the errors of Css::demodulate.
Source§impl Modulate<Labels> for Css
CSS as a Modulate block: one stream of symbol indices into one stream of samples
at Css::sample_rate, by Css::modulate.
impl Modulate<Labels> for Css
CSS as a Modulate block: one stream of symbol indices into one stream of samples
at Css::sample_rate, by Css::modulate.
Source§fn modulate_into(&self, x: &Labels, out: &mut Signal) -> Result<()>
fn modulate_into(&self, x: &Labels, out: &mut Signal) -> Result<()>
§Errors
comnum_core::Error::Config for several streams, and the errors of
Css::modulate.