Files
ratdeck/src/reticulum/LXMFMessage.h
T
DeFiDude 71849cbb62 Fix LXMF wire format for Python interoperability
Opportunistic (non-link) delivery must strip dest_hash from the LXMF
payload — it's carried by the RNS packet header. Python prepends it
back on receive; we now do the same. Previously ratdeck always included
dest_hash when sending and never prepended it when receiving, breaking
interop in both directions.

- packFull: return [src:16][sig:64][msgpack] instead of [dest:16][src:16][sig:64][msgpack]
- onPacketReceived: prepend dest_hash from packet header before unpacking
- sendDirect: use messageId computed by packFull instead of re-hashing wire payload
- Add docs/WIRE-FORMAT.md documenting the exact format for all delivery methods
2026-03-19 12:37:09 -06:00

34 lines
895 B
C++

#pragma once
#include <Arduino.h>
#include <Bytes.h>
#include <Identity.h>
#include <string>
#include <vector>
enum class LXMFStatus : uint8_t {
DRAFT = 0, QUEUED, SENDING, SENT, DELIVERED, FAILED
};
struct LXMFMessage {
RNS::Bytes sourceHash;
RNS::Bytes destHash;
double timestamp = 0;
std::string content;
std::string title;
RNS::Bytes signature;
LXMFStatus status = LXMFStatus::DRAFT;
bool incoming = false;
bool read = false;
int retries = 0;
unsigned long lastRetryMs = 0;
uint32_t savedCounter = 0;
RNS::Bytes messageId;
static std::vector<uint8_t> packContent(double timestamp, const std::string& content, const std::string& title);
std::vector<uint8_t> packFull(const RNS::Identity& signingIdentity);
static bool unpackFull(const uint8_t* data, size_t len, LXMFMessage& msg);
const char* statusStr() const;
};