diff --git a/docs/cli_commands.md b/docs/cli_commands.md index 78c73f8d..8363f39e 100644 --- a/docs/cli_commands.md +++ b/docs/cli_commands.md @@ -1399,8 +1399,8 @@ set flood.retry.bucket 2 none **Default:** `15` with the `rooftop` preset -**Note:** Direct-routed type 2 text packets always use 21 retry attempts, -regardless of this setting or the short-path cap. +**Note:** Direct-routed type 2 text packets always use 21 retry attempts in the +shared retry logic, regardless of this setting or the repeater short-path cap. **Examples:** ``` @@ -1427,6 +1427,8 @@ set direct.retry.count 15 - The failed echo window includes a packet-length add-on. TRACE and ANON_REQ/type 7 packets keep the existing 4x line-time add-on. TXT_MSG/type 2 packets use 7x. Other direct retry packets use 6x. +- Non-repeater firmware uses the same packet-type add-ons with the shared + fixed base retry timing. - For non-TRACE direct paths shorter than 6 remaining hops, the effective wait is scaled by `hops / 6`. - Non-TRACE direct paths with 6 or more remaining hops use the configured value unchanged. - TRACE retries shorter than 16 remaining hops use `hops / 16`; 16 or more remaining hops use the configured value unchanged. @@ -1458,6 +1460,8 @@ set direct.retry.base 500 - This is added after the failed echo window. TRACE and ANON_REQ/type 7 packets keep the existing 4x packet-length add-on. TXT_MSG/type 2 packets use 7x. Other direct retry packets use 6x. +- Non-repeater firmware uses the same packet-type add-ons with the shared + fixed retry step. - For non-TRACE direct paths shorter than 6 remaining hops, that computed delay is scaled by `hops / 6`. - Non-TRACE direct paths with 6 or more remaining hops use the computed delay unchanged. - TRACE retries shorter than 16 remaining hops use `hops / 16`; 16 or more remaining hops use the computed delay unchanged. diff --git a/docs/halo_keymind_settings.md b/docs/halo_keymind_settings.md index 2ee56723..9ef40190 100644 --- a/docs/halo_keymind_settings.md +++ b/docs/halo_keymind_settings.md @@ -183,7 +183,7 @@ direct `altpath` sends the second packet. ## Direct Retry Settings -Direct retry applies to direct-routed packets. A queued resend is canceled when the next-hop echo is heard. +Direct retry applies to direct-routed packets. A queued resend is canceled when the next-hop echo is heard. Repeaters expose the settings below; non-repeater firmware uses the same packet-type timing rules with fixed shared base/step timing. | Setting | What it does | How to use | Example | | --- | --- | --- | --- | diff --git a/examples/simple_repeater/MyMesh.cpp b/examples/simple_repeater/MyMesh.cpp index 6809014d..18a28301 100644 --- a/examples/simple_repeater/MyMesh.cpp +++ b/examples/simple_repeater/MyMesh.cpp @@ -1004,13 +1004,7 @@ uint32_t MyMesh::getDirectRetryEchoDelay(const mesh::Packet* packet) const { // Wait roughly long enough for our TX, the next hop's receive/forward window, and its echo back. uint32_t bits = ((uint32_t)packet->getRawLength()) * 8; - uint8_t payload_type = packet->getPayloadType(); - float length_factor = 6.0f; - if (payload_type == PAYLOAD_TYPE_TRACE || payload_type == PAYLOAD_TYPE_ANON_REQ) { - length_factor = 4.0f; - } else if (payload_type == PAYLOAD_TYPE_TXT_MSG) { - length_factor = 7.0f; - } + float length_factor = (float)getDirectRetryPacketAirtimeFactor(packet); uint32_t scaled_wait_millis = (uint32_t)((((float)bits) * length_factor) / kbps); return base_wait_millis + scaled_wait_millis; } diff --git a/src/Mesh.cpp b/src/Mesh.cpp index 7f9cba6d..0ecb2412 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -228,17 +228,37 @@ bool Mesh::allowDirectRetry(const Packet* packet, const uint8_t* next_hop_hash, (void)next_hop_hash_len; return true; } +uint8_t Mesh::getDirectRetryPacketAirtimeFactor(const Packet* packet) const { + if (packet == NULL) { + return 6; + } + + uint8_t payload_type = packet->getPayloadType(); + if (payload_type == PAYLOAD_TYPE_TRACE || payload_type == PAYLOAD_TYPE_ANON_REQ) { + return 4; + } + if (payload_type == PAYLOAD_TYPE_TXT_MSG) { + return 7; + } + return 6; +} +uint32_t Mesh::getDirectRetryPacketAirtimeDelay(const Packet* packet) const { + if (packet == NULL || _radio == NULL) { + return 0; + } + + return _radio->getEstAirtimeFor(packet->getRawLength()) * (uint32_t)getDirectRetryPacketAirtimeFactor(packet); +} uint32_t Mesh::getDirectRetryEchoDelay(const Packet* packet) const { - (void)packet; - // Keep the base fallback aligned with the repeater's minimum retry wait. - return 200; + return 200 + getDirectRetryPacketAirtimeDelay(packet); } uint8_t Mesh::getDirectRetryMaxAttempts(const Packet* packet) const { - (void)packet; + if (packet != NULL && packet->getPayloadType() == PAYLOAD_TYPE_TXT_MSG) { + return 21; + } return DIRECT_RETRY_MAX_ATTEMPTS_DEFAULT; } uint32_t Mesh::getDirectRetryAttemptDelay(const Packet* packet, uint8_t attempt_idx) { - (void)packet; uint32_t base = getDirectRetryEchoDelay(packet); // Keep the historical linear spacing while allowing the base wait to vary by platform/profile. return base + ((uint32_t)attempt_idx * 100UL); diff --git a/src/Mesh.h b/src/Mesh.h index 72fcfac1..8a4bdb6c 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -150,6 +150,16 @@ protected: */ virtual uint32_t getDirectRetryEchoDelay(const Packet* packet) const; + /** + * \returns packet-airtime multiplier used by the direct-retry echo window. + */ + uint8_t getDirectRetryPacketAirtimeFactor(const Packet* packet) const; + + /** + * \returns packet-airtime add-on used by the direct-retry echo window. + */ + uint32_t getDirectRetryPacketAirtimeDelay(const Packet* packet) const; + /** * \returns maximum number of retry transmissions after the initial direct TX. */