Skip to main content

pamoja_radios/
lib.rs

1#![cfg_attr(not(any(test, feature = "std")), no_std)]
2
3//! LoRa radio drivers for the pamoja SDK.
4//!
5//! `pamoja-lora` works out what a link costs and how far it reaches; this crate puts a
6//! radio on the air to match. Each chip family has a module in two halves. The first is
7//! the chip's commands or registers and its decoders: the bytes that configure it, the
8//! interrupt and status bits it answers with, the signal levels of a received packet,
9//! and the frequency, modulation, packet, and power settings that a
10//! [`LinkSettings`](pamoja_lora::LinkSettings) and a channel plan turn into. That half
11//! needs no bus and no allocation, so a test, a language binding, or a protocol
12//! analyzer can use it without a radio. The second half is an `embedded-hal` driver
13//! that talks to the chip over SPI and transmits and receives frames.
14//!
15//! - [`sx126x`] - Semtech's SX1261, SX1262, and LLCC68, from the SX1261/2 datasheet.
16//! - [`sx127x`] - Semtech's SX1276, SX1277, SX1278, and SX1279, and modules such as the
17//!   RFM95W, from the SX1276/77/78/79 datasheet.
18//! - [`duty`] - a guard that holds a radio silent for the off time a regional duty-cycle
19//!   limit requires after each transmission.
20//! - `mesh`, with the `std` feature - a pamoja transport over a radio, carrying topics in
21//!   pamoja-mesh frames that each node relays onward, under the duty-cycle guard.
22//!
23//! # Examples
24//!
25//! ```
26//! use pamoja_lora::LinkSettings;
27//! use pamoja_radios::sx126x::{command, config};
28//!
29//! // The commands that tune an SX1262 to 868.1 MHz for SF9 at 125 kHz.
30//! let link = LinkSettings::new(9, 125_000);
31//! let tune = command::set_rf_frequency(config::frequency_word(868_100_000));
32//! let modulation = config::LoraModulation::from_link(&link).expect("125 kHz is an SX126x bandwidth");
33//! let modulate = command::set_lora_modulation_params(modulation);
34//!
35//! assert_eq!(tune.as_bytes(), [0x86, 0x36, 0x41, 0x99, 0x9A]);
36//! assert_eq!(modulate.as_bytes(), [0x8B, 0x09, 0x04, 0x01, 0x00]);
37//! ```
38
39pub mod duty;
40#[cfg(feature = "std")]
41pub mod mesh;
42pub mod sx126x;
43pub mod sx127x;