From 7d2ff381207c3b84ee083ebc0fe45bfb653c5151 Mon Sep 17 00:00:00 2001 From: mikecarper Date: Tue, 16 Jun 2026 13:15:52 -0700 Subject: [PATCH] Trim direct retry cleanup --- examples/simple_repeater/MyMesh.cpp | 13 ------------- examples/simple_repeater/MyMesh.h | 3 --- src/Mesh.cpp | 5 ++--- src/Mesh.h | 10 ++++++++-- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/examples/simple_repeater/MyMesh.cpp b/examples/simple_repeater/MyMesh.cpp index 05c308bc..4261edd9 100644 --- a/examples/simple_repeater/MyMesh.cpp +++ b/examples/simple_repeater/MyMesh.cpp @@ -579,10 +579,6 @@ uint8_t MyMesh::getDirectRetryCodingRateForSNR(int8_t snr_x4) const { return 7; } -uint8_t MyMesh::getDirectRetryPreset() const { - return _prefs.retry_preset; -} - uint8_t MyMesh::getDirectRetryConfiguredMaxAttempts() const { return constrain(_prefs.direct_retry_attempts, 1, 15); } @@ -631,11 +627,6 @@ void MyMesh::configureDirectRetryPacket(mesh::Packet* retry, const mesh::Packet* retry->tx_cr = getDirectRetryCodingRateForSNR(snr_x4); } -bool MyMesh::maybeShortCircuitDirect(mesh::Packet* packet) { - (void)packet; - return false; -} - uint32_t MyMesh::getDirectRetryEchoDelay(const mesh::Packet* packet) const { (void)packet; return 200; @@ -1071,7 +1062,6 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc next_local_advert = next_flood_advert = 0; dirty_contacts_expiry = 0; set_radio_at = revert_radio_at = 0; - active_bw = 0.0f; active_sf = 0; active_cr = 0; _logging = false; @@ -1184,7 +1174,6 @@ void MyMesh::begin(FILESYSTEM *fs) { #endif radio_driver.setParams(_prefs.freq, _prefs.bw, _prefs.sf, _prefs.cr); - active_bw = _prefs.bw; active_sf = _prefs.sf; active_cr = _prefs.cr; radio_driver.setTxPower(_prefs.tx_power_dbm); @@ -1514,7 +1503,6 @@ void MyMesh::loop() { if (set_radio_at && millisHasNowPassed(set_radio_at)) { // apply pending (temporary) radio params set_radio_at = 0; // clear timer radio_driver.setParams(pending_freq, pending_bw, pending_sf, pending_cr); - active_bw = pending_bw; active_sf = pending_sf; active_cr = pending_cr; MESH_DEBUG_PRINTLN("Temp radio params"); @@ -1523,7 +1511,6 @@ void MyMesh::loop() { if (revert_radio_at && millisHasNowPassed(revert_radio_at)) { // revert radio params to orig revert_radio_at = 0; // clear timer radio_driver.setParams(_prefs.freq, _prefs.bw, _prefs.sf, _prefs.cr); - active_bw = _prefs.bw; active_sf = _prefs.sf; active_cr = _prefs.cr; MESH_DEBUG_PRINTLN("Radio params restored"); diff --git a/examples/simple_repeater/MyMesh.h b/examples/simple_repeater/MyMesh.h index 055b4b83..fddbed3e 100644 --- a/examples/simple_repeater/MyMesh.h +++ b/examples/simple_repeater/MyMesh.h @@ -110,7 +110,6 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks { unsigned long set_radio_at, revert_radio_at; float pending_freq; float pending_bw; - float active_bw; // live BW, including temporary radio overrides uint8_t pending_sf; uint8_t active_sf; // live SF, including temporary radio overrides uint8_t pending_cr; @@ -125,7 +124,6 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks { bool extractDirectRetryPrefix(const mesh::Packet* packet, uint8_t* prefix, uint8_t& prefix_len) const; int8_t getDirectRetryMinSNRX4() const; uint8_t getDirectRetryCodingRateForSNR(int8_t snr_x4) const; - uint8_t getDirectRetryPreset() const; uint8_t getDirectRetryConfiguredMaxAttempts() const; uint32_t getDirectRetryAttemptStepMillis() const; void putNeighbour(const mesh::Identity& id, uint32_t timestamp, float snr); @@ -157,7 +155,6 @@ protected: uint32_t getDirectRetransmitDelay(const mesh::Packet* packet) override; uint8_t getDefaultTxCodingRate() const override { return active_cr; } bool allowDirectRetry(const mesh::Packet* packet, const uint8_t* next_hop_hash, uint8_t next_hop_hash_len) const override; - bool maybeShortCircuitDirect(mesh::Packet* packet) override; void configureDirectRetryPacket(mesh::Packet* retry, const mesh::Packet* original, uint8_t retry_attempt) override; uint32_t getDirectRetryEchoDelay(const mesh::Packet* packet) const override; uint8_t getDirectRetryMaxAttempts(const mesh::Packet* packet) const override; diff --git a/src/Mesh.cpp b/src/Mesh.cpp index 0bac461b..a4b2750d 100644 --- a/src/Mesh.cpp +++ b/src/Mesh.cpp @@ -185,7 +185,7 @@ DispatcherAction Mesh::onRecvPacket(Packet* pkt) { } } - if (self_id.isHashMatch(pkt->path, pkt->getPathHashSize()) || maybeShortCircuitDirect(pkt)) { + if (self_id.isHashMatch(pkt->path, pkt->getPathHashSize())) { if (allowPacketForward(pkt)) { if (pkt->getPayloadType() == PAYLOAD_TYPE_MULTIPART) { return forwardMultipartDirect(pkt); @@ -448,9 +448,8 @@ DispatcherAction Mesh::routeRecvPacket(Packet* packet) { packet->setPathHashCount(n + 1); uint32_t d = getRetransmitDelay(packet); - uint8_t priority = packet->getPathHashCount(); // as this propagates outwards, give it lower and lower priority - return ACTION_RETRANSMIT_DELAYED(priority, d); // give priority to closer sources, than ones further away + return ACTION_RETRANSMIT_DELAYED(packet->getPathHashCount(), d); // give priority to closer sources, than ones further away } return ACTION_RELEASE; } diff --git a/src/Mesh.h b/src/Mesh.h index 4511b394..523c204b 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -111,8 +111,6 @@ protected: /** * \brief Allow subclasses to rewrite a non-TRACE DIRECT packet path when this node can safely skip ahead. */ - virtual bool maybeShortCircuitDirect(Packet* packet) { return false; } - /** * \returns milliseconds to wait for the next-hop echo before queueing one retry of the DIRECT packet. */ @@ -190,6 +188,8 @@ protected: /** * \brief A path TO peer (sender_idx) has been received. (also with optional 'extra' data encoded) + * NOTE: these can be received multiple times (per sender), via different routes + * NOTE: these can be received multiple times (per sender), via differen routes * \param sender_idx index of peer, [0..n) where n is what searchPeersByHash() returned * \param secret the pre-calculated shared-secret (handy for sending response packet) * \returns true, if path was accepted and that reciprocal path should be sent @@ -212,6 +212,8 @@ protected: /** * \brief A path TO 'sender' has been received. (also with optional 'extra' data encoded) + * NOTE: these can be received multiple times (per sender), via different routes + * NOTE: these can be received multiple times (per sender), via differen routes */ virtual void onPathRecv(Packet* packet, Identity& sender, uint8_t* path, uint8_t path_len, uint8_t extra_type, uint8_t* extra, uint8_t extra_len) { } @@ -293,10 +295,14 @@ public: void sendDirect(Packet* packet, const uint8_t* path, uint8_t path_len, uint32_t delay_millis=0); /** + * \brief send a locally-generated Packet to just neighbor nodes (zero hops) + * \brief send a locally-generated Packet to just neigbor nodes (zero hops) */ void sendZeroHop(Packet* packet, uint32_t delay_millis=0); /** + * \brief send a locally-generated Packet to just neighbor nodes (zero hops), with specific transport codes + * \brief send a locally-generated Packet to just neigbor nodes (zero hops), with specific transort 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);