Skip to main content

LoraRadio

Trait LoraRadio 

Source
pub trait LoraRadio {
    type Error: Debug;

    // Required methods
    fn link(&self) -> Option<LinkSettings>;
    fn start_transmit(&mut self, frame: &[u8]) -> Result<u64, Self::Error>;
    fn finish_transmit(&mut self) -> Result<bool, Self::Error>;
    fn listen(&mut self) -> Result<(), Self::Error>;
    fn take_frame(
        &mut self,
        buffer: &mut [u8],
    ) -> Result<Option<usize>, Self::Error>;
}
Expand description

A radio a MeshRadio carries frames over.

Each method returns at once, so the transport can sleep on the runtime’s timer between calls rather than block it. Sx126x, Sx127x, and Radio implement it, and a simulated radio implements the same five methods.

Required Associated Types§

Source

type Error: Debug

What the radio reports when it or the bus under it fails.

Required Methods§

Returns the link settings frames go out with, which the duty cycle’s arithmetic needs.

§Returns

The settings, or None while the radio is unconfigured.

Source

fn start_transmit(&mut self, frame: &[u8]) -> Result<u64, Self::Error>

Starts sending one frame, without waiting for it to leave.

§Arguments
  • frame - the bytes to put on the air.
§Returns

The frame’s airtime in microseconds.

§Errors

Whatever the radio reports.

Source

fn finish_transmit(&mut self) -> Result<bool, Self::Error>

Reports whether the frame start_transmit began has left.

§Returns

true once it has been sent.

§Errors

Whatever the radio reports, including a transmission that timed out.

Source

fn listen(&mut self) -> Result<(), Self::Error>

Starts listening, and keeps listening frame after frame.

§Errors

Whatever the radio reports.

Source

fn take_frame( &mut self, buffer: &mut [u8], ) -> Result<Option<usize>, Self::Error>

Takes a frame the radio has received since the last call, dropping one whose CRC failed.

§Arguments
  • buffer - where the frame goes, 255 bytes long.
§Returns

The frame’s length, or None when no good frame has arrived.

§Errors

Whatever the radio reports.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<SPI, BUSY, RESET, D> LoraRadio for Radio<SPI, BUSY, RESET, D>
where SPI: SpiDevice, BUSY: InputPin, RESET: OutputPin, D: DelayNs,

Source§

type Error = RadioError<<SPI as ErrorType>::Error>

Source§

impl<SPI, BUSY, RESET, D> LoraRadio for Sx126x<SPI, BUSY, RESET, D>
where SPI: SpiDevice, BUSY: InputPin, RESET: OutputPin, D: DelayNs,

Source§

type Error = RadioError<<SPI as ErrorType>::Error>

Source§

impl<SPI, RESET, D> LoraRadio for Sx127x<SPI, RESET, D>
where SPI: SpiDevice, RESET: OutputPin, D: DelayNs,

Source§

type Error = RadioError<<SPI as ErrorType>::Error>