feat(channels): capture raw_packet at send time for raw resend

PR #2 of 5. Builds the full GRP_TXT wire bytes (header + transport_codes if
scoped + path_len + encrypted payload) from the ts+0 pkt_payload guess and
stores it in channel_messages.raw_packet right after the send. When echo
correlation later identifies the actual pkt_payload (potentially using a
different ±dt candidate due to host/firmware clock drift), the raw_packet is
rebuilt from the actual one so a future resend matches the original packet
hash and dedupes at the repeaters.

Transport-scope codes are computed in Python via HMAC-SHA256(scope_key,
payload_type||payload)[:2], mirroring TransportKey::calcTransportCode in
MeshCore Core (including the 0x0000/0xFFFF reservations).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-06-09 12:27:17 +02:00
parent bed838c365
commit fa0b1c9109
2 changed files with 102 additions and 3 deletions
+8
View File
@@ -993,6 +993,14 @@ class Database:
(pkt_payload, msg_id)
)
def update_message_raw_packet(self, msg_id: int, raw_packet: str) -> None:
"""Set raw_packet on a channel message (full wire bytes for raw resend)."""
with self._connect() as conn:
conn.execute(
"UPDATE channel_messages SET raw_packet = ? WHERE id = ?",
(raw_packet, msg_id)
)
# ================================================================
# Paths
# ================================================================