[][src]Module lorawan::parser

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 Ok(FRMPayload::Data(data_payload)) =
            decrypted.frm_payload() {
        println!("{}", String::from_utf8_lossy(data_payload));
    }
} else {
    panic!("failed to parse data payload");
}

Structs

AppNonce

AppNonce represents a 24 bit network server nonce.

DecryptedDataPayload

DecryptedDataPayload represents a decrypted DataPayload.

DecryptedJoinAcceptPayload

DecryptedJoinAcceptPayload represents a decrypted JoinAccept.

DevAddr

DevAddr represents a 32 bit device address.

DevNonce

DevNonce represents a 16 bit device nonce.

EUI64

EUI64 represents a 64 bit EUI.

EncryptedDataPayload

EncryptedDataPayload represents an encrypted data payload.

EncryptedJoinAcceptPayload

EncryptedJoinAcceptPayload represents an encrypted JoinAccept.

FCtrl

FCtrl represents the FCtrl from FHDR.

FHDR

FHDR represents FHDR from DataPayload.

FRMMacCommands

FRMMacCommands represents the mac commands.

JoinRequestPayload

JoinAcceptPayload represents a JoinRequest.

MHDR

MHDR represents LoRaWAN MHDR.

NwkAddr

NwkAddr represents a 24 bit network address.

Enums

DataPayload

DataPayload is a type that represents a ConfirmedDataUp, ConfirmedDataDown, UnconfirmedDataUp or UnconfirmedDataDown.

FRMPayload

FRMPayload represents the FRMPayload that can either be the application data or mac commands.

JoinAcceptPayload

JoinAcceptPayload is a type that represents a JoinAccept.

MType

MType gives the possible message types of the PhyPayload.

Major

Major gives the supported LoRaWAN payload formats.

PhyPayload

PhyPayload is a type that represents a physical LoRaWAN payload.

Traits

AsPhyPayloadBytes

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).

DataHeader

Helper trait for EncryptedDataPayload and DecryptedDataPayload.

MHDRAble

Helper trait to add mhdr to all types that should have it.

MICAble

Helper trait to add mic to all types that should have it.

Functions

parse

Parses a payload as LoRaWAN physical payload.

parse_with_factory

Parses a payload as LoRaWAN physical payload.