Skip to main content

FragCommand

Enum FragCommand 

Source
pub enum FragCommand<'a> {
    PackageVersionReq,
    PackageVersionAns(PackageVersion),
    FragSessionStatusReq {
        frag_index: u8,
        all_participants: bool,
    },
    FragSessionStatusAns {
        frag_index: u8,
        received: u16,
        missing: u8,
        mic_error: bool,
        memory_error: bool,
        no_session: bool,
    },
    FragSessionSetupReq {
        frag_index: u8,
        mc_group_bit_mask: u8,
        nb_frag: u16,
        frag_size: u8,
        ack_reception: bool,
        frag_algo: u8,
        block_ack_delay: u8,
        padding: u8,
        descriptor: [u8; 4],
        session_cnt: u16,
        mic: [u8; 4],
    },
    FragSessionSetupAns(SetupStatus),
    FragSessionDeleteReq {
        frag_index: u8,
    },
    FragSessionDeleteAns {
        frag_index: u8,
        no_session: bool,
    },
    FragDataBlockReceivedReq {
        frag_index: u8,
        mic_error: bool,
    },
    FragDataBlockReceivedAns {
        frag_index: u8,
    },
    DataFragment {
        frag_index: u8,
        n: u16,
        data: &'a [u8],
    },
}
Expand description

One command of the fragmented data block transport package.

Variants§

§

PackageVersionReq

The server asking which version of this package the device implements.

§

PackageVersionAns(PackageVersion)

The device’s answer, section 3.1.

§

FragSessionStatusReq

The server asking how a session is going, section 3.2.

Fields

§frag_index: u8

Which session.

§all_participants: bool

Whether every device answers, or only those still missing fragments.

§

FragSessionStatusAns

The device’s answer, section 3.2.

Fields

§frag_index: u8

Which session.

§received: u16

How many fragments arrived, coded, uncoded and repeated.

§missing: u8

How many uncoded fragments are still missing, capped at 255.

§mic_error: bool

Whether the block’s integrity code did not check out.

§memory_error: bool

Whether the session ran out of memory to defragment with.

§no_session: bool

Whether the session does not exist on this device.

§

FragSessionSetupReq

The server setting a session up, section 3.3.

Fields

§frag_index: u8

Which session, 0 to 3.

§mc_group_bit_mask: u8

Which multicast groups may feed it, a bit for each.

§nb_frag: u16

How many uncoded fragments the block was cut into.

§frag_size: u8

How many bytes each fragment carries.

§ack_reception: bool

Whether the device reports the block once it has it.

§frag_algo: u8

Which fragmentation algorithm to run.

§block_ack_delay: u8

The coded spread of the delay before a device answers.

§padding: u8

How many bytes of padding the last fragment carries.

§descriptor: [u8; 4]

The four bytes the server describes the block with.

§session_cnt: u16

The session counter, which must rise for each new block.

§mic: [u8; 4]

The code over the block the device checks once it has it all.

§

FragSessionSetupAns(SetupStatus)

The device’s answer, section 3.3.

§

FragSessionDeleteReq

The server deleting a session, section 3.4.

Fields

§frag_index: u8

Which session.

§

FragSessionDeleteAns

The device’s answer, section 3.4.

Fields

§frag_index: u8

Which session.

§no_session: bool

Whether the device had no such session.

§

FragDataBlockReceivedReq

The device reporting a block it has completely received, section 3.5.

Fields

§frag_index: u8

Which session.

§mic_error: bool

Whether the block’s integrity code did not check out.

§

FragDataBlockReceivedAns

The server’s acknowledgment, section 3.5.

Fields

§frag_index: u8

Which session.

§

DataFragment

One fragment of a block, section 3.6.

Fields

§frag_index: u8

Which session.

§n: u16

Which fragment, counting from one.

§data: &'a [u8]

Its bytes.

Implementations§

Source§

impl<'a> FragCommand<'a>

Source

pub const fn cid(&self) -> u8

The identifier this command travels under.

§Returns

The identifier, 0x00 to 0x04 or 0x08 for a data fragment.

Source

pub const fn direction(&self) -> Direction

Which way this command travels.

§Returns

Direction::Uplink for what a device sends, Direction::Downlink for what a server sends.

Source

pub fn parse( direction: Direction, bytes: &'a [u8], ) -> Result<(FragCommand<'a>, usize), LorawanError>

Reads one command from the front of a message.

A data fragment takes the whole message, as section 3 asks, so it reads to the end.

§Arguments
  • direction - which way the frame carrying it traveled.
  • bytes - the message, from this command’s identifier on.
§Returns

The command and how many bytes it took.

§Errors

LorawanError::MalformedFrame when the message ends inside the command, and LorawanError::UnknownCommand for an identifier this package does not define.

Source

pub fn encode(&self, out: &mut [u8]) -> Result<usize, LorawanError>

Writes this command out.

A session setup writes its integrity code, which the caller takes over the block with BlockMicKey.

§Arguments
  • out - where to write it.
§Returns

How many bytes were written.

§Errors

LorawanError::PayloadTooLong when the buffer is too small.

Trait Implementations§

Source§

impl<'a> Clone for FragCommand<'a>

Source§

fn clone(&self) -> FragCommand<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for FragCommand<'a>

Source§

impl<'a> Debug for FragCommand<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for FragCommand<'a>

Source§

impl<'a> Hash for FragCommand<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> PartialEq for FragCommand<'a>

Source§

fn eq(&self, other: &FragCommand<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for FragCommand<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for FragCommand<'a>

§

impl<'a> RefUnwindSafe for FragCommand<'a>

§

impl<'a> Send for FragCommand<'a>

§

impl<'a> Sync for FragCommand<'a>

§

impl<'a> Unpin for FragCommand<'a>

§

impl<'a> UnsafeUnpin for FragCommand<'a>

§

impl<'a> UnwindSafe for FragCommand<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.