Skip to main content

Service

Struct Service 

Source
pub struct Service {
    pub offset_hz: i32,
    pub chain: Chain,
    pub spreading_factor: u8,
    pub bandwidth_hz: u32,
    pub implicit: Option<Implicit>,
}
Expand description

The receiver fixed to one spreading factor, which is what a network calls its service channel.

The eight receivers beside it take any spreading factor and share a bandwidth fixed in hardware at 125 kHz. This one takes exactly one spreading factor and a bandwidth of its own, which is what lets a network carry a faster rate on a channel of its own.

Fields§

§offset_hz: i32

How far from the carrier it listens, in hertz, which is signed.

§chain: Chain

Which radio it takes its samples from.

§spreading_factor: u8

The one spreading factor it looks for.

§bandwidth_hz: u32

The bandwidth it runs at, in hertz. It is the only receiver that takes its own.

§implicit: Option<Implicit>

What it assumes when a packet carries no header, or None when packets carry one.

Implementations§

Source§

impl Service

Source

pub const fn at(offset_hz: i32, spreading_factor: u8) -> Service

A service channel on the first radio, at 125 kHz, hearing packets that carry a header.

§Arguments
  • offset_hz - how far from the carrier it listens, which is signed.
  • spreading_factor - the one spreading factor it looks for.
§Returns

The service channel.

§Examples
use pamoja_radios::sx1302::channel::Service;
use pamoja_radios::sx1302::tx::Chain;

// The channel a European network runs at its fast rate: SF7 on 250 kHz.
let service = Service::at(300_000, 7).bandwidth(250_000);
assert_eq!(service.chain, Chain::A);
assert!(service.implicit.is_none(), "packets carry their own header");
Source

pub const fn on(self, chain: Chain) -> Service

The same channel, on the other radio.

§Arguments
  • chain - the radio it takes its samples from.
§Returns

The service channel.

Source

pub const fn bandwidth(self, bandwidth_hz: u32) -> Service

The same channel, at a bandwidth of its own.

§Arguments
  • bandwidth_hz - 125000, 250000, or 500000. Anything else leaves a plan a concentrator refuses rather than one it quietly narrows.
§Returns

The service channel.

Source

pub const fn without_header(self, implicit: Implicit) -> Service

The same channel, hearing packets that carry no header.

§Arguments
  • implicit - what every packet is, since nothing on the air will say.
§Returns

The service channel.

Source

pub const fn supported(&self) -> bool

Whether the concentrator can be set to this channel at all.

§Returns

Whether the spreading factor and the bandwidth are ones the chip takes, and the offset is one the radio hears.

§Examples
use pamoja_radios::sx1302::channel::Service;

assert!(Service::at(300_000, 7).bandwidth(250_000).supported());
assert!(!Service::at(300_000, 7).bandwidth(200_000).supported(), "not a bandwidth");
assert!(!Service::at(300_000, 13).supported(), "not a spreading factor");
assert!(!Service::at(900_000, 7).supported(), "past what the radio hears");

Trait Implementations§

Source§

impl Clone for Service

Source§

fn clone(&self) -> Service

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Service

Source§

impl Debug for Service

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Service

Source§

impl PartialEq for Service

Source§

fn eq(&self, other: &Service) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Service

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.