2025-05-26 18:22:31 -07:00
# Meshcore payloads
Inside of each [meshcore packet ](./packet_structure.md ) is a payload, identified by the payload type in the packet header. The types of payloads are:
2025-06-20 17:59:55 -07:00
* Node advertisement.
* Acknowledgment.
* Returned path.
2025-05-26 18:22:31 -07:00
* Request (destination/source hashes + MAC).
* Response to REQ or ANON_REQ.
* Plain text message.
2025-06-20 17:59:55 -07:00
* Anonymous request.
2025-05-26 18:22:31 -07:00
* Group text message (unverified).
* Group datagram (unverified).
2025-07-18 12:56:31 +10:00
* Multi-part packet
2025-05-26 18:22:31 -07:00
* Custom packet (raw bytes, custom encryption).
2025-07-18 12:56:31 +10:00
This document defines the structure of each of these payload types.
NOTE: all 16 and 32-bit integer fields are Little Endian.
2025-05-26 18:22:31 -07:00
2025-06-20 17:59:55 -07:00
## Important concepts:
2025-07-18 12:56:31 +10:00
* Node hash: the first byte of the node's public key
2025-06-20 17:59:55 -07:00
2025-05-26 18:22:31 -07:00
# Node advertisement
This kind of payload notifies receivers that a node exists, and gives information about the node
| Field | Size (bytes) | Description |
|---------------|-----------------|----------------------------------------------------------|
2025-06-20 17:59:55 -07:00
| public key | 32 | Ed25519 public key of the node |
2025-05-26 18:22:31 -07:00
| timestamp | 4 | unix timestamp of advertisement |
| signature | 64 | Ed25519 signature of public key, timestamp, and app data |
| appdata | rest of payload | optional, see below |
Appdata
| Field | Size (bytes) | Description |
|---------------|-----------------|-------------------------------------------------------|
| flags | 1 | specifies which of the fields are present, see below |
2025-07-18 12:56:31 +10:00
| latitude | 4 (optional) | decimal latitude multiplied by 1000000, integer |
| longitude | 4 (optional) | decimal longitude multiplied by 1000000, integer |
| feature 1 | 2 (optional) | reserved for future use |
| feature 2 | 2 (optional) | reserved for future use |
2025-05-26 18:22:31 -07:00
| name | rest of appdata | name of the node |
Appdata Flags
2025-06-20 19:41:07 -07:00
| Value | Name | Description |
|--------|----------------|---------------------------------------|
| `0x01` | is chat node | advert is for a chat node |
| `0x02` | is repeater | advert is for a repeater |
| `0x03` | is room server | advert is for a room server |
2025-07-18 12:56:31 +10:00
| `0x04` | is sensor | advert is for a sensor server |
2025-06-20 19:41:07 -07:00
| `0x10` | has location | appdata contains lat/long information |
| `0x20` | has feature 1 | Reserved for future use. |
| `0x40` | has feature 2 | Reserved for future use. |
| `0x80` | has name | appdata contains a node name |
2025-05-26 18:22:31 -07:00
# Acknowledgement
2025-06-20 17:59:55 -07:00
An acknowledgement that a message was received. Note that for returned path messages, an acknowledgement will be sent in the "extra" payload (see [Returned Path ](#returned-path )) and not as a discrete ackowledgement. CLI commands do not require an acknowledgement, neither discrete nor extra.
2025-05-26 18:22:31 -07:00
| Field | Size (bytes) | Description |
|----------|--------------|------------------------------------------------------------|
| checksum | 4 | CRC checksum of message timestamp, text, and sender pubkey |
# Returned path, request, response, and plain text message
2025-06-20 17:59:55 -07:00
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.
2025-05-26 18:22:31 -07:00
| Field | Size (bytes) | Description |
|------------------|-----------------|------------------------------------------------------|
| destination hash | 1 | first byte of destination node public key |
| source hash | 1 | first byte of source node public key |
| cipher MAC | 2 | MAC for encrypted data in next field |
| ciphertext | rest of payload | encrypted message, see subsections below for details |
## Returned path
2025-06-20 17:59:55 -07:00
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.
2025-05-26 18:22:31 -07:00
| Field | Size (bytes) | Description |
|-------------|--------------|----------------------------------------------------------------------------------------------|
| path length | 1 | length of next field |
2025-06-20 17:59:55 -07:00
| path | see above | a list of node hashes (one byte each) |
| extra type | 1 | extra, bundled payload type, eg., acknowledgement or response. Same values as in [packet structure ](./packet_structure.md ) |
2025-05-26 18:22:31 -07:00
| extra | rest of data | extra, bundled payload content, follows same format as main content defined by this document |
## Request
| Field | Size (bytes) | Description |
|--------------|-----------------|----------------------------|
| timestamp | 4 | send time (unix timestamp) |
| request type | 1 | see below |
| request data | rest of payload | depends on request type |
Request type
2025-07-18 12:56:31 +10:00
| Value | Name | Description |
|--------|----------------------|---------------------------------------|
| `0x01` | get stats | get stats of repeater or room server |
| `0x02` | keepalive | (deprecated) |
| `0x03` | get telemetry data | TODO |
| `0x04` | get min,max,avg data | sensor nodes - get min, max, average for given time span |
| `0x05` | get access list | get node's approved access list |
2025-05-26 18:22:31 -07:00
2025-07-18 12:56:31 +10:00
### Get stats
2025-05-26 18:22:31 -07:00
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
Request data about sensors on the node, including battery level.
## Response
| Field | Size (bytes) | Description |
|---------|-----------------|-------------|
| tag | 4 | TODO |
| content | rest of payload | TODO |
## Plain text message
2025-07-18 12:56:31 +10:00
| Field | Size (bytes) | Description |
|-----------------|-----------------|--------------------------------------------------------------|
| timestamp | 4 | send time (unix timestamp) |
| flags + attempt | 1 | upper six bits are flags (see below), lower two bits are attempt number (0..3) |
| message | rest of payload | the message content, see next table |
2025-05-26 18:22:31 -07:00
Flags
| Value | Description | Message content |
|--------|---------------------------|------------------------------------------------------------|
| `0x00` | plain text message | the plain text of the message |
| `0x01` | CLI command | the command text of the message |
2025-07-18 12:56:31 +10:00
| `0x02` | signed plain text message | first four bytes is sender pubkey prefix, followed by plain text message |
2025-05-26 18:22:31 -07:00
# Anonymous request
| Field | Size (bytes) | Description |
|------------------|-----------------|-------------------------------------------|
| destination hash | 1 | first byte of destination node public key |
| public key | 32 | sender's Ed25519 public key |
| cipher MAC | 2 | MAC for encrypted data in next field |
| ciphertext | rest of payload | encrypted message, see below for details |
Plaintext message
| Field | Size (bytes) | Description |
|----------------|-----------------|-------------------------------------------------------------------------------|
| timestamp | 4 | send time (unix timestamp) |
2025-07-18 12:56:31 +10:00
| sync timestamp | 4 | NOTE: room server only! - sender's "sync messages SINCE x" timestamp |
2025-05-26 18:22:31 -07:00
| password | rest of message | password for repeater/room |
# Group text message / datagram
2025-06-20 17:59:55 -07:00
| Field | Size (bytes) | Description |
|--------------|-----------------|--------------------------------------------|
2025-07-18 12:56:31 +10:00
| channel hash | 1 | first byte of SHA256 of channel's shared key |
2025-06-20 17:59:55 -07:00
| cipher MAC | 2 | MAC for encrypted data in next field |
| ciphertext | rest of payload | encrypted message, see below for details |
2025-05-26 18:22:31 -07:00
2025-06-20 17:59:55 -07:00
The plaintext contained in the ciphertext matches the format described in [plain text message ](#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 `<sender name>: <message body>` (eg., `user123: I'm on my way` ).
2025-05-26 18:22:31 -07:00
TODO: describe what datagram looks like
# Custom packet
Custom packets have no defined format.