Skip to main content

McCommand

Enum McCommand 

Source
pub enum McCommand {
Show 13 variants PackageVersionReq, PackageVersionAns(PackageVersion), McGroupStatusReq { req_group_mask: u8, }, McGroupStatusAns { ans_group_mask: u8, nb_total_groups: u8, }, McGroupStatusItem { mc_group_id: u8, mc_addr: u32, }, McGroupSetupReq { mc_group_id: u8, mc_addr: u32, mc_key_encrypted: [u8; 16], min_mc_fcnt: u32, max_mc_fcnt: u32, }, McGroupSetupAns { mc_group_id: u8, id_error: bool, }, McGroupDeleteReq { mc_group_id: u8, }, McGroupDeleteAns { mc_group_id: u8, group_undefined: bool, }, McClassCSessionReq { mc_group_id: u8, session_time: u32, time_out: u8, dl_frequency_hz: u32, data_rate: u8, }, McClassCSessionAns { status: SessionStatus, time_to_start: Option<u32>, }, McClassBSessionReq { mc_group_id: u8, session_time: u32, time_out: u8, periodicity: u8, dl_frequency_hz: u32, data_rate: u8, }, McClassBSessionAns { status: SessionStatus, time_to_start: Option<u32>, },
}
Expand description

One command of the remote multicast setup package.

Variants§

§

PackageVersionReq

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

§

PackageVersionAns(PackageVersion)

The device’s answer, section 4.1.

§

McGroupStatusReq

The server asking which groups the device holds, section 4.2.

Fields

§req_group_mask: u8

Which groups to report on, a bit for each.

§

McGroupStatusAns

The device’s answer, section 4.2. The groups themselves follow in the message.

Fields

§ans_group_mask: u8

Which groups this answer covers, a bit for each.

§nb_total_groups: u8

How many groups the device holds in all.

§

McGroupStatusItem

One group of a status answer: its identifier and its address.

Fields

§mc_group_id: u8

Which group.

§mc_addr: u32

Its address.

§

McGroupSetupReq

The server creating or changing a group, section 4.3.

Fields

§mc_group_id: u8

Which group, 0 to 3.

§mc_addr: u32

The address the group answers to.

§mc_key_encrypted: [u8; 16]

The group key, wrapped under the device’s key encryption key.

§min_mc_fcnt: u32

The first frame counter the device accepts from the group.

§max_mc_fcnt: u32

The last one, which ends the group’s life.

§

McGroupSetupAns

The device’s answer, section 4.3.

Fields

§mc_group_id: u8

Which group.

§id_error: bool

Whether the device holds no group by that identifier.

§

McGroupDeleteReq

The server deleting a group, section 4.4.

Fields

§mc_group_id: u8

Which group.

§

McGroupDeleteAns

The device’s answer, section 4.4.

Fields

§mc_group_id: u8

Which group.

§group_undefined: bool

Whether the device held no such group.

§

McClassCSessionReq

The server opening a Class C window on a group, section 4.5.

Fields

§mc_group_id: u8

Which group.

§session_time: u32

When the window opens, in seconds since the GPS epoch.

§time_out: u8

How long it lasts at most: two to the power of this, in seconds.

§dl_frequency_hz: u32

Where the group listens, in hertz.

§data_rate: u8

The data rate it listens at.

§

McClassCSessionAns

The device’s answer, section 4.5.

Fields

§status: SessionStatus

What the device made of it.

§time_to_start: Option<u32>

How many seconds until the window opens, for a session it will open.

§

McClassBSessionReq

The server opening a Class B window on a group, section 4.6.

Fields

§mc_group_id: u8

Which group.

§session_time: u32

When the window opens, a multiple of the beacon period.

§time_out: u8

How long it lasts at most: 128 seconds times two to the power of this.

§periodicity: u8

How often the device opens a ping slot inside it.

§dl_frequency_hz: u32

Where the group listens, in hertz.

§data_rate: u8

The data rate it listens at.

§

McClassBSessionAns

The device’s answer, section 4.6.

Fields

§status: SessionStatus

What the device made of it.

§time_to_start: Option<u32>

How many seconds until the window opens, for a session it will open.

Implementations§

Source§

impl McCommand

Source

pub const fn cid(&self) -> u8

The identifier this command travels under.

§Returns

The identifier, 0x00 to 0x05.

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: &[u8], ) -> Result<(McCommand, usize), LorawanError>

Reads one command from the front of a message.

A status answer reads only its own byte: the groups it covers follow as McCommand::McGroupStatusItem records, five bytes each, which McCommand::status_item reads.

§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 status_item(bytes: &[u8]) -> Result<(McCommand, usize), LorawanError>

Reads one group record of a status answer, section 4.2.

§Arguments
  • bytes - the message from the record on, five bytes or more.
§Returns

The record and how many bytes it took.

§Errors

LorawanError::MalformedFrame when the message ends inside the record.

Source

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

Writes this command out.

§Arguments
  • out - where to write it, at least MAX_COMMAND bytes for any command.
§Returns

How many bytes were written.

§Errors

LorawanError::PayloadTooLong when the buffer is too small.

Trait Implementations§

Source§

impl Clone for McCommand

Source§

fn clone(&self) -> McCommand

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 Copy for McCommand

Source§

impl Debug for McCommand

Source§

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

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

impl Eq for McCommand

Source§

impl Hash for McCommand

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 PartialEq for McCommand

Source§

fn eq(&self, other: &McCommand) -> bool

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for McCommand

Auto Trait Implementations§

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.