fix(mesh): šířku path hashe bere každá TX cesta z prefs uzlu, ne z konstanty

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5 committed 2026-08-22 18:13:02 +02:00
1 parent 89f08f76b7
commit 906c675b4b
6 files changed
+56 -6

No files matched your search

+5
View File
@@ -113,6 +113,11 @@ protected:
bool filterRecvFloodPacket(mesh::Packet* packet) override;
bool allowPacketForward(const mesh::Packet* packet) override;
// Šířku path hashe volí ODESÍLATEL, takže musí přijít z prefs tohohle uzlu.
// Díky tomuhle overridu ji dostanou i volání send*(), která ji nepředávají
// explicitně (ACKy, PATH-return, zerohop odpovědi sousedovi).
uint8_t getSelfPathHashSize() const override { return _prefs.path_hash_mode + 1; }
void sendFloodScoped(const TransportKey& scope, mesh::Packet* pkt, uint32_t delay_millis);
void sendFloodScoped(const ContactInfo& recipient, mesh::Packet* pkt, uint32_t delay_millis=0) override;
void sendFloodScoped(const mesh::GroupChannel& channel, mesh::Packet* pkt, uint32_t delay_millis=0) override;
+5
View File
@@ -305,6 +305,11 @@ protected:
}
bool allowPacketForward(const mesh::Packet* packet) override;
// Šířku path hashe volí ODESÍLATEL, takže musí přijít z prefs tohohle uzlu.
// Díky tomuhle overridu ji dostanou i volání send*(), která ji nepředávají
// explicitně (ACKy, PATH-return, zerohop odpovědi sousedovi).
uint8_t getSelfPathHashSize() const override { return _prefs.path_hash_mode + 1; }
#ifdef BOT_CHANNEL_PSK
// CUSTOM (TeTeHacko): both are no-op virtuals in mesh::Mesh, which is the only
// reason a repeater is normally deaf to channel traffic. Overriding them does
+5
View File
@@ -159,6 +159,11 @@ protected:
mesh::DispatcherAction onRecvPacket(mesh::Packet* pkt) override;
bool allowPacketForward(const mesh::Packet* packet) override;
// Šířku path hashe volí ODESÍLATEL, takže musí přijít z prefs tohohle uzlu.
// Díky tomuhle overridu ji dostanou i volání send*(), která ji nepředávají
// explicitně (ACKy, PATH-return, zerohop odpovědi sousedovi).
uint8_t getSelfPathHashSize() const override { return _prefs.path_hash_mode + 1; }
void onAnonDataRecv(mesh::Packet* packet, const uint8_t* secret, const mesh::Identity& sender, uint8_t* data, size_t len) override;
int searchPeersByHash(const uint8_t* hash) override ;
void getPeerSharedSecret(uint8_t* dest_secret, int peer_idx) override;
+5
View File
@@ -116,6 +116,11 @@ protected:
// Mesh overrides
float getAirtimeBudgetFactor() const override;
bool allowPacketForward(const mesh::Packet* packet) override;
// Šířku path hashe volí ODESÍLATEL, takže musí přijít z prefs tohohle uzlu.
// Díky tomuhle overridu ji dostanou i volání send*(), která ji nepředávají
// explicitně (ACKy, PATH-return, zerohop odpovědi sousedovi).
uint8_t getSelfPathHashSize() const override { return _prefs.path_hash_mode + 1; }
int calcRxDelay(float score, uint32_t air_time) const override;
uint32_t getRetransmitDelay(const mesh::Packet* packet) override;
uint32_t getDirectRetransmitDelay(const mesh::Packet* packet) override;
+15 -1
View File
@@ -650,6 +650,7 @@ void Mesh::sendFlood(Packet* packet, uint32_t delay_millis, uint8_t path_hash_si
MESH_DEBUG_PRINTLN("%s Mesh::sendFlood(): TRACE type not suspported", getLogDateTime());
return;
}
if (path_hash_size == 0) path_hash_size = getSelfPathHashSize();
if (path_hash_size == 0 || path_hash_size > 3) {
MESH_DEBUG_PRINTLN("%s Mesh::sendFlood(): invalid path_hash_size", getLogDateTime());
return;
@@ -677,6 +678,7 @@ void Mesh::sendFlood(Packet* packet, uint16_t* transport_codes, uint32_t delay_m
MESH_DEBUG_PRINTLN("%s Mesh::sendFlood(): TRACE type not suspported", getLogDateTime());
return;
}
if (path_hash_size == 0) path_hash_size = getSelfPathHashSize();
if (path_hash_size == 0 || path_hash_size > 3) {
MESH_DEBUG_PRINTLN("%s Mesh::sendFlood(): invalid path_hash_size", getLogDateTime());
return;
@@ -701,10 +703,12 @@ void Mesh::sendFlood(Packet* packet, uint16_t* transport_codes, uint32_t delay_m
sendPacket(packet, pri, delay_millis);
}
void Mesh::sendDirect(Packet* packet, const uint8_t* path, uint8_t path_len, uint32_t delay_millis) {
void Mesh::sendDirect(Packet* packet, const uint8_t* path, uint8_t path_len, uint32_t delay_millis, uint8_t path_hash_size) {
packet->header &= ~PH_ROUTE_MASK;
packet->header |= ROUTE_TYPE_DIRECT;
if (path_hash_size == 0) path_hash_size = getSelfPathHashSize();
uint8_t pri;
if (packet->getPayloadType() == PAYLOAD_TYPE_TRACE) { // TRACE packets are different
// for TRACE packets, path is appended to end of PAYLOAD. (path is used for SNR's)
@@ -715,6 +719,12 @@ void Mesh::sendDirect(Packet* packet, const uint8_t* path, uint8_t path_len, uin
pri = 5; // maybe make this configurable
} else {
packet->path_len = Packet::copyPath(packet->path, path, path_len);
// An empty path has no hash-size bits of its own to preserve, and a bare 0 decodes as
// 1 byte. Zero-hop DIRECT is the common case for a neighbour reply, so without this a
// 2-byte node declares 1 byte on every such reply.
if (packet->getPathHashCount() == 0) {
packet->setPathHashSizeAndCount(path_hash_size, 0);
}
if (packet->getPayloadType() == PAYLOAD_TYPE_PATH) {
pri = 1; // slightly less priority
} else {
@@ -729,6 +739,8 @@ void Mesh::sendZeroHop(Packet* packet, uint32_t delay_millis, uint8_t path_hash_
packet->header &= ~PH_ROUTE_MASK;
packet->header |= ROUTE_TYPE_DIRECT;
if (path_hash_size == 0) path_hash_size = getSelfPathHashSize();
// Zero Hop = nulový počet hopů. POZOR, dřív tu bylo `packet->path_len = 0`,
// což vynulovalo CELÝ bajt — a v jeho horních dvou bitech bydlí šířka hashe
// (Packet.h:85). Každý zerohop paket proto hlásil 1 B bez ohledu na
@@ -743,6 +755,8 @@ void Mesh::sendZeroHop(Packet* packet, uint32_t delay_millis, uint8_t path_hash_
void Mesh::sendZeroHop(Packet* packet, uint16_t* transport_codes, uint32_t delay_millis, uint8_t path_hash_size) {
packet->header &= ~PH_ROUTE_MASK;
packet->header |= ROUTE_TYPE_TRANSPORT_DIRECT;
if (path_hash_size == 0) path_hash_size = getSelfPathHashSize();
packet->transport_codes[0] = transport_codes[0];
packet->transport_codes[1] = transport_codes[1];
+21 -5
View File
@@ -71,6 +71,17 @@ protected:
*/
virtual uint8_t getExtraAckTransmitCount() const;
/**
* \brief Width (in bytes) of the path hashes this node writes into packets it originates.
*
* Sender-chosen, so it must come from this node's own prefs. The base class has no prefs
* and returns the protocol minimum; firmwares with a NodePrefs override it. Used whenever
* a send*() caller does not pass an explicit width.
*
* \returns 1, 2 or 3
*/
virtual uint8_t getSelfPathHashSize() const { return 1; }
/**
* \brief Perform search of local DB of peers/contacts.
* \returns Number of peers with matching hash
@@ -199,18 +210,23 @@ public:
/**
* \brief send a locally-generated Packet with flood routing
*/
void sendFlood(Packet* packet, uint32_t delay_millis=0, uint8_t path_hash_size=1);
void sendFlood(Packet* packet, uint32_t delay_millis=0, uint8_t path_hash_size=0);
/**
* \brief send a locally-generated Packet with flood routing
* \param transport_codes array of 2 codes to attach to packet
*/
void sendFlood(Packet* packet, uint16_t* transport_codes, uint32_t delay_millis=0, uint8_t path_hash_size=1);
void sendFlood(Packet* packet, uint16_t* transport_codes, uint32_t delay_millis=0, uint8_t path_hash_size=0);
/**
* \brief send a locally-generated Packet with Direct routing
*
* `path_len` is the ENCODED path byte (hash-size bits + hop count), so a non-empty path
* carries its own width across unchanged. An EMPTY path has no width to carry, and a bare
* 0 decodes as 1 byte -- which is why zero-hop replies used to declare 1 B on a 2 B node.
* `path_hash_size` (0 = this node's prefs) fills that gap.
*/
void sendDirect(Packet* packet, const uint8_t* path, uint8_t path_len, uint32_t delay_millis=0);
void sendDirect(Packet* packet, const uint8_t* path, uint8_t path_len, uint32_t delay_millis=0, uint8_t path_hash_size=0);
/**
* \brief send a locally-generated Packet to just neighbor nodes (zero hops)
@@ -218,13 +234,13 @@ public:
// `path_hash_size` tu je ze stejného důvodu jako u sendFlood: zerohop paket
// sice cestu nenese, ale ta šířka je v hlavičce a analyzery z ní odvozují,
// na kolika bajtech uzel jede. Bez toho parametru hlásí každý zerohop 1 B.
void sendZeroHop(Packet* packet, uint32_t delay_millis=0, uint8_t path_hash_size=1);
void sendZeroHop(Packet* packet, uint32_t delay_millis=0, uint8_t path_hash_size=0);
/**
* \brief send a locally-generated Packet to just neighbor nodes (zero hops), with specific transport codes
* \param transport_codes array of 2 codes to attach to packet
*/
void sendZeroHop(Packet* packet, uint16_t* transport_codes, uint32_t delay_millis=0, uint8_t path_hash_size=1);
void sendZeroHop(Packet* packet, uint16_t* transport_codes, uint32_t delay_millis=0, uint8_t path_hash_size=0);
};