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
FragSessionStatusAns
The device’s answer, section 3.2.
Fields
FragSessionSetupReq
The server setting a session up, section 3.3.
Fields
FragSessionSetupAns(SetupStatus)
The device’s answer, section 3.3.
FragSessionDeleteReq
The server deleting a session, section 3.4.
FragSessionDeleteAns
The device’s answer, section 3.4.
FragDataBlockReceivedReq
The device reporting a block it has completely received, section 3.5.
Fields
FragDataBlockReceivedAns
The server’s acknowledgment, section 3.5.
DataFragment
One fragment of a block, section 3.6.
Implementations§
Source§impl<'a> FragCommand<'a>
impl<'a> FragCommand<'a>
Sourcepub const fn cid(&self) -> u8
pub const fn cid(&self) -> u8
The identifier this command travels under.
§Returns
The identifier, 0x00 to 0x04 or 0x08 for a data fragment.
Sourcepub const fn direction(&self) -> Direction
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.
Sourcepub fn parse(
direction: Direction,
bytes: &'a [u8],
) -> Result<(FragCommand<'a>, usize), LorawanError>
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.
Sourcepub fn encode(&self, out: &mut [u8]) -> Result<usize, LorawanError>
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>
impl<'a> Clone for FragCommand<'a>
Source§fn clone(&self) -> FragCommand<'a>
fn clone(&self) -> FragCommand<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more