MeshPacket class
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.
- Available extensions
Constructors
-
MeshPacket.new({int? from, int? to, int? channel, Data? decoded, List<
int> ? encrypted, int? id, int? rxTime, double? rxSnr, int? hopLimit, bool? wantAck, MeshPacket_Priority? priority, int? rxRssi, @Deprecated('This field is deprecated.') MeshPacket_Delayed? delayed, bool? viaMqtt, int? hopStart, List<int> ? publicKey, bool? pkiEncrypted, int? nextHop, int? relayNode, int? txAfter, MeshPacket_TransportMechanism? transportMechanism}) -
factory
-
MeshPacket.fromBuffer(List<
int> data, [ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) -
factory
- MeshPacket.fromJson(String json, [ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY])
-
factory
Properties
- channel ↔ int
-
(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'.
getter/setter pair
- decoded ↔ Data
-
TODO: REPLACE
getter/setter pair
- delayed ↔ MeshPacket_Delayed
-
Describe if this message is delayed
getter/setter pair
-
encrypted
↔ List<
int> -
TODO: REPLACE
getter/setter pair
- from ↔ int
-
The sending node number.
Note: Our crypto implementation uses this field as well.
See crypto for details.
getter/setter pair
- hashCode → int
-
Calculates a hash code based on the contents of the protobuf.
no setterinherited
- hopLimit ↔ int
-
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.
getter/setter pair
- hopStart ↔ int
-
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.
getter/setter pair
- id ↔ int
-
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.
getter/setter pair
- info_ → BuilderInfo
-
no setter
- isFrozen → bool
-
Returns
true
if this message is marked read-only. Otherwisefalse
.no setterinherited - nextHop ↔ int
-
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.
getter/setter pair
- pkiEncrypted ↔ bool
-
Indicates whether the packet was en/decrypted using PKI
getter/setter pair
- priority ↔ MeshPacket_Priority
-
The priority of this message for sending.
See MeshPacket.Priority description for more details.
getter/setter pair
-
publicKey
↔ List<
int> -
Records the public key the packet was encrypted with, if applicable.
getter/setter pair
- relayNode ↔ int
-
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.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- rxRssi ↔ int
-
rssi of received packet. Only sent to phone for dispay purposes.
getter/setter pair
- rxSnr ↔ double
-
Never sent over the radio links.
Set during reception to indicate the SNR of this packet.
Used to collect statistics on current link quality.
getter/setter pair
- rxTime ↔ int
-
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)
getter/setter pair
- to ↔ int
-
The (immediate) destination for this packet
getter/setter pair
- transportMechanism ↔ MeshPacket_TransportMechanism
-
Indicates which transport mechanism this packet arrived over
getter/setter pair
- txAfter ↔ int
-
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.
getter/setter pair
- unknownFields → UnknownFieldSet
-
no setterinherited
- viaMqtt ↔ bool
-
Describes whether this packet passed via MQTT somewhere along the path it currently took.
getter/setter pair
- wantAck ↔ 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
getter/setter pair
Methods
-
addExtension(
Extension extension, Object? value) → void -
Adds an extension field value to a repeated field.
inherited
-
check(
) → void -
Throws a StateError if the message has required fields without a value.
inherited
-
clear(
) → void -
Clears all data that was set in this message.
inherited
-
clearChannel(
) → void -
clearDecoded(
) → void -
clearDelayed(
) → void -
clearEncrypted(
) → void -
clearExtension(
Extension extension) → void -
Clears an extension field and also removes the extension.
inherited
-
clearField(
int tagNumber) → void -
Clears the contents of a given field.
inherited
-
clearFrom(
) → void -
clearHopLimit(
) → void -
clearHopStart(
) → void -
clearId(
) → void -
clearNextHop(
) → void -
clearPayloadVariant(
) → void -
clearPkiEncrypted(
) → void -
clearPriority(
) → void -
clearPublicKey(
) → void -
clearRelayNode(
) → void -
clearRxRssi(
) → void -
clearRxSnr(
) → void -
clearRxTime(
) → void -
clearTo(
) → void -
clearTransportMechanism(
) → void -
clearTxAfter(
) → void -
clearViaMqtt(
) → void -
clearWantAck(
) → void -
clone(
) → MeshPacket - Creates a deep copy of the fields in this message. (The generated code uses mergeFromMessage.)
-
copyWith(
void updates(MeshPacket)) → MeshPacket -
Apply
updates
to a copy of this message. -
createEmptyInstance(
) → MeshPacket - Creates an empty instance of the same message type as this.
-
deepCopy(
) → T -
Available on T, provided by the GeneratedMessageGenericExtensions extension
Returns a writable deep copy of this message. -
ensureDecoded(
) → Data -
extensionsAreInitialized(
) → bool -
inherited
-
freeze(
) → GeneratedMessage -
Make this message read-only.
inherited
-
getDefaultForField(
int tagNumber) → dynamic -
Returns the default value for the given field.
inherited
-
getExtension(
Extension extension) → dynamic -
Returns the value of
extension
.inherited -
getField(
int tagNumber) → dynamic -
Returns the value of the field associated with
tagNumber
, or the default value if it is not set.inherited -
getFieldOrNull(
int tagNumber) → dynamic -
Returns the value of a field, ignoring any defaults.
inherited
-
getTagNumber(
String fieldName) → int? -
inherited
-
hasChannel(
) → bool -
hasDecoded(
) → bool -
hasDelayed(
) → bool -
hasEncrypted(
) → bool -
hasExtension(
Extension extension) → bool -
Returns
true
if a value ofextension
is present.inherited -
hasField(
int tagNumber) → bool -
Whether this message has a field associated with
tagNumber
.inherited -
hasFrom(
) → bool -
hasHopLimit(
) → bool -
hasHopStart(
) → bool -
hasId(
) → bool -
hasNextHop(
) → bool -
hasPkiEncrypted(
) → bool -
hasPriority(
) → bool -
hasPublicKey(
) → bool -
hasRelayNode(
) → bool -
hasRequiredFields(
) → bool -
Whether the message has required fields.
inherited
-
hasRxRssi(
) → bool -
hasRxSnr(
) → bool -
hasRxTime(
) → bool -
hasTo(
) → bool -
hasTransportMechanism(
) → bool -
hasTxAfter(
) → bool -
hasViaMqtt(
) → bool -
hasWantAck(
) → bool -
isInitialized(
) → bool -
Whether all required fields in the message and embedded messages are set.
inherited
-
mergeFromBuffer(
List< int> input, [ExtensionRegistry extensionRegistry = ExtensionRegistry.EMPTY]) → void -
Merges serialized protocol buffer data into this message.
inherited
-
mergeFromCodedBufferReader(
CodedBufferReader input, [ExtensionRegistry extensionRegistry = ExtensionRegistry.EMPTY]) → void -
Same as
mergeFromBuffer
, but takes aCodedBufferReader
input.inherited -
mergeFromJson(
String data, [ExtensionRegistry extensionRegistry = ExtensionRegistry.EMPTY]) → void -
Merges field values from
data
, a JSON object, encoded as described byGeneratedMessage.writeToJson
.inherited -
mergeFromJsonMap(
Map< String, dynamic> json, [ExtensionRegistry extensionRegistry = ExtensionRegistry.EMPTY]) → void -
Merges field values from a JSON object represented as a Dart map.
inherited
-
mergeFromMessage(
GeneratedMessage other) → void -
Merges the contents of the
other
into this message.inherited -
mergeFromProto3Json(
Object? json, {TypeRegistry typeRegistry = const TypeRegistry.empty(), bool ignoreUnknownFields = false, bool supportNamesWithUnderscores = true, bool permissiveEnums = false}) → void -
Merges field values from
json
, a JSON object using proto3 encoding.inherited -
mergeUnknownFields(
UnknownFieldSet unknownFieldSet) → void -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
rebuild(
void updates(T)) → T -
Available on T, provided by the GeneratedMessageGenericExtensions extension
Applyupdates
to a copy of this message. -
setExtension(
Extension extension, Object value) → void -
Sets the value of a non-repeated extension field to
value
.inherited -
setField(
int tagNumber, Object value) → void -
Sets the value of a field by its
tagNumber
.inherited -
toBuilder(
) → GeneratedMessage -
Creates a writable, shallow copy of this message.
inherited
-
toDebugString(
) → String -
Returns a String representation of this message.
inherited
-
toProto3Json(
{TypeRegistry typeRegistry = const TypeRegistry.empty()}) → Object? -
Returns an Object representing Proto3 JSON serialization of
this
.inherited -
toString(
) → String -
Returns a String representation of this message.
inherited
-
whichPayloadVariant(
) → MeshPacket_PayloadVariant -
writeToBuffer(
) → Uint8List -
Serialize the message as the protobuf binary format.
inherited
-
writeToCodedBufferWriter(
CodedBufferWriter output) → void -
Same as
writeToBuffer
, but serializes to the givenCodedBufferWriter
.inherited -
writeToJson(
) → String -
Returns a JSON string that encodes this message.
inherited
-
writeToJsonMap(
) → Map< String, dynamic> -
Returns the JSON encoding of this message as a Dart Map.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
create(
) → MeshPacket -
createRepeated(
) → PbList< MeshPacket> -
getDefault(
) → MeshPacket