LoRa

Struct LoRa 

Source
pub struct LoRa<RK, DLY>
where RK: RadioKind, DLY: DelayNs,
{ /* private fields */ }
Expand description

Provides the physical layer API to support LoRa chips

Implementations§

Source§

impl<RK, DLY> LoRa<RK, DLY>
where RK: RadioKind, DLY: DelayNs,

Source

pub async fn new( radio_kind: RK, enable_public_network: bool, delay: DLY, ) -> Result<Self, RadioError>

Build and return a new instance of the LoRa physical layer API to control an initialized LoRa radio

Source

pub async fn wait_for_irq(&mut self) -> Result<(), RadioError>

Wait for an IRQ event to occur

Source

pub async fn process_irq_event( &mut self, ) -> Result<Option<IrqState>, RadioError>

Process an IRQ event and return the new state of the radio

Source

pub fn create_modulation_params( &mut self, spreading_factor: SpreadingFactor, bandwidth: Bandwidth, coding_rate: CodingRate, frequency_in_hz: u32, ) -> Result<ModulationParams, RadioError>

Create modulation parameters for a communication channel

Source

pub fn create_tx_packet_params( &mut self, preamble_length: u16, implicit_header: bool, crc_on: bool, iq_inverted: bool, modulation_params: &ModulationParams, ) -> Result<PacketParams, RadioError>

Create packet parameters for a send operation on a communication channel

Source

pub fn create_rx_packet_params( &mut self, preamble_length: u16, implicit_header: bool, max_payload_length: u8, crc_on: bool, iq_inverted: bool, modulation_params: &ModulationParams, ) -> Result<PacketParams, RadioError>

Create packet parameters for a receive operation on a communication channel

Source

pub async fn init(&mut self) -> Result<(), RadioError>

Initialize a Semtech chip as the radio for LoRa physical layer communications

Source

pub async fn enter_standby(&mut self) -> Result<(), RadioError>

Place the LoRa physical layer in standby mode

Source

pub async fn sleep( &mut self, warm_start_if_possible: bool, ) -> Result<(), RadioError>

Place the LoRa physical layer in low power mode, specifying cold or warm start (if the Semtech chip supports it)

Source

pub async fn prepare_for_tx( &mut self, mdltn_params: &ModulationParams, tx_pkt_params: &mut PacketParams, output_power: i32, buffer: &[u8], ) -> Result<(), RadioError>

Prepare the Semtech chip for a send operation

Source

pub async fn tx(&mut self) -> Result<(), RadioError>

Execute a send operation

Source

pub async fn prepare_for_rx( &mut self, listen_mode: RxMode, mdltn_params: &ModulationParams, rx_pkt_params: &PacketParams, ) -> Result<(), RadioError>

Prepare radio to receive a frame in either single or continuous packet mode. Notes:

  • sx126x SetRx(0 < timeout < MAX) will listen util LoRa packet header is detected, therefore we only use 0 (Single Mode) and MAX (continuous) values. TODO: Find a way to express timeout for sx126x, allowing waiting for packet upto 262s TODO: Allow DutyCycle as well?
Source

pub async fn rx( &mut self, packet_params: &PacketParams, receiving_buffer: &mut [u8], ) -> Result<(u8, PacketStatus), RadioError>

Start receiving and wait for result

Source

pub async fn prepare_for_cad( &mut self, mdltn_params: &ModulationParams, ) -> Result<(), RadioError>

Prepare the Semtech chip for a channel activity detection operation

Source

pub async fn cad( &mut self, mdltn_params: &ModulationParams, ) -> Result<bool, RadioError>

Start channel activity detection operation and return the result

Source

pub async fn continuous_wave( &mut self, mdltn_params: &ModulationParams, output_power: i32, ) -> Result<(), RadioError>

Place radio in continuous wave mode, generally for regulatory testing

SemTech app note AN1200.26 “Semtech LoRa FCC 15.247 Guidance” covers usage.

Presumes that init() is called before this function

Trait Implementations§

Source§

impl<RK, DLY, const P: u8, const G: i8> From<LoRa<RK, DLY>> for LorawanRadio<RK, DLY, P, G>
where RK: RadioKind, DLY: DelayNs,

Available on crate feature lorawan-radio only.
Source§

fn from(lora: LoRa<RK, DLY>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<RK, DLY> Freeze for LoRa<RK, DLY>
where RK: Freeze, DLY: Freeze,

§

impl<RK, DLY> RefUnwindSafe for LoRa<RK, DLY>
where RK: RefUnwindSafe, DLY: RefUnwindSafe,

§

impl<RK, DLY> Send for LoRa<RK, DLY>
where RK: Send, DLY: Send,

§

impl<RK, DLY> Sync for LoRa<RK, DLY>
where RK: Sync, DLY: Sync,

§

impl<RK, DLY> Unpin for LoRa<RK, DLY>
where RK: Unpin, DLY: Unpin,

§

impl<RK, DLY> UnwindSafe for LoRa<RK, DLY>
where RK: UnwindSafe, DLY: UnwindSafe,

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.