mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-24 05:50:16 +00:00
Short-circuit to FloodingRouter for broadcasts
This commit is contained in:
parent
44dc270c8a
commit
9b1dd75549
@ -66,14 +66,11 @@ void NextHopRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtast
|
|||||||
|
|
||||||
tosend->hop_limit--; // bump down the hop count
|
tosend->hop_limit--; // bump down the hop count
|
||||||
NextHopRouter::send(tosend);
|
NextHopRouter::send(tosend);
|
||||||
} else if (p->next_hop == 0) {
|
} else if (p->next_hop == NO_NEXT_HOP_PREFERENCE) {
|
||||||
// No preference for next hop, use FloodingRouter
|
// No preference for next hop, use FloodingRouter
|
||||||
LOG_DEBUG("No preference for next hop, using FloodingRouter\n");
|
LOG_DEBUG("No preference for next hop, using FloodingRouter\n");
|
||||||
FloodingRouter::sniffReceived(p, c);
|
FloodingRouter::sniffReceived(p, c);
|
||||||
} else if (p->to == NODENUM_BROADCAST) {
|
} // else don't relay
|
||||||
// TODO: Smarter way of handling broadcasts
|
|
||||||
FloodingRouter::sniffReceived(p, c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG("Not rebroadcasting. Role = Role_ClientMute\n");
|
LOG_DEBUG("Not rebroadcasting. Role = Role_ClientMute\n");
|
||||||
|
@ -33,7 +33,7 @@ ErrorCode ReliableRouter::send(meshtastic_MeshPacket *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return config.lora.next_hop_routing ? NextHopRouter::send(p) : FloodingRouter::send(p);
|
return (config.lora.next_hop_routing && p->to != NODENUM_BROADCAST) ? NextHopRouter::send(p) : FloodingRouter::send(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReliableRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
|
bool ReliableRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
|
||||||
@ -132,8 +132,9 @@ void ReliableRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle the packet as normal
|
// For DMs, we use the NextHopRouter, whereas for broadcasts, we use the FloodingRouter
|
||||||
config.lora.next_hop_routing ? NextHopRouter::sniffReceived(p, c) : FloodingRouter::sniffReceived(p, c);
|
config.lora.next_hop_routing && (p->to != NODENUM_BROADCAST) ? NextHopRouter::sniffReceived(p, c)
|
||||||
|
: FloodingRouter::sniffReceived(p, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NUM_RETRANSMISSIONS 3
|
#define NUM_RETRANSMISSIONS 3
|
||||||
@ -222,7 +223,8 @@ int32_t ReliableRouter::doRetransmissions()
|
|||||||
LOG_DEBUG("Sending reliable retransmission fr=0x%x,to=0x%x,id=0x%x, tries left=%d\n", p.packet->from,
|
LOG_DEBUG("Sending reliable retransmission fr=0x%x,to=0x%x,id=0x%x, tries left=%d\n", p.packet->from,
|
||||||
p.packet->to, p.packet->id, p.numRetransmissions);
|
p.packet->to, p.packet->id, p.numRetransmissions);
|
||||||
|
|
||||||
if (config.lora.next_hop_routing && p.numRetransmissions == 1) {
|
if (config.lora.next_hop_routing && p.packet->to != NODENUM_BROADCAST) {
|
||||||
|
if (p.numRetransmissions == 1) {
|
||||||
// Last retransmission, reset next_hop (fallback to FloodingRouter)
|
// Last retransmission, reset next_hop (fallback to FloodingRouter)
|
||||||
p.packet->next_hop = NO_NEXT_HOP_PREFERENCE;
|
p.packet->next_hop = NO_NEXT_HOP_PREFERENCE;
|
||||||
// Also reset it in the nodeDB
|
// Also reset it in the nodeDB
|
||||||
@ -232,11 +234,12 @@ int32_t ReliableRouter::doRetransmissions()
|
|||||||
sentTo->next_hop = NO_NEXT_HOP_PREFERENCE;
|
sentTo->next_hop = NO_NEXT_HOP_PREFERENCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
NextHopRouter::send(packetPool.allocCopy(*p.packet));
|
||||||
|
} else {
|
||||||
// Note: we call the superclass version because we don't want to have our version of send() add a new
|
// Note: we call the superclass version because we don't want to have our version of send() add a new
|
||||||
// retransmission record
|
// retransmission record
|
||||||
config.lora.next_hop_routing ? NextHopRouter::send(packetPool.allocCopy(*p.packet))
|
FloodingRouter::send(packetPool.allocCopy(*p.packet));
|
||||||
: FloodingRouter::send(packetPool.allocCopy(*p.packet));
|
}
|
||||||
|
|
||||||
// Queue again
|
// Queue again
|
||||||
--p.numRetransmissions;
|
--p.numRetransmissions;
|
||||||
|
Loading…
Reference in New Issue
Block a user