mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-04 02:34:14 +00:00
set hops to hop_max and set hop_max to 15 when using coverage filter
This commit is contained in:
parent
2e3283b2fb
commit
5ce10c0698
@ -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
|
||||
|
@ -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
|
||||
@ -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
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user