pub struct Sx1261<SPI, RESET, D> { /* private fields */ }Expand description
The SX1261 beside a concentrator, on its own SPI device with its reset line.
Implementations§
Source§impl<SPI, RESET, D> Sx1261<SPI, RESET, D>
impl<SPI, RESET, D> Sx1261<SPI, RESET, D>
Sourcepub const fn new(spi: SPI, reset: RESET, delay: D) -> Sx1261<SPI, RESET, D>
pub const fn new(spi: SPI, reset: RESET, delay: D) -> Sx1261<SPI, RESET, D>
Takes the radio’s bus, reset line and delay.
§Arguments
spi- the radio’s own SPI device,/dev/spidev0.1on Semtech’s reference card.reset- its reset line, which is held low to reset, the opposite of the concentrator’s.delay- a blocking delay.
§Returns
The driver. Nothing is sent until a method is called.
Sourcepub fn release(self) -> (SPI, RESET, D)
pub fn release(self) -> (SPI, RESET, D)
Source§impl<SPI, RESET, D> Sx1261<SPI, RESET, D>where
SPI: SpiDevice,
RESET: OutputPin,
D: DelayNs,
impl<SPI, RESET, D> Sx1261<SPI, RESET, D>where
SPI: SpiDevice,
RESET: OutputPin,
D: DelayNs,
Sourcepub fn bring_up(
&mut self,
patch: &[u32; 386],
hertz: u32,
) -> Result<(), ListenerError<SPI::Error>>
pub fn bring_up( &mut self, patch: &[u32; 386], hertz: u32, ) -> Result<(), ListenerError<SPI::Error>>
Brings the radio up for carrier checks and spectral scans.
§Arguments
patch- the words of Semtech’ssx1261_pram.var, read withread_patch.hertz- a carrier in the band the gateway works in, which the image is calibrated for; the reference uses the first front end’s.
§Returns
Ok(()) with the radio patched, calibrated and parked.
§Errors
Returns what reset, load_patch,
calibrate or set_up returns.
Sourcepub fn reset(&mut self) -> Result<(), ListenerError<SPI::Error>>
pub fn reset(&mut self) -> Result<(), ListenerError<SPI::Error>>
Resets the radio: its line low, then high, each held a tenth of a second.
§Errors
Returns ListenerError::Pin if the line cannot be driven.
Sourcepub fn command(
&mut self,
frame: &Frame,
) -> Result<(), ListenerError<SPI::Error>>
pub fn command( &mut self, frame: &Frame, ) -> Result<(), ListenerError<SPI::Error>>
Sends one command.
§Arguments
frame- the command and its payload.
§Errors
Returns ListenerError::Spi if the transfer fails.
Sourcepub fn send(
&mut self,
opcode: u8,
payload: &[u8],
) -> Result<(), ListenerError<SPI::Error>>
pub fn send( &mut self, opcode: u8, payload: &[u8], ) -> Result<(), ListenerError<SPI::Error>>
Sends an opcode and its payload as one transfer.
§Arguments
opcode- the command.payload- what follows it.
§Errors
Returns ListenerError::Spi if the transfer fails.
Sourcepub fn query(
&mut self,
opcode: u8,
exchange: &mut [u8],
) -> Result<(), ListenerError<SPI::Error>>
pub fn query( &mut self, opcode: u8, exchange: &mut [u8], ) -> Result<(), ListenerError<SPI::Error>>
Sends an opcode with a payload and reads back what the radio answers over it.
§Arguments
opcode- the command.exchange- the payload going out, replaced by the bytes that came back over it.
§Errors
Returns ListenerError::Spi if the transfer fails.
Sourcepub fn status(&mut self) -> Result<Status, ListenerError<SPI::Error>>
pub fn status(&mut self) -> Result<Status, ListenerError<SPI::Error>>
Asks the radio what it is doing.
§Returns
The status it answered with.
§Errors
Returns ListenerError::Spi if the transfer fails.
Sourcepub fn read_memory(
&mut self,
address: u16,
exchange: &mut [u8],
) -> Result<(), ListenerError<SPI::Error>>
pub fn read_memory( &mut self, address: u16, exchange: &mut [u8], ) -> Result<(), ListenerError<SPI::Error>>
Reads bytes from the radio’s memory.
§Arguments
address- where to start.exchange- the address, a byte the radio answers over, then room for the data. The first three bytes are filled in here, and the data lands after them.
§Errors
Returns ListenerError::Spi if the transfer fails.
Sourcepub fn load_patch(
&mut self,
patch: &[u32; 386],
) -> Result<(), ListenerError<SPI::Error>>
pub fn load_patch( &mut self, patch: &[u32; 386], ) -> Result<(), ListenerError<SPI::Error>>
Loads the patch that adds the carrier check and the spectral scan, and proves it took.
Semtech’s sx1261_load_pram: park the radio and confirm it is parked, open the patch
area, write each word, close it, commit, and read back a version string that ends in
PRAM_VERSION.
§Arguments
patch- the patch’s words.
§Errors
Returns ListenerError::NotParked if the radio does not answer as a parked radio,
ListenerError::Unpatched if the version it reports afterward is not the patch’s,
and ListenerError::Spi if a transfer fails.
Sourcepub fn calibrate(&mut self, hertz: u32) -> Result<(), ListenerError<SPI::Error>>
pub fn calibrate(&mut self, hertz: u32) -> Result<(), ListenerError<SPI::Error>>
Calibrates the radio’s image rejection for the band a carrier falls in.
§Arguments
hertz- a carrier in the band.
§Errors
Returns ListenerError::UnsupportedBand for a carrier outside every band,
ListenerError::Calibration if the radio reports the calibration failed, and
ListenerError::Spi if a transfer fails.
Sourcepub fn set_up(&mut self) -> Result<(), ListenerError<SPI::Error>>
pub fn set_up(&mut self) -> Result<(), ListenerError<SPI::Error>>
Sets the receiver up for carrier checks: parked, its buffers placed, and its sensitivity trimmed.
§Errors
Returns ListenerError::NotParked if the radio does not settle parked, and
ListenerError::Spi if a transfer fails.
Sourcepub fn listen(
&mut self,
hertz: u32,
bandwidth: Bandwidth,
) -> Result<(), ListenerError<SPI::Error>>
pub fn listen( &mut self, hertz: u32, bandwidth: Bandwidth, ) -> Result<(), ListenerError<SPI::Error>>
Points the receiver at a channel and leaves it listening.
§Arguments
hertz- the channel’s carrier.bandwidth- the channel’s width.
§Errors
Returns ListenerError::Spi if a transfer fails.
Sourcepub fn check(
&mut self,
scan_time: ScanTime,
threshold_dbm: i8,
) -> Result<(), ListenerError<SPI::Error>>
pub fn check( &mut self, scan_time: ScanTime, threshold_dbm: i8, ) -> Result<(), ListenerError<SPI::Error>>
Starts a carrier check on the channel the receiver listens on, and waits out its scan.
The radio then holds its answer on the pin the concentrator reads when the packet is due to leave, so the transmission that needs the check is armed after this returns.
§Arguments
scan_time- how long to listen.threshold_dbm- the level above which the channel counts as busy, with the board’s RSSI offset already added.
§Errors
Returns ListenerError::Spi if the transfer fails.
Sourcepub fn stop(&mut self) -> Result<(), ListenerError<SPI::Error>>
pub fn stop(&mut self) -> Result<(), ListenerError<SPI::Error>>
Ends a carrier check and parks the receiver on frequency.
§Errors
Returns ListenerError::Spi if a transfer fails.
Sourcepub fn start_scan(
&mut self,
hertz: u32,
scans: u16,
) -> Result<(), ListenerError<SPI::Error>>
pub fn start_scan( &mut self, hertz: u32, scans: u16, ) -> Result<(), ListenerError<SPI::Error>>
Starts a spectral scan of a 125 kHz channel.
§Arguments
hertz- the channel’s carrier.scans- how many times to sample it.
§Errors
Returns ListenerError::Spi if a transfer fails.
Sourcepub fn scan_status(&mut self) -> Result<ScanStatus, ListenerError<SPI::Error>>
pub fn scan_status(&mut self) -> Result<ScanStatus, ListenerError<SPI::Error>>
How far along a spectral scan is.
§Returns
The scan’s state.
§Errors
Returns ListenerError::ScanStatus for a value that is no state, and
ListenerError::Spi if the transfer fails.
Sourcepub fn scan_counts(
&mut self,
rssi_offset: i8,
) -> Result<[Level; 33], ListenerError<SPI::Error>>
pub fn scan_counts( &mut self, rssi_offset: i8, ) -> Result<[Level; 33], ListenerError<SPI::Error>>
Reads what a finished spectral scan counted.
§Arguments
rssi_offset- the board’s correction, in dB.
§Returns
The count at each level, strongest first.
§Errors
Returns ListenerError::Spi if the transfer fails.
Sourcepub fn abort_scan(&mut self) -> Result<(), ListenerError<SPI::Error>>
pub fn abort_scan(&mut self) -> Result<(), ListenerError<SPI::Error>>
Abandons a spectral scan, which frees the radio for a carrier check.
§Errors
Returns ListenerError::Spi if the transfer fails.