Module lorawan::parser

source ·
Expand description

Provides types and methods for parsing LoRaWAN payloads.

Examples

use lorawan::parser::*;
use lorawan::keys::*;

let data = vec![0x40, 0x04, 0x03, 0x02, 0x01, 0x80, 0x01, 0x00, 0x01,
    0xa6, 0x94, 0x64, 0x26, 0x15, 0xd6, 0xc3, 0xb5, 0x82];
if let Ok(PhyPayload::Data(DataPayload::Encrypted(phy))) = parse(data) {
    let key = AES128([1; 16]);
    let decrypted = phy.decrypt(None, Some(&key), 1).unwrap();
    if let FRMPayload::Data(data_payload) =
            decrypted.frm_payload() {
        println!("{}", String::from_utf8_lossy(data_payload));
    }
} else {
    panic!("failed to parse data payload");
}

Structs

Enums

  • DataPayload is a type that represents a ConfirmedDataUp, ConfirmedDataDown, UnconfirmedDataUp or UnconfirmedDataDown.
  • FRMPayload represents the FRMPayload that can either be the application data or mac commands.
  • JoinAcceptPayload is a type that represents a JoinAccept.
  • MType gives the possible message types of the PhyPayload.
  • Major gives the supported LoRaWAN payload formats.
  • PhyPayload is a type that represents a physical LoRaWAN payload.

Traits

  • Trait with the sole purpose to make clear distinction in some implementations between types that just happen to have AsRef and those that want to have the given implementations (like MICAble and MHDRAble).
  • Helper trait for EncryptedDataPayload and DecryptedDataPayload.
  • Helper trait to add mhdr to all types that should have it.
  • Helper trait to add mic to all types that should have it.

Functions