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: u32The sending node number. Note: Our crypto implementation uses this field as well. See crypto for details.
to: u32The (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: u32A 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: u32The 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: f32Never 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: u32If 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: boolThis 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: i32The priority of this message for sending. See MeshPacket.Priority description for more details.
rx_rssi: i32rssi of received packet. Only sent to phone for dispay purposes.
delayed: i32Describe if this message is delayed
via_mqtt: boolDescribes whether this packet passed via MQTT somewhere along the path it currently took.
hop_start: u32Hop 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: boolIndicates whether the packet was en/decrypted using PKI
next_hop: u32Last 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: u32Last 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: u32Never 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: i32Indicates which transport mechanism this packet arrived over
payload_variant: Option<PayloadVariant>Implementations§
Source§impl MeshPacket
impl MeshPacket
Sourcepub fn priority(&self) -> Priority
pub fn priority(&self) -> Priority
Returns the enum value of priority, or the default if the field is set to an invalid enum value.
Sourcepub fn set_priority(&mut self, value: Priority)
pub fn set_priority(&mut self, value: Priority)
Sets priority to the provided enum value.
Sourcepub fn delayed(&self) -> Delayed
pub fn delayed(&self) -> Delayed
Returns the enum value of delayed, or the default if the field is set to an invalid enum value.
Sourcepub fn set_delayed(&mut self, value: Delayed)
pub fn set_delayed(&mut self, value: Delayed)
Sets delayed to the provided enum value.
Sourcepub fn transport_mechanism(&self) -> TransportMechanism
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.
Sourcepub fn set_transport_mechanism(&mut self, value: TransportMechanism)
pub fn set_transport_mechanism(&mut self, value: TransportMechanism)
Sets transport_mechanism to the provided enum value.
Trait Implementations§
Source§impl Clone for MeshPacket
impl Clone for MeshPacket
Source§fn clone(&self) -> MeshPacket
fn clone(&self) -> MeshPacket
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MeshPacket
impl Debug for MeshPacket
Source§impl Default for MeshPacket
impl Default for MeshPacket
Source§impl<'de> Deserialize<'de> for MeshPacket
impl<'de> Deserialize<'de> for MeshPacket
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Message for MeshPacket
impl Message for MeshPacket
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self.Source§impl PartialEq for MeshPacket
impl PartialEq for MeshPacket
Source§fn eq(&self, other: &MeshPacket) -> bool
fn eq(&self, other: &MeshPacket) -> bool
self and other values to be equal, and is used by ==.