pamoja.radios
Idiomatic LoRa radio facade.
pamoja.lora works out what a link costs and how far it reaches; this puts a radio chip
on the air to match. For the Semtech SX1261, SX1262, and LLCC68, pamoja.radios.sx126x
builds the bytes of every command and decodes every answer, and chooses the amplifier
setting a regional EIRP ceiling allows behind an antenna. For the SX1276 family,
pamoja.radios.sx127x gives the register values and decodes the readings.
DutyCycle holds the radio
silent for the off time a duty-cycle limit owes after each frame. On a Linux board,
LoraRadio opens a module of either family through the kernel's spidev and GPIO
character devices and drives it with the same calls. On any platform,
SimulatedLoraChip stands in for a module: the radio it gives is the same class,
and the chip says what it was tuned to and what it sent.
1"""Idiomatic LoRa radio facade. 2 3``pamoja.lora`` works out what a link costs and how far it reaches; this puts a radio chip 4on the air to match. For the Semtech SX1261, SX1262, and LLCC68, :mod:`pamoja.radios.sx126x` 5builds the bytes of every command and decodes every answer, and chooses the amplifier 6setting a regional EIRP ceiling allows behind an antenna. For the SX1276 family, 7:mod:`pamoja.radios.sx127x` gives the register values and decodes the readings. 8:class:`DutyCycle` holds the radio 9silent for the off time a duty-cycle limit owes after each frame. On a Linux board, 10:class:`LoraRadio` opens a module of either family through the kernel's spidev and GPIO 11character devices and drives it with the same calls. On any platform, 12:class:`SimulatedLoraChip` stands in for a module: the radio it gives is the same class, 13and the chip says what it was tuned to and what it sent. 14""" 15 16from __future__ import annotations 17 18from pamoja._native import ( 19 LoraRadio, 20 LoraReception, 21 LoraSentFrame, 22 LoraTuning, 23 SimulatedLoraChip, 24) 25from pamoja._native import RadioDutyCycle as DutyCycle 26 27from . import sx126x, sx127x 28 29__all__ = [ 30 "DutyCycle", 31 "LoraRadio", 32 "LoraReception", 33 "LoraSentFrame", 34 "LoraTuning", 35 "SimulatedLoraChip", 36 "sx126x", 37 "sx127x", 38]
A LoRa radio opened on a Linux board or wired to a simulated chip.
Opens an SX1261, SX1262, SX1268, or LLCC68 module and resets it, which takes a few tens of milliseconds.
Raises PamojaError when the platform is not Linux, a device cannot be opened, or no
chip answers, and ValueError for an amplifier name or a TCXO voltage the chip has no
setting for.
Opens an SX1276, SX1277, SX1278, or SX1279 module, such as an RFM95W, and resets it into LoRa mode.
Raises PamojaError when the platform is not Linux, a device cannot be opened, or no
chip answers, and ValueError for an amplifier output name the chip has no setting
for.
Tunes the radio to a carrier, a link, and an output power.
The sync word is one byte, 0x34 for a public network such as LoRaWAN and 0x12, the
default, for a private one. An SX126x calibrates its receiver for the carrier alone
unless a band is given.
Sends one frame and returns its airtime in microseconds once it has left.
Takes the frame a listening radio has received, or None when nothing has arrived.
Listens a few symbols for a LoRa preamble and returns whether one is there, as a relay's scan does, leaving the chip in standby. An SX126x listens over 1, 2, 4, 8, or 16 symbols, rounded down to one of them, and an SX127x over one.
Puts the radio to sleep until the next call wakes it. An SX126x is configured again before its next frame; an SX127x keeps its registers.
Draws a random number from the noise the receiver hears, leaving the chip in standby.
Semtech's own drivers draw it the same way, and LoRaWAN 1.0.3 suggests this source for a join nonce on a device that has no other.
Reads one register: a 16-bit address on the SX126x, 0x00 to 0x7F on the SX127x.
Writes one register: a 16-bit address on the SX126x, 0x00 to 0x7F on the SX127x.
How a reception ended, with the frame and its signal levels when one arrived.
A frame a simulated chip put on the air.
What a simulated chip is tuned to.
A simulated SX126x or SX127x, which a LoraRadio drives with no radio attached.
The program says what arrives on the air with hear, and reads back what the chip was
tuned to and what it sent with tuning and sent. Nothing is timed: a transmission is
done as soon as it starts, and a reception with a timeout ends at once when nothing is
waiting.
A simulated SX1261, SX1262, SX1268, or LLCC68, out of reset.
Raises ValueError for an amplifier name or a TCXO voltage the chip has no setting
for.
A simulated SX1276, SX1277, SX1278, or SX1279, out of reset.
Raises ValueError for an amplifier output name the chip has no setting for.
Puts a frame on the air for the chip to receive the next time it listens, heard at a strength in dBm and a signal-to-noise ratio in dB. A payload past 255 bytes is cut to 255.
Raises ValueError for a level that is not a finite number.