From ade42830e0a22ced816cf2eb3e731703556c5694 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Wed, 8 Jul 2026 06:59:07 -0700 Subject: [PATCH] Re-enable wantresponse and other fields in simradio when on the decoded path (#10934) * Re-enable wantresponse and other fields in simradio when on the decoded path * Make the comments less verbose --- src/platform/portduino/SimRadio.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/platform/portduino/SimRadio.cpp b/src/platform/portduino/SimRadio.cpp index 14465a09f..eb970df48 100644 --- a/src/platform/portduino/SimRadio.cpp +++ b/src/platform/portduino/SimRadio.cpp @@ -252,7 +252,14 @@ void SimRadio::startSend(meshtastic_MeshPacket *txp) // pb_encode_to_bytes writes into decoded.payload, which aliases `encrypted` in the union, so all // reads of p->encrypted above must be complete before this point. - p->decoded = meshtastic_Data_init_zero; + if (carryEncrypted) { + // On the encrypted path, `decoded` aliases the ciphertext we just copied into c.data; + // the remaining `Data` fields hold ciphertext bytes that would serialize as spurious + // wire fields, so clear the struct. + p->decoded = meshtastic_Data_init_zero; + } + // On the decoded path, `p->decoded` is already a valid Data from perhapsDecode(), + // so retain the existing fields (want_response, request_id, bitfield, etc.) p->which_payload_variant = meshtastic_MeshPacket_decoded_tag; p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &meshtastic_Compressed_msg, &c); @@ -409,4 +416,4 @@ int16_t SimRadio::getCurrentRSSI() { // Simulated radio - return a reasonable default noise floor return -120; -} \ No newline at end of file +}