Crate lorawan_device

source ·
Expand description

§Feature flags

  • embassy-time — Provide an async_device::Timer impl based on embassy-time.
  • defmt — Use defmt for logging.
  • serde — Enable serde serialization/deserialization for data structures.

§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§

Modules§

  • 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.
  • Provides a default software implementation for LoRaWAN’s cryptographic functions.
  • 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.
  • 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.
  • LoRaWAN device region definitions (eg: EU868, US915, etc).

Structs§

  • AppEui should be entered in LSB format. For example, if your LNS provides a AppEui of 00:11:22:33:44:55:66:77, you should enter it as AppEui([0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00]).
  • AppKey should be entered in MSB format. For example, if your LNS provides a AppKey of 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF, you should enter it as AppKey([0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF]).
  • AppSKey should be entered in MSB format. For example, if your LNS provides a AppSKey of 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF, you should enter it as AppSKey([0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF]).
  • DevAddr represents a 32 bit device address.
  • DevEui should be entered in LSB format. For example, if your LNS provides a DevEui of 00:11:22:33:44:55:66:77, you should enter it as DevEui([0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00]).
  • Provides the application payload and FPort of a downlink message.
  • NwkSKey should be entered in MSB format. For example, if your LNS provides a NwkSKey of 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF, you should enter it as NwkSKey([0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF]).
  • A pseudorandom number generator based on the fastrand crate which uses the Wyrand algorithm.

Enums§

  • Join the network using either OTAA or ABP.

Traits§

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