mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-23 17:13:38 +00:00
NodeInfo exchange: don't bother if too far away (#6260)
When we receive a NodeInfo from a new node, if it is more than 2 hops beyond our configured hop limit away from us, don't bother to send a NodeInfo back to it. In my dense urban environment, I see many nodes that are >= 5 hops away, but sending their NodeInfo with a hopStart of 6 or 7. In most cases I can imagine, this seems like a waste of airtime.
This commit is contained in:
parent
16a0dce83c
commit
7f17747d8c
@ -88,8 +88,16 @@ int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp)
|
|||||||
} else if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag && !nodeDB->getMeshNode(mp->from)->has_user &&
|
} else if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag && !nodeDB->getMeshNode(mp->from)->has_user &&
|
||||||
nodeInfoModule && !isPreferredRebroadcaster && !nodeDB->isFull()) {
|
nodeInfoModule && !isPreferredRebroadcaster && !nodeDB->isFull()) {
|
||||||
if (airTime->isTxAllowedChannelUtil(true)) {
|
if (airTime->isTxAllowedChannelUtil(true)) {
|
||||||
LOG_INFO("Heard new node on ch. %d, send NodeInfo and ask for response", mp->channel);
|
// Hops used by the request. If somebody in between running modified firmware modified it, ignore it
|
||||||
nodeInfoModule->sendOurNodeInfo(mp->from, true, mp->channel);
|
auto hopStart = mp->hop_start;
|
||||||
|
auto hopLimit = mp->hop_limit;
|
||||||
|
uint8_t hopsUsed = hopStart < hopLimit ? config.lora.hop_limit : hopStart - hopLimit;
|
||||||
|
if (hopsUsed > config.lora.hop_limit + 2) {
|
||||||
|
LOG_DEBUG("Skip send NodeInfo: %d hops away is too far away", hopsUsed);
|
||||||
|
} else {
|
||||||
|
LOG_INFO("Heard new node on ch. %d, send NodeInfo and ask for response", mp->channel);
|
||||||
|
nodeInfoModule->sendOurNodeInfo(mp->from, true, mp->channel);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG("Skip sending NodeInfo > 25%% ch. util");
|
LOG_DEBUG("Skip sending NodeInfo > 25%% ch. util");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user