Skip to main content

Module linux

Module linux 

Source
Expand description

Opening a LoRa radio on a Linux board.

On a Raspberry Pi or any Linux board a radio module’s SPI bus is a file such as /dev/spidev0.0, and its reset and BUSY pins are lines on a GPIO chip such as /dev/gpiochip0. open_sx126x and open_sx127x open them through the Linux backends of pamoja-hal, reset the chip, and hand it back as a LinuxRadio, so a gateway, a Python script, or a C# service drives a radio with no bus code of its own. The kernel’s SPI interface has to be turned on first; on a Raspberry Pi that is dtparam=spi=on in config.txt.

Only Linux has spidev and the GPIO character device. Everywhere else this module still builds and LinuxRadio still names a type, but opening a radio returns OpenError::Unsupported, so a program and the language bindings compile on any platform and say plainly where no radio can be reached.

§Examples

use pamoja_lora::LinkSettings;
use pamoja_radios::linux::{self, Wiring};
use pamoja_radios::radio::RadioConfig;
use pamoja_radios::sx127x::config::PaOutput;
use pamoja_radios::sx127x::Board;

// An RFM95W on the Raspberry Pi's SPI0, chip select CE0, with its reset pin on GPIO25.
let wiring = Wiring::new("/dev/spidev0.0", "/dev/gpiochip0", 25);
let mut radio = linux::open_sx127x(&wiring, Board::new(PaOutput::PaBoost))?;
radio.configure(RadioConfig::new(868_100_000, LinkSettings::new(9, 125_000), 14))?;
let airtime_us = radio.transmit(b"21.5")?;
println!("sent in {airtime_us} us");

Structs§

UsbCard
A USB card, opened: its concentrator, and the bridge everything on the card shares.
Wiring
Where a radio module is wired on a Linux board.

Enums§

OpenError
Why a radio could not be opened.
Unavailable
The bus, line, and delay of a platform with no spidev or GPIO character device.

Constants§

CONSUMER
The name the kernel shows as holding a radio’s GPIO lines, which gpioinfo prints.
DEFAULT_SPI_HZ
The SPI clock a radio is opened at unless its wiring names another, in hertz.
SPI_MODE
The SPI mode both families take: CPOL 0 and CPHA 0, the clock idling low and data sampled on its rising edge, as section 8.2 of the SX126x family’s datasheets gives it and as RadioLib opens both families.

Functions§

open_sx126x
Opens an SX1261, SX1262, SX1268, or LLCC68 module and resets it.
open_sx127x
Opens an SX1276, SX1277, SX1278, or SX1279 module, such as an RFM95W, and resets it into LoRa mode.
open_sx1261
Opens the SX1261 beside a concentrator card on SPI.
open_sx1302
Opens an SX1302 or SX1303 concentrator and pulses its reset line.
open_usb_sx1302
Opens a concentrator on a USB card, and brings the card up.

Type Aliases§

BusError
Why the SPI device or a GPIO line could not be opened.
Delay
The delay a radio’s driver waits with: the process sleeping.
Line
A GPIO line a radio’s reset or BUSY pin is on: a line of the GPIO character device.
LinuxConcentrator
A concentrator opened on a Linux board.
LinuxListener
The SX1261 beside a concentrator card on the host’s SPI, which checks a channel before the gateway talks on it.
LinuxRadio
A radio opened on a Linux board.
Port
The port a USB card’s bridge answers on.
Spi
The SPI device a radio is opened on: the kernel’s spidev device.
SpiError
What the SPI device reports when a transfer fails.
UsbConcentrator
A concentrator on a USB card: the same driver as LinuxConcentrator, reached through the card’s bridge rather than a bus of the host’s own.
UsbListener
The SX1261 on a USB card, reached through the card’s bridge.