Skip to content

Commit

Permalink
Merge pull request #1971 from GUVWAF/master
Browse files Browse the repository at this point in the history
Cover two ACK/NAK edge cases for admin packets
  • Loading branch information
thebentern authored Nov 22, 2022
2 parents 7a63ba8 + 35d7e11 commit 5417671
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/mesh/MeshModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ void MeshModule::callPlugins(const MeshPacket &mp, RxSource src)
// no one should have already replied!
assert(!currentReply);

if (mp.decoded.want_response) {
printPacket("packet on wrong channel, returning error", &mp);
currentReply = pi.allocErrorResponse(Routing_Error_NOT_AUTHORIZED, &mp);
if (mp.decoded.want_response || (isDecoded && mp.want_ack)) {
printPacket("Packet on wrong channel, returning error", &mp);
currentReply = pi.allocErrorResponse(Routing_Error_NOT_AUTHORIZED, &mp);
} else
printPacket("packet on wrong channel, but can't respond", &mp);
printPacket("Packet on wrong channel, but it didn't require a response or ACK", &mp);
} else {

ProcessMessage handled = pi.handleReceived(mp);
Expand Down Expand Up @@ -156,12 +156,12 @@ void MeshModule::callPlugins(const MeshPacket &mp, RxSource src)
pi.currentRequest = NULL;
}

if (mp.decoded.want_response && toUs) {
if ((mp.decoded.want_response || mp.want_ack) && toUs) {
if (currentReply) {
printPacket("Sending response", currentReply);
service.sendToMesh(currentReply);
currentReply = NULL;
} else if(mp.from != ourNodeNum) {
} else if(mp.decoded.want_response && mp.from != ourNodeNum) {
// Note: if the message started with the local node we don't want to send a no response reply

// No one wanted to reply to this requst, tell the requster that happened
Expand Down
6 changes: 5 additions & 1 deletion src/mesh/ReliableRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ void ReliableRouter::sniffReceived(const MeshPacket *p, const Routing *c)
if (MeshModule::currentReply)
DEBUG_MSG("Some other module has replied to this message, no need for a 2nd ack\n");
else
sendAckNak(Routing_Error_NONE, getFrom(p), p->id, p->channel);
if (p->which_payload_variant == MeshPacket_decoded_tag)
sendAckNak(Routing_Error_NONE, getFrom(p), p->id, p->channel);
else
// Send a 'NO_CHANNEL' error on the primary channel if want_ack packet destined for us cannot be decoded
sendAckNak(Routing_Error_NO_CHANNEL, getFrom(p), p->id, channels.getPrimaryIndex());
}

// We consider an ack to be either a !routing packet with a request ID or a routing packet with !error
Expand Down

0 comments on commit 5417671

Please sign in to comment.