Skip to content

Commit

Permalink
set hops to hop_max and set hop_max to 15 when using coverage filter
Browse files Browse the repository at this point in the history
  • Loading branch information
medentem committed Jan 7, 2025
1 parent 2e3283b commit 5ce10c0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/mesh/MeshTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ enum RxSource {
* maxhops to 3 should be fine for a while. This also serves to prevent routing/flooding attempts to be attempted for
* too long.
**/

#define HOP_MAX 7
#ifdef USERPREFS_USE_COVERAGE_FILTER
bool useCoverageFilter = USERPREFS_USE_COVERAGE_FILTER;
if (useCoverageFilter)
#define HOP_MAX 15
#endif

/// We normally just use max 3 hops for sending reliable messages
#define HOP_RELIABLE 3
Expand Down
11 changes: 11 additions & 0 deletions src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,11 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
config.lora.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST;
#endif
config.lora.hop_limit = HOP_RELIABLE;
#ifdef USERPREFS_USE_COVERAGE_FILTER
bool useCoverageFilter = USERPREFS_USE_COVERAGE_FILTER;
if (useCoverageFilter)
config.lora.hop_limit = HOP_MAX;
#endif
#ifdef USERPREFS_CONFIG_LORA_IGNORE_MQTT
config.lora.ignore_mqtt = USERPREFS_CONFIG_LORA_IGNORE_MQTT;
#else
Expand Down Expand Up @@ -827,18 +832,22 @@ bool NodeDB::isValidCandidateForCoverage(const meshtastic_NodeInfoLite &node)
}
// 2) Exclude ignored
if (node.is_ignored) {
LOG_DEBUG("Node 0x%x is not valid for coverage: Ignored", node.num);
return false;
}
// 3) Exclude nodes that aren't direct neighbors
if (!node.has_hops_away || node.hops_away != 0) {
LOG_DEBUG("Node 0x%x is not valid for coverage: Not Direct Neighbor", node.num);
return false;
}
// 4) Exclude MQTT-based nodes if desired
if (node.via_mqtt) {
LOG_DEBUG("Node 0x%x is not valid for coverage: MQTT", node.num);
return false;
}
// 5) Must have last_heard
if (node.last_heard == 0) {
LOG_DEBUG("Node 0x%x is not valid for coverage: Missing Last Heard", node.num);
return false;
}
return true; // If we pass all checks, it's valid
Expand Down Expand Up @@ -895,6 +904,8 @@ std::vector<NodeNum> NodeDB::getCoveredNodes(uint32_t timeWindowSecs)
uint32_t age = now - node.last_heard;
if (age <= timeWindowSecs) {
allCandidates.push_back(NodeCandidate{node.num, node.last_heard, node.snr});
} else {
LOG_DEBUG("Node 0x%x is not valid for coverage: Aged Out", node.num);
}
}

Expand Down

0 comments on commit 5ce10c0

Please sign in to comment.