Preserve MeshCore preambles with Meshtext and allow MQTT upload
This commit is contained in:
1 parent
9363ad4f95
commit
6b75ad07d3
8 files changed
+304
-5
No files matched your search
@@ -228,6 +228,13 @@ class RadioProfiles {
|
||||
if (p.protocol == RadioProfileProtocol::Meshtext) return 16;
|
||||
if (p.preamble) return p.preamble;
|
||||
if (!enabled()) return single_profile_default;
|
||||
// A foreign profile cannot teach MeshCore peers our scan timing. Keep
|
||||
// the normal network's canonical TX preamble (including during startup),
|
||||
// since peers' RXPS header windows depend on it. Scanning remains best
|
||||
// effort; chirpTiming() still reports any longer capture recommendation.
|
||||
if (profile == 0 && p.protocol == RadioProfileProtocol::MeshCore
|
||||
&& secondary.params.protocol == RadioProfileProtocol::Meshtext)
|
||||
return single_profile_default;
|
||||
// Do not expose an unmeasured short preamble while the startup test runs.
|
||||
if (!switchTestReady()) return MaxAutomaticPreamble;
|
||||
double symbols = automaticPreamble(profile);
|
||||
|
||||
@@ -283,6 +283,9 @@ size_t encodeText(uint32_t from, uint32_t id, uint8_t hop_limit, const char* cha
|
||||
if (text_len >= 128) data[count++] = static_cast<uint8_t>(text_len) | 0x80;
|
||||
data[count++] = static_cast<uint8_t>(text_len >> (text_len >= 128 ? 7 : 0));
|
||||
memcpy(data + count, text, text_len); count += text_len;
|
||||
// Data.bitfield field 9, bit 0: allow a receiving gateway to upload to MQTT.
|
||||
// This is consent, not the radio header's via_mqtt origin flag.
|
||||
data[count++] = 0x48; data[count++] = 1;
|
||||
return finishFrame(from, id, hop_limit, channel_name, key, key_len, out, count);
|
||||
}
|
||||
|
||||
@@ -319,6 +322,7 @@ size_t encodeNodeInfo(uint32_t from, uint32_t id, uint8_t hop_limit, const char*
|
||||
data[count++] = 0x38; data[count++] = 1; // Config.DeviceConfig.Role.CLIENT_MUTE.
|
||||
data[count++] = 0x48; data[count++] = 1; // User.is_unmessagable explicitly true.
|
||||
data[3] = static_cast<uint8_t>(count - 4);
|
||||
data[count++] = 0x48; data[count++] = 1; // Data.bitfield: MQTT upload consent.
|
||||
return finishFrame(from, id, hop_limit, channel_name, key, key_len, out, count);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,11 @@ bool modemConfig(Region region, Preset preset, RadioProfileParams& params, uint3
|
||||
|
||||
static constexpr size_t HeaderSize = 16;
|
||||
static constexpr size_t MaxFrameSize = 255;
|
||||
static constexpr size_t MaxDataSize = 233;
|
||||
static constexpr size_t MaxTextSize = 228; // Data port + payload tag/length overhead.
|
||||
static constexpr size_t MaxTextSize = 228;
|
||||
// Keep the existing text limit with port/payload (5B) and MQTT consent (2B).
|
||||
// The peer's 233B limit applies to Data.payload, not the complete protobuf.
|
||||
static constexpr size_t MaxDataSize = MaxTextSize + 7;
|
||||
static_assert(HeaderSize + MaxDataSize <= MaxFrameSize, "Meshtext frame exceeds radio limit");
|
||||
static constexpr size_t MaxLongNameSize = 24; // Current stock User.long_name bound.
|
||||
static constexpr size_t MaxShortNameSize = 4; // Stock max_size:5 includes NUL.
|
||||
static constexpr size_t MaxShortNameCharacters = 4; // Unicode scalar values.
|
||||
@@ -44,6 +47,8 @@ struct DecodedText {
|
||||
|
||||
// Expanded AES-128/256 PSK only. No unencrypted-key fallback. Names are exact,
|
||||
// canonical peer channel names (<12 bytes), without local display markers.
|
||||
// Outgoing text and explicit NodeInfo permit peer MQTT upload (Data.bitfield
|
||||
// bit 0); this neither enables a local MQTT client nor marks traffic via_mqtt.
|
||||
// Returns 0 for invalid arguments, malformed UTF-8, embedded NUL or overflow.
|
||||
size_t encodeText(uint32_t from, uint32_t id, uint8_t hop_limit, const char* channel_name,
|
||||
const uint8_t* key, size_t key_len, const char* text, size_t text_len,
|
||||
|
||||
Reference in new issue
Block a user