feat(mesh): default to 2-byte path hashes (PATH_HASH_MODE_DEFAULT)

Upstream never initialises _prefs.path_hash_mode, so a fresh node came up at
mode 0 = 1 byte per hop. Nobody on the CZ mesh runs 1 B any more, which meant
every new install needed a manual `set path.hash.mode 1`. Default it to 1 at
compile time in both the repeater and the companion; the pref still overrides
it, so existing nodes are unaffected.

NOTE this is the PATH hash, not PATH_HASH_SIZE. It is used as
sendFlood(..., path_hash_mode + 1), i.e. the bytes each hop appends to the path
while flooding, and the size travels in the packet -- Packet.h:85 packs it into
the top two bits of path_len and Mesh.cpp:93 matches with getPathHashSize() --
so mixed-mode nodes still route for each other. PATH_HASH_SIZE (1) is a
different field, the destination and channel hash in Mesh.cpp:458/548, and
changing THAT would break the wire format against every other node in the mesh.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5 committed 2026-08-03 19:12:15 +02:00
1 parent 85be4a76a6
commit bfdaf32d30
2 files changed
+26

No files matched your search

+9
View File
@@ -876,6 +876,15 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
_prefs.bw = LORA_BW;
_prefs.cr = LORA_CR;
_prefs.tx_power_dbm = LORA_TX_POWER;
// CUSTOM (TeTeHacko): 2-byte path hashes by default, same as the repeater --
// upstream left this unset, so a fresh node came up at mode 0 = 1 byte per
// hop, which nobody on the CZ mesh runs any more. See the longer note in
// simple_repeater/MyMesh.cpp: this is the PATH hash (bytes each hop appends
// while flooding, size carried in the packet), NOT PATH_HASH_SIZE.
#ifndef PATH_HASH_MODE_DEFAULT
#define PATH_HASH_MODE_DEFAULT 1 // 1 = 2 bytes per hop
#endif
_prefs.path_hash_mode = PATH_HASH_MODE_DEFAULT;
_prefs.gps_enabled = 0; // GPS disabled by default
_prefs.gps_interval = 0; // No automatic GPS updates by default
//_prefs.rx_delay_base = 10.0f; enable once new algo fixed