Skip to content

Commit

Permalink
updated coverage is not needed unless rebroadcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
medentem committed Jan 6, 2025
1 parent 5c27934 commit 10103fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/mesh/FloodingRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ bool FloodingRouter::perhapsRebroadcast(const meshtastic_MeshPacket *p)
CoverageFilter incomingCoverage;
loadCoverageFilterFromPacket(p, incomingCoverage);

CoverageFilter updatedCoverage = incomingCoverage;
mergeMyCoverage(updatedCoverage);

float forwardProb = calculateForwardProbability(incomingCoverage, updatedCoverage, p->from);
float forwardProb = calculateForwardProbability(incomingCoverage, p->from);

float rnd = static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
if (rnd <= forwardProb) {
Expand All @@ -95,6 +92,9 @@ bool FloodingRouter::perhapsRebroadcast(const meshtastic_MeshPacket *p)
}
#endif

CoverageFilter updatedCoverage = incomingCoverage;
mergeMyCoverage(updatedCoverage);

storeCoverageFilterInPacket(updatedCoverage, tosend);

LOG_INFO("Rebroadcasting packet ID=0x%x with ForwardProb=%.2f", p->id, forwardProb);
Expand Down Expand Up @@ -161,7 +161,7 @@ void FloodingRouter::mergeMyCoverage(CoverageFilter &coverage)
coverage.add(nodeDB->getNodeNum());
}

float FloodingRouter::calculateForwardProbability(const CoverageFilter &incoming, const CoverageFilter &updated, NodeNum from)
float FloodingRouter::calculateForwardProbability(const CoverageFilter &incoming, NodeNum from)
{
#ifdef USERPREFS_USE_COVERAGE_FILTER
bool useCoverageFilter = USERPREFS_USE_COVERAGE_FILTER;
Expand Down
2 changes: 1 addition & 1 deletion src/mesh/FloodingRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class FloodingRouter : public Router, protected PacketHistory

void mergeMyCoverage(CoverageFilter &coverage);

float calculateForwardProbability(const CoverageFilter &incoming, const CoverageFilter &updated, NodeNum from);
float calculateForwardProbability(const CoverageFilter &incoming, NodeNum from);

public:
/**
Expand Down

0 comments on commit 10103fe

Please sign in to comment.