Skip to main content

MeshCore Payload Format Reference

Payload Format

Inside each MeshCore Packet is a payload, identified by the payload type in the packet header. The types of payloads are:

  • Node advertisement.
  • Acknowledgment.
  • Returned path.
  • Request (destination/source hashes + MAC).
  • Response to REQ or ANON_REQ.
  • Plain text message.
  • Anonymous request.
  • Group text message (unverified).
  • Group datagram (unverified).
  • Multi-part packet
  • Control data packet
  • Custom packet (raw bytes, custom encryption).

This document defines the structure of each of these payload types.

NOTE: all 16 and 32-bit integer fields are Little Endian.

Important concepts:

  • Node hash: the first byte of the node's public key

Node advertisement

This kind of payload notifies receivers that a node exists, and gives information about the node

FieldSize (bytes)Description
public key32Ed25519 public key of the node
timestamp4unix timestamp of advertisement
signature64Ed25519 signature of public key, timestamp, and app data
appdatarest of payloadoptional, see below

Appdata

FieldSize (bytes)Description
flags1specifies which of the fields are present, see below
latitude4 (optional)decimal latitude multiplied by 1000000, integer
longitude4 (optional)decimal longitude multiplied by 1000000, integer
feature 12 (optional)reserved for future use
feature 22 (optional)reserved for future use
namerest of appdataname of the node

Appdata Flags

ValueNameDescription
0x01is chat nodeadvert is for a chat node
0x02is repeateradvert is for a repeater
0x03is room serveradvert is for a room server
0x04is sensoradvert is for a sensor server
0x10has locationappdata contains lat/long information
0x20has feature 1Reserved for future use.
0x40has feature 2Reserved for future use.
0x80has nameappdata contains a node name

Acknowledgement

An acknowledgement that a message was received. Note that for returned path messages, an acknowledgement can be sent in the "extra" payload (see Returned Path) instead of as a separate ackowledgement packet. CLI commands do not cause acknowledgement responses, neither discrete nor extra.

FieldSize (bytes)Description
checksum4CRC checksum of message timestamp, text, and sender pubkey

Returned path, request, response, and plain text message

Returned path, request, response, and plain text messages are all formatted in the same way. See the subsection for more details about the ciphertext's associated plaintext representation.

FieldSize (bytes)Description
destination hash1first byte of destination node public key
source hash1first byte of source node public key
cipher MAC2MAC for encrypted data in next field
ciphertextrest of payloadencrypted message, see subsections below for details

Returned path

Returned path messages provide a description of the route a packet took from the original author. Receivers will send returned path messages to the author of the original message.

FieldSize (bytes)Description
path length1length of next field
pathsee abovea list of node hashes (one byte each)
extra type1extra, bundled payload type, eg., acknowledgement or response. Same values as in Packet Format
extrarest of dataextra, bundled payload content, follows same format as main content defined by this document

Request

FieldSize (bytes)Description
timestamp4sender time (unix timestamp)
request datarest of payloadapplication-defined request payload body

For the common chat/server helpers in BaseChatMesh, the current request type values are:

ValueNameDescription
0x01get statsget stats of repeater or room server
0x02keepalivekeep-alive request used for maintained connections

Get stats

Gets information about the node, possibly including the following:

  • Battery level (millivolts)
  • Current transmit queue length
  • Current free queue length
  • Last RSSI value
  • Number of received packets
  • Number of sent packets
  • Total airtime (seconds)
  • Total uptime (seconds)
  • Number of packets sent as flood
  • Number of packets sent directly
  • Number of packets received as flood
  • Number of packets received directly
  • Error flags
  • Last SNR value
  • Number of direct route duplicates
  • Number of flood route duplicates
  • Number posted (?)
  • Number of post pushes (?)

Get telemetry data

Not defined in BaseChatMesh. Sensor- and application-specific request payloads may be implemented by higher-level firmware.

Get Telemetry

Not defined in BaseChatMesh.

Get Min/Max/Ave (Sensor nodes)

Not defined in BaseChatMesh.

Get Access List

Not defined in BaseChatMesh.

Get Neighors

Not defined in BaseChatMesh.

Get Owner Info

Not defined in BaseChatMesh.

Response

FieldSize (bytes)Description
contentrest of payloadapplication-defined response body

Response contents are opaque application data. There is no single generic response envelope beyond the encrypted payload wrapper shown above.

Plain text message

FieldSize (bytes)Description
timestamp4send time (unix timestamp)
txt_type + attempt1upper six bits are txt_type (see below), lower two bits are attempt number (0..3)
messagerest of payloadthe message content, see next table

txt_type

ValueDescriptionMessage content
0x00plain text messagethe plain text of the message
0x01CLI commandthe command text of the message
0x02signed plain text messagefirst four bytes is sender pubkey prefix, followed by plain text message

Anonymous request

FieldSize (bytes)Description
destination hash1first byte of destination node public key
public key32sender's Ed25519 public key
cipher MAC2MAC for encrypted data in next field
ciphertextrest of payloadencrypted message, see below for details

Room server login

FieldSize (bytes)Description
timestamp4sender time (unix timestamp)
sync timestamp4sender's "sync messages SINCE x" timestamp
passwordrest of messagepassword for room

Repeater/Sensor login

FieldSize (bytes)Description
timestamp4sender time (unix timestamp)
passwordrest of messagepassword for repeater/sensor

Repeater - Regions request

FieldSize (bytes)Description
timestamp4sender time (unix timestamp)
req type10x01 (request sub type)
reply path len1path len for reply
reply path(variable)reply path

Repeater - Owner info request

FieldSize (bytes)Description
timestamp4sender time (unix timestamp)
req type10x02 (request sub type)
reply path len1path len for reply
reply path(variable)reply path

Repeater - Clock and status request

FieldSize (bytes)Description
timestamp4sender time (unix timestamp)
req type10x03 (request sub type)
reply path len1path len for reply
reply path(variable)reply path

Group text message

FieldSize (bytes)Description
channel hash1first byte of SHA256 of channel's shared key
cipher MAC2MAC for encrypted data in next field
ciphertextrest of payloadencrypted message, see below for details

The plaintext contained in the ciphertext matches the format described in plain text message. Specifically, it consists of a four byte timestamp, a flags byte, and the message. The flags byte will generally be 0x00 because it is a "plain text message". The message will be of the form : (eg., user123: I'm on my way).

Group datagram

FieldSize (bytes)Description
channel hash1first byte of SHA256 of channel's shared key
cipher MAC2MAC for encrypted data in next field
ciphertextrest of payloadencrypted data, see below for details

The data contained in the ciphertext uses the format below:

FieldSize (bytes)Description
data type2Identifier for type of data. (See number_allocations.md)
data len1byte length of data
datarest of payload(depends on data type)

Control data

FieldSize (bytes)Description
flags1upper 4 bits is sub_type
datarest of payloadtypically unencrypted data

DISCOVER_REQ (sub_type)

FieldSize (bytes)Description
flags10x8 (upper 4 bits), prefix_only (lowest bit)
type_filter1bit for each ADV_TYPE_*
tag4randomly generate by sender
since4(optional) epoch timestamp (0 by default)

DISCOVER_RESP (sub_type)

FieldSize (bytes)Description
flags10x9 (upper 4 bits), node_type (lower 4)
snr1signed, SNR*4
tag4reflected back from DISCOVER_REQ
pubkey8 or 32node's ID (or prefix)

Custom packet

Custom packets have no defined format.