Crate lorawan_device

Source
Expand description

§Feature flags

  • default-crypto — Use pure Rust implementations of AES and CMAC for the LoRaWAN crypto layer.
  • defmt — Use defmt for logging.
  • embassy-time — Provide an async_device::Timer impl based on embassy-time.
  • serde — Enable serde serialization/deserialization for data structures.
  • region-as923-1 (enabled by default) — Enable support for AS923-1 region (by default all regions are enabled).
  • region-as923-2 (enabled by default) — Enable support for AS923-2 region (by default all regions are enabled).
  • region-as923-3 (enabled by default) — Enable support for AS923-3 region (by default all regions are enabled).
  • region-as923-4 (enabled by default) — Enable support for AS923-4 region (by default all regions are enabled).
  • region-au915 (enabled by default) — Enable support for AU915 region (by default all regions are enabled).
  • region-eu433 (enabled by default) — Enable support for EU433 region (by default all regions are enabled).
  • region-eu868 (enabled by default) — Enable support for EU868 region (by default all regions are enabled).
  • region-in865 (enabled by default) — Enable support for IN865 region (by default all regions are enabled).
  • region-us915 (enabled by default) — Enable support for US915 region (by default all regions are enabled).

§lorawan-device

Latest Version Docs

This is an experimental LoRaWAN device stack with both non-blocking (nb_device) and async (async_device) implementations. Both implementations have their respective radio::PhyRxTx traits that describe the radio interface required.

Note: The lorawan-radio feature in the lora-phy crate provides LorawanRadio as an async implementation of radio::PhyRxTx.

Both stacks share a dependency on the internal module, mac where LoRaWAN 1.0.x is approximately implemented:

  • Class A device behavior
  • Class C device behavior (async only)
  • Over-the-Air Activation (OTAA) and Activation by Personalization (ABP)
  • CFList is supported for fixed and dynamic channel plans
  • Regional support for AS923_1, AS923_2, AS923_3, AS923_4, AU915, EU868, EU433, IN865, US915 (note: regional power limits are not enforced (#168)

Currently, MAC commands are minimally mocked. For example, an ADRReq is responded with an ADRResp, but not much is actually done with the payload.

Furthermore, both async and non-blocking implementation do not implement any retries for failed joins or failed confirmed uplinks. It is up to the client to implement retry behavior; see the examples for more.

Please see examples for usage.

A public chat on LoRa/LoRaWAN topics using Rust is here.

Re-exports§

pub use region::Region;

Modules§

async_device
LoRaWAN device which uses async-await for driving the protocol state against pin and timer events, allowing for asynchronous radio implementations. Requires the async feature.
default_cryptodefault-crypto
Provides a default software implementation for LoRaWAN’s cryptographic functions.
mac
LoRaWAN MAC layer implementation written as a non-async state machine (leveraged by async_device and nb_device). Manages state internally while providing client with transmit and receive frequencies, while writing to and decrypting from send and receive buffers.
nb_device
A non-blocking LoRaWAN device implementation which uses an explicitly defined state machine for driving the protocol state against pin and timer events. Depends on a non-async radio implementation.
region
LoRaWAN device region definitions (eg: EU868, US915, etc).

Structs§

AppEui
You can construct AppEui from a hex-encoded MSB string or bytes in LSB format.
AppKey
You can construct AppKey from a hex-encoded MSB string or bytes in MSB format.
AppSKey
You can construct AppSKey from a hex-encoded MSB string or bytes in MSB format.
DevAddr
DevAddr represents a 32-bit device address.
DevEui
You can construct DevEui from a hex-encoded MSB string or bytes in LSB format.
Downlink
Provides the application payload and FPort of a downlink message.
NewSKey
You can construct NewSKey from a hex-encoded MSB string or bytes in MSB format.
Prng
A pseudorandom number generator utilizing Wyrand algorithm via the fastrand crate.

Enums§

JoinMode
Join the network using either OTAA or ABP.

Traits§

CryptoFactory
Represents an abstraction over the crypto functions.
RngCore
The core of a random number generator.
Timings
Allows to fine-tune the beginning and end of the receive windows for a specific board.