Add Routing_Error_NONE

This commit is contained in:
Jonathan Bennett 2024-08-12 23:39:45 -05:00
parent 754db3f2bc
commit 308c0a6bb8
5 changed files with 20 additions and 19 deletions

View File

@ -253,7 +253,8 @@ void MeshService::sendToMesh(meshtastic_MeshPacket *p, RxSource src, bool ccToPh
LOG_DEBUG("Can't send status to phone");
}
if (res == ERRNO_OK && ccToPhone) { // Check if p is not released in case it couldn't be sent
if ((res == ERRNO_OK || res == meshtastic_Routing_Error_NONE_PKI) &&
ccToPhone) { // Check if p is not released in case it couldn't be sent
sendToPhone(packetPool.allocCopy(*p));
}
}

View File

@ -15,7 +15,7 @@ typedef uint32_t PacketId; // A packet sequence number
#define ERRNO_OK 0
#define ERRNO_NO_INTERFACES 33
#define ERRNO_UNKNOWN 32 // pick something that doesn't conflict with RH_ROUTER_ERROR_UNABLE_TO_DELIVER
#define ERRNO_DISABLED 34 // the interface is disabled
#define ERRNO_DISABLED 35 // the interface is disabled
/*
* Source of a received message

View File

@ -117,20 +117,17 @@ void ReliableRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtas
}
// We consider an ack to be either a !routing packet with a request ID or a routing packet with !error
PacketId ackId = ((c && c->error_reason == meshtastic_Routing_Error_NONE) || !c) ? p->decoded.request_id : 0;
if ((c && (c->error_reason == meshtastic_Routing_Error_NONE || c->error_reason == meshtastic_Routing_Error_NONE_PKI)) ||
!c) {
LOG_DEBUG("Received an ack for 0x%x, stopping retransmissions\n", p->decoded.request_id);
stopRetransmission(p->to, p->decoded.request_id);
// } else if (c && (c->error_reason == meshtastic_Routing_Error_NO_CHANNEL)) {
// noop?
} else if (c &&
(c->error_reason != meshtastic_Routing_Error_NONE && c->error_reason != meshtastic_Routing_Error_NONE_PKI)) {
// A nak is a routing packt that has an error code
PacketId nakId = (c && c->error_reason != meshtastic_Routing_Error_NONE) ? p->decoded.request_id : 0;
// We intentionally don't check wasSeenRecently, because it is harmless to delete non existent retransmission records
if (ackId || nakId) {
if (ackId) {
LOG_DEBUG("Received an ack for 0x%x, stopping retransmissions\n", ackId);
stopRetransmission(p->to, ackId);
} else {
LOG_DEBUG("Received a nak for 0x%x, stopping retransmissions\n", nakId);
stopRetransmission(p->to, nakId);
}
LOG_DEBUG("Received a nak for 0x%x, stopping retransmissions\n", p->decoded.request_id);
stopRetransmission(p->to, p->decoded.request_id);
}
}

View File

@ -258,7 +258,7 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
meshtastic_MeshPacket *p_decoded = packetPool.allocCopy(*p);
auto encodeResult = perhapsEncode(p);
if (encodeResult != meshtastic_Routing_Error_NONE) {
if (encodeResult != meshtastic_Routing_Error_NONE && encodeResult != meshtastic_Routing_Error_NONE_PKI) {
packetPool.release(p_decoded);
abortSendAndNak(encodeResult, p);
return encodeResult; // FIXME - this isn't a valid ErrorCode
@ -493,8 +493,10 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
p->encrypted.size = numbytes;
p->which_payload_variant = meshtastic_MeshPacket_encrypted_tag;
}
return meshtastic_Routing_Error_NONE;
if (p->pki_encrypted)
return meshtastic_Routing_Error_NONE_PKI;
else
return meshtastic_Routing_Error_NONE;
}
NodeNum Router::getNodeNum()

View File

@ -1105,7 +1105,8 @@ ProcessMessage CannedMessageModule::handleReceived(const meshtastic_MeshPacket &
this->incoming = service->getNodenumFromRequestId(mp.decoded.request_id);
meshtastic_Routing decoded = meshtastic_Routing_init_default;
pb_decode_from_bytes(mp.decoded.payload.bytes, mp.decoded.payload.size, meshtastic_Routing_fields, &decoded);
this->ack = decoded.error_reason == meshtastic_Routing_Error_NONE;
this->ack = decoded.error_reason == meshtastic_Routing_Error_NONE ||
decoded.error_reason == meshtastic_Routing_Error_NONE_PKI;
waitingForAck = false; // No longer want routing packets
this->notifyObservers(&e);
// run the next time 2 seconds later