Expand description
lora-phy-backed LoRa radio driver implementing umsh_hal::Radio.
Works with any chip that implements lora_phy::mod_traits::RadioKind
(SX126x, LR11xx, etc.). Per-board parameters (frequency, modulation,
preamble, TCXO, RF switch) are supplied by the caller — this crate
only owns the RX/TX state machine.
§Architecture
Two concurrent actors share a Channels bundle:
-
runner— an Embassy task that owns thelora_phy::LoRainstance. It loops between continuous RX and TX: when a TX request arrives on the TX channel it exits RX, transmits, signals the result, then re-enters RX. A request that arrives while a frame is being received is refused withTxError::CadTimeout(up toRX_GATE_MAX_STRIKEStimes) instead of tearing down the reception — the channel is busy either way, and the MAC already backs off and retries on that error. -
LoraphyRadio— a lightweight handle used by the MAC coordinator. It borrows&'static Channelsfortransmit()(sends request, awaits result signal) andpoll_receive()(non-blocking probe of the RX channel with waker registration viaAtomicWaker).
§Usage
use umsh_radio_loraphy::{Channels, LoraphyRadio};
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
static RADIO_CH: Channels<ThreadModeRawMutex, 4, 2> = Channels::new();
// Spawn runner(lora, &RADIO_CH, mdltn, rx_pkt, tx_pkt, power_dbm).
// Pass LoraphyRadio::new(&RADIO_CH, t_frame_ms) to the MAC.Modules§
- profiles
- The vetted PHY profiles, re-exported so a board crate that depends only on this one can name a profile without a manifest entry. Vetted LoRa PHY profiles.
Structs§
- Channels
- Shared state between
LoraphyRadioandrunner. Place in astatic. - Device
Control - Control handle for
device_runner: latest-wins settings updates and on-demand instantaneous-RSSI sampling. Place in astaticnext to theChannels. - Device
Settings - Radio settings applied at runtime by the ULCP session.
- Loraphy
Radio - Implements
umsh_hal::Radioover the sharedChannels. - RxFrame
- A received frame plus signal metadata.
- TxRequest
- A queued transmit request from the MAC to the runner task.
Enums§
- CadPolicy
- Channel-activity-detection (CAD) policy applied before a transmit.
- RxStrategy
- How the runner keeps the radio listening between frames.
- TxError
- Error returned by [
Radio::transmit].
Constants§
- MAX_
PAYLOAD - Maximum SX1262 LoRa payload: 255 bytes.
- RX_
GATE_ MAX_ STRIKES - Maximum consecutive TX requests refused with
TxError::CadTimeoutwhile a reception appears to be in progress (preamble seen, frame not finished).
Functions§
- airtime_
ms - Conservative upper bound on LoRa on-air time in milliseconds.
- bandwidth_
from_ hz - Convert a bandwidth in Hz (the ULCP representation)
to the lora-phy enum. Returns
Nonefor unsupported values. - coding_
rate_ from_ denom - Convert a coding-rate denominator (5 for 4/5 .. 8 for 4/8) to the lora-phy enum.
- device_
runner - Device variant of
runner: same RX/TX state machine, but the modulation parameters, frequency, and power come from anDeviceControlat runtime instead of being fixed at spawn. - duty_
cycle_ rx_ mode - Pick the RX mode for a strategy at the given modulation settings.
- profile_
params - Build modulation and packet parameters for a vetted PHY profile.
- runner
- Background loop: owns the
lora_phy::LoRainstance, switches between continuous RX and TX as requests arrive. Never returns. - spreading_
factor_ from_ u8 - Convert a numeric spreading factor (5-12) to the lora-phy enum.