mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-20 12:02:21 +00:00
retransmissions work again
This commit is contained in:
parent
e2cbccb133
commit
e75561016b
@ -29,7 +29,7 @@ bool PacketHistory::wasSeenRecently(const MeshPacket *p, bool withUpdate)
|
|||||||
recentPackets.erase(recentPackets.begin() + i); // delete old record
|
recentPackets.erase(recentPackets.begin() + i); // delete old record
|
||||||
} else {
|
} else {
|
||||||
if (r.id == p->id && r.sender == p->from) {
|
if (r.id == p->id && r.sender == p->from) {
|
||||||
DEBUG_MSG("Found existing broadcast record for fr=0x%x,to=0x%x,id=%d\n", p->from, p->to, p->id);
|
DEBUG_MSG("Found existing packet record for fr=0x%x,to=0x%x,id=%d\n", p->from, p->to, p->id);
|
||||||
|
|
||||||
// Update the time on this record to now
|
// Update the time on this record to now
|
||||||
if (withUpdate)
|
if (withUpdate)
|
||||||
@ -48,7 +48,7 @@ bool PacketHistory::wasSeenRecently(const MeshPacket *p, bool withUpdate)
|
|||||||
r.sender = p->from;
|
r.sender = p->from;
|
||||||
r.rxTimeMsec = now;
|
r.rxTimeMsec = now;
|
||||||
recentPackets.push_back(r);
|
recentPackets.push_back(r);
|
||||||
DEBUG_MSG("Adding broadcast record for fr=0x%x,to=0x%x,id=%d\n", p->from, p->to, p->id);
|
DEBUG_MSG("Adding packet record for fr=0x%x,to=0x%x,id=%d\n", p->from, p->to, p->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -36,6 +36,8 @@ void ReliableRouter::handleReceived(MeshPacket *p)
|
|||||||
NodeNum ourNode = getNodeNum();
|
NodeNum ourNode = getNodeNum();
|
||||||
|
|
||||||
if (p->from == ourNode && p->to == NODENUM_BROADCAST) {
|
if (p->from == ourNode && p->to == NODENUM_BROADCAST) {
|
||||||
|
DEBUG_MSG("Received someone rebroadcasting for us fr=0x%x,to=0x%x,id=%d\n", p->from, p->to, p->id);
|
||||||
|
|
||||||
// We are seeing someone rebroadcast one of our broadcast attempts.
|
// We are seeing someone rebroadcast one of our broadcast attempts.
|
||||||
// If this is the first time we saw this, cancel any retransmissions we have queued up and generate an internal ack for
|
// If this is the first time we saw this, cancel any retransmissions we have queued up and generate an internal ack for
|
||||||
// the original sending process.
|
// the original sending process.
|
||||||
@ -77,7 +79,7 @@ void ReliableRouter::handleReceived(MeshPacket *p)
|
|||||||
*/
|
*/
|
||||||
void ReliableRouter::sendAckNak(bool isAck, NodeNum to, PacketId idFrom)
|
void ReliableRouter::sendAckNak(bool isAck, NodeNum to, PacketId idFrom)
|
||||||
{
|
{
|
||||||
DEBUG_MSG("Sending an ack=%d,to=%d,idFrom=%d", isAck, to, idFrom);
|
DEBUG_MSG("Sending an ack=%d,to=%d,idFrom=%d\n", isAck, to, idFrom);
|
||||||
auto p = allocForSending();
|
auto p = allocForSending();
|
||||||
p->hop_limit = 0; // Assume just immediate neighbors for now
|
p->hop_limit = 0; // Assume just immediate neighbors for now
|
||||||
p->to = to;
|
p->to = to;
|
||||||
@ -108,7 +110,7 @@ PendingPacket::PendingPacket(MeshPacket *p)
|
|||||||
bool ReliableRouter::stopRetransmission(NodeNum from, PacketId id)
|
bool ReliableRouter::stopRetransmission(NodeNum from, PacketId id)
|
||||||
{
|
{
|
||||||
auto key = GlobalPacketId(from, id);
|
auto key = GlobalPacketId(from, id);
|
||||||
stopRetransmission(key);
|
return stopRetransmission(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReliableRouter::stopRetransmission(GlobalPacketId key)
|
bool ReliableRouter::stopRetransmission(GlobalPacketId key)
|
||||||
@ -150,12 +152,17 @@ void ReliableRouter::doRetransmissions()
|
|||||||
// FIXME, handle 51 day rolloever here!!!
|
// FIXME, handle 51 day rolloever here!!!
|
||||||
if (p.nextTxMsec <= now) {
|
if (p.nextTxMsec <= now) {
|
||||||
if (p.numRetransmissions == 0) {
|
if (p.numRetransmissions == 0) {
|
||||||
DEBUG_MSG("Reliable send failed, returning a nak\n");
|
DEBUG_MSG("Reliable send failed, returning a nak fr=0x%x,to=0x%x,id=%d\n", p.packet->from, p.packet->to,
|
||||||
|
p.packet->id);
|
||||||
sendAckNak(false, p.packet->from, p.packet->id);
|
sendAckNak(false, p.packet->from, p.packet->id);
|
||||||
stopRetransmission(it->first);
|
stopRetransmission(it->first);
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Sending reliable retransmission\n");
|
DEBUG_MSG("Sending reliable retransmission fr=0x%x,to=0x%x,id=%d, tries left=%d\n", p.packet->from, p.packet->to,
|
||||||
send(packetPool.allocCopy(*p.packet));
|
p.packet->id, p.numRetransmissions);
|
||||||
|
|
||||||
|
// Note: we call the superclass version because we don't want to have our version of send() add a new
|
||||||
|
// retransmission record
|
||||||
|
FloodingRouter::send(packetPool.allocCopy(*p.packet));
|
||||||
|
|
||||||
// Queue again
|
// Queue again
|
||||||
--p.numRetransmissions;
|
--p.numRetransmissions;
|
||||||
|
@ -48,7 +48,7 @@ struct PendingPacket {
|
|||||||
PendingPacket() {}
|
PendingPacket() {}
|
||||||
PendingPacket(MeshPacket *p);
|
PendingPacket(MeshPacket *p);
|
||||||
|
|
||||||
void setNextTx() { nextTxMsec = millis() + random(10 * 1000, 12 * 1000); }
|
void setNextTx() { nextTxMsec = millis() + random(30 * 1000, 22 * 1000); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class GlobalPacketIdHashFunction
|
class GlobalPacketIdHashFunction
|
||||||
|
Loading…
Reference in New Issue
Block a user