Skip to main content

MeshPacket

Struct MeshPacket 

Source
pub struct MeshPacket {
Show 20 fields pub from: u32, pub to: u32, pub channel: u32, pub id: u32, pub rx_time: u32, pub rx_snr: f32, pub hop_limit: u32, pub want_ack: bool, pub priority: i32, pub rx_rssi: i32, pub delayed: i32, pub via_mqtt: bool, pub hop_start: u32, pub public_key: Vec<u8>, pub pki_encrypted: bool, pub next_hop: u32, pub relay_node: u32, pub tx_after: u32, pub transport_mechanism: i32, pub payload_variant: Option<PayloadVariant>,
}
Expand description

A packet envelope sent/received over the mesh only payload_variant is sent in the payload portion of the LORA packet. The other fields are either not sent at all, or sent in the special 16 byte LORA header.

Fields§

§from: u32

The sending node number. Note: Our crypto implementation uses this field as well. See crypto for details.

§to: u32

The (immediate) destination for this packet If the value is 4,294,967,295 (maximum value of an unsigned 32bit integer), this indicates that the packet was not destined for a specific node, but for a channel as indicated by the value of channel below. If the value is another, this indicates that the packet was destined for a specific node (i.e. a kind of “Direct Message” to this node) and not broadcast on a channel.

§channel: u32

(Usually) If set, this indicates the index in the secondary_channels table that this packet was sent/received on. If unset, packet was on the primary channel. A particular node might know only a subset of channels in use on the mesh. Therefore channel_index is inherently a local concept and meaningless to send between nodes. Very briefly, while sending and receiving deep inside the device Router code, this field instead contains the ‘channel hash’ instead of the index. This ‘trick’ is only used while the payload_variant is an ‘encrypted’.

§id: u32

A unique ID for this packet. Always 0 for no-ack packets or non broadcast packets (and therefore take zero bytes of space). Otherwise a unique ID for this packet, useful for flooding algorithms. ID only needs to be unique on a per sender basis, and it only needs to be unique for a few minutes (long enough to last for the length of any ACK or the completion of a mesh broadcast flood). Note: Our crypto implementation uses this id as well. See crypto for details.

§rx_time: u32

The time this message was received by the esp32 (secs since 1970). Note: this field is never sent on the radio link itself (to save space) Times are typically not sent over the mesh, but they will be added to any Packet (chain of SubPacket) sent to the phone (so the phone can know exact time of reception)

§rx_snr: f32

Never sent over the radio links. Set during reception to indicate the SNR of this packet. Used to collect statistics on current link quality.

§hop_limit: u32

If unset treated as zero (no forwarding, send to direct neighbor nodes only) if 1, allow hopping through one node, etc… For our usecase real world topologies probably have a max of about 3. This field is normally placed into a few of bits in the header.

§want_ack: bool

This packet is being sent as a reliable message, we would prefer it to arrive at the destination. We would like to receive a ack packet in response. Broadcasts messages treat this flag specially: Since acks for broadcasts would rapidly flood the channel, the normal ack behavior is suppressed. Instead, the original sender listens to see if at least one node is rebroadcasting this packet (because naive flooding algorithm). If it hears that the odds (given typical LoRa topologies) the odds are very high that every node should eventually receive the message. So FloodingRouter.cpp generates an implicit ack which is delivered to the original sender. If after some time we don’t hear anyone rebroadcast our packet, we will timeout and retransmit, using the regular resend logic. Note: This flag is normally sent in a flag bit in the header when sent over the wire

§priority: i32

The priority of this message for sending. See MeshPacket.Priority description for more details.

§rx_rssi: i32

rssi of received packet. Only sent to phone for dispay purposes.

§delayed: i32
👎Deprecated

Describe if this message is delayed

§via_mqtt: bool

Describes whether this packet passed via MQTT somewhere along the path it currently took.

§hop_start: u32

Hop limit with which the original packet started. Sent via LoRa using three bits in the unencrypted header. When receiving a packet, the difference between hop_start and hop_limit gives how many hops it traveled.

§public_key: Vec<u8>

Records the public key the packet was encrypted with, if applicable.

§pki_encrypted: bool

Indicates whether the packet was en/decrypted using PKI

§next_hop: u32

Last byte of the node number of the node that should be used as the next hop in routing. Set by the firmware internally, clients are not supposed to set this.

§relay_node: u32

Last byte of the node number of the node that will relay/relayed this packet. Set by the firmware internally, clients are not supposed to set this.

§tx_after: u32

Never sent over the radio links. Timestamp after which this packet may be sent. Set by the firmware internally, clients are not supposed to set this.

§transport_mechanism: i32

Indicates which transport mechanism this packet arrived over

§payload_variant: Option<PayloadVariant>

Implementations§

Source§

impl MeshPacket

Source

pub fn priority(&self) -> Priority

Returns the enum value of priority, or the default if the field is set to an invalid enum value.

Source

pub fn set_priority(&mut self, value: Priority)

Sets priority to the provided enum value.

Source

pub fn delayed(&self) -> Delayed

Returns the enum value of delayed, or the default if the field is set to an invalid enum value.

Source

pub fn set_delayed(&mut self, value: Delayed)

Sets delayed to the provided enum value.

Source

pub fn transport_mechanism(&self) -> TransportMechanism

Returns the enum value of transport_mechanism, or the default if the field is set to an invalid enum value.

Source

pub fn set_transport_mechanism(&mut self, value: TransportMechanism)

Sets transport_mechanism to the provided enum value.

Trait Implementations§

Source§

impl Clone for MeshPacket

Source§

fn clone(&self) -> MeshPacket

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 Debug for MeshPacket

Source§

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

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

impl Default for MeshPacket

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MeshPacket

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Message for MeshPacket

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited( &self, buf: &mut impl BufMut, ) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl PartialEq for MeshPacket

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for MeshPacket

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for MeshPacket

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> 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,