Expand description
One LoRa radio of either family, behind one set of calls.
The SX126x takes commands and the SX127x takes registers, but a program that sends a
reading does not care which: it tunes to a carrier, sends a frame, and listens for one.
Radio holds either driver and gives both the same calls, configured from one
RadioConfig of a carrier, a LoRa link, an output power, a sync word, and the IQ
polarity of each direction. A program that reads which module it has from a file keeps
one code path, and one that needs a chip’s own features matches on the enum and reaches
its driver.
§Examples
An RFM95W behind the shared calls, answering a register read over a scripted bus:
use pamoja_hal::script::{DelayLog, PinScript, SpiScript, SpiStep};
use pamoja_radios::radio::{Family, Radio, RadioError};
use pamoja_radios::sx127x::config::PaOutput;
use pamoja_radios::sx127x::{Board, Sx127x};
// RegVersion, at 0x42, holds 0x12 on every SX1276.
let spi = SpiScript::new([SpiStep::write([0x42]), SpiStep::read([0x12])]);
let board = Board::new(PaOutput::PaBoost);
let chip = Sx127x::new(spi, PinScript::new([]), DelayLog::new(), board);
let mut radio: Radio<_, PinScript, _, _> = Radio::from(chip);
assert_eq!(radio.family(), Family::Sx127x);
assert_eq!(radio.read_register(0x42), Ok(0x12));
// The SX127x address byte carries seven bits, so its register map ends at 0x7F.
assert_eq!(radio.read_register(0x0740), Err(RadioError::Address(0x0740)));Structs§
- Radio
Config - What a radio of either family sends and listens with.
- Signal
Levels - The signal levels a frame arrived with.
Enums§
- Family
- Which family a radio’s chip belongs to.
- Radio
- A LoRa radio of either family: an SX126x with its BUSY line, or an SX127x.
- Radio
Error - What can go wrong driving a radio of either family.
- Reception
- How a reception ended.
- Sync
Word - The LoRa sync word, which keeps one network’s frames apart from another’s.