pub struct LoRa<RK, DLY>{ /* private fields */ }Expand description
Provides the physical layer API to support LoRa chips
Implementations§
Source§impl<RK, DLY> LoRa<RK, DLY>
impl<RK, DLY> LoRa<RK, DLY>
Sourcepub async fn new(
radio_kind: RK,
enable_public_network: bool,
delay: DLY,
) -> Result<Self, RadioError>
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
Sourcepub async fn wait_for_irq(&mut self) -> Result<(), RadioError>
pub async fn wait_for_irq(&mut self) -> Result<(), RadioError>
Wait for an IRQ event to occur
Sourcepub async fn process_irq_event(
&mut self,
) -> Result<Option<IrqState>, RadioError>
pub async fn process_irq_event( &mut self, ) -> Result<Option<IrqState>, RadioError>
Process an IRQ event and return the new state of the radio
Sourcepub fn create_modulation_params(
&mut self,
spreading_factor: SpreadingFactor,
bandwidth: Bandwidth,
coding_rate: CodingRate,
frequency_in_hz: u32,
) -> Result<ModulationParams, RadioError>
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
Sourcepub 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>
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
Sourcepub 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>
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
Sourcepub async fn init(&mut self) -> Result<(), RadioError>
pub async fn init(&mut self) -> Result<(), RadioError>
Initialize a Semtech chip as the radio for LoRa physical layer communications
Sourcepub async fn enter_standby(&mut self) -> Result<(), RadioError>
pub async fn enter_standby(&mut self) -> Result<(), RadioError>
Place the LoRa physical layer in standby mode
Sourcepub async fn sleep(
&mut self,
warm_start_if_possible: bool,
) -> Result<(), RadioError>
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)
Sourcepub async fn prepare_for_tx(
&mut self,
mdltn_params: &ModulationParams,
tx_pkt_params: &mut PacketParams,
output_power: i32,
buffer: &[u8],
) -> Result<(), RadioError>
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
Sourcepub async fn tx(&mut self) -> Result<(), RadioError>
pub async fn tx(&mut self) -> Result<(), RadioError>
Execute a send operation
Sourcepub async fn prepare_for_rx(
&mut self,
listen_mode: RxMode,
mdltn_params: &ModulationParams,
rx_pkt_params: &PacketParams,
) -> Result<(), RadioError>
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?
Sourcepub async fn rx(
&mut self,
packet_params: &PacketParams,
receiving_buffer: &mut [u8],
) -> Result<(u8, PacketStatus), RadioError>
pub async fn rx( &mut self, packet_params: &PacketParams, receiving_buffer: &mut [u8], ) -> Result<(u8, PacketStatus), RadioError>
Start receiving and wait for result
Sourcepub async fn prepare_for_cad(
&mut self,
mdltn_params: &ModulationParams,
) -> Result<(), RadioError>
pub async fn prepare_for_cad( &mut self, mdltn_params: &ModulationParams, ) -> Result<(), RadioError>
Prepare the Semtech chip for a channel activity detection operation
Sourcepub async fn cad(
&mut self,
mdltn_params: &ModulationParams,
) -> Result<bool, RadioError>
pub async fn cad( &mut self, mdltn_params: &ModulationParams, ) -> Result<bool, RadioError>
Start channel activity detection operation and return the result
Sourcepub async fn continuous_wave(
&mut self,
mdltn_params: &ModulationParams,
output_power: i32,
) -> Result<(), RadioError>
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