Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/mesh/ReliableRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
ErrorCode ReliableRouter::send(meshtastic_MeshPacket *p)
{
if (p->want_ack) {
// If someone asks for acks on broadcast, we need the hop limit to be at least one, so that first node that receives our
// message will rebroadcast. But asking for hop_limit 0 in that context means the client app has no preference on hop
// counts and we want this message to get through the whole mesh, so use the default.
if (p->hop_limit == 0) {
p->hop_limit = Default::getConfiguredOrDefaultHopLimit(config.lora.hop_limit);
}
DEBUG_HEAP_BEFORE;
auto copy = packetPool.allocCopy(*p);
DEBUG_HEAP_AFTER("ReliableRouter::send", copy);
Expand Down
7 changes: 7 additions & 0 deletions src/mesh/Router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ ErrorCode Router::sendLocal(meshtastic_MeshPacket *p, RxSource src)
}
}

// If someone asks for acks on broadcast, we need the hop limit to be at least one, so that first node that receives our
// message will rebroadcast. But asking for hop_limit 0 in that context means the client app has no preference on hop
// counts and we want this message to get through the whole mesh, so use the default.
if (src == RX_SRC_USER && p->want_ack && p->hop_limit == 0) {
p->hop_limit = Default::getConfiguredOrDefaultHopLimit(config.lora.hop_limit);
}
Comment on lines +269 to +274

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentions "asks for acks on broadcast" but the condition doesn't check if the packet is a broadcast. According to the comment's logic, this code should only apply when the packet is a broadcast (to ensure the first node that receives it will rebroadcast). For unicast packets with want_ack and hop_limit==0, the user likely wants a direct 0-hop message, which is the goal of this PR.

Consider adding a broadcast check to match the comment:

if (src == RX_SRC_USER && p->want_ack && p->hop_limit == 0 && isBroadcast(p->to))

This would ensure that unicast 0-hop requests from users are honored as direct messages, while broadcast messages with want_ack still use the default hop limit as intended.

Copilot uses AI. Check for mistakes.

@esev esev Jan 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though the comment mentions broadcasts, I'm hesitant to make this change in this PR. The original logic where the comment was copied from didn't check for broadcasts, and I'd like to keep this PR scoped to the 0 hop replies.

It's also not super clear to me that the 'broadcast' in the comment is intended to refer to "the ^all To address". I suspect it is referring to a message "transmitted/broadcast over RF/LoRA".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's keep it like it was before, although there will be a "real ACK" that will stop retransmissions if the DM reaches the recipient even with 0 hops.


return send(p);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/modules/RoutingModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ uint8_t RoutingModule::getHopLimitForResponse(const meshtastic_MeshPacket &mp)
#if !(EVENTMODE) // This falls through to the default.
return hopsUsed; // If the request used more hops than the limit, use the same amount of hops
#endif
} else if (mp.hop_start == 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to double check but since we're in an if-statement with hopsUsed >= 0 this works indeed also for older firmware.

return 0; // The requesting node wanted 0 hops, so the response also uses a direct/local path.
} else if ((uint8_t)(hopsUsed + 2) < config.lora.hop_limit) {
return hopsUsed + 2; // Use only the amount of hops needed with some margin as the way back may be different
}
Expand Down