From 77cddd4f9d6d26ce4158cbff4076dd77780db1ed Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sun, 1 Sep 2024 16:18:55 +0200 Subject: [PATCH] More priorities for different types of MeshPackets --- src/mesh/MeshPacketQueue.cpp | 14 +++++++++++--- src/modules/NeighborInfoModule.cpp | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/mesh/MeshPacketQueue.cpp b/src/mesh/MeshPacketQueue.cpp index 8e5eedc878..6581b1ce4a 100644 --- a/src/mesh/MeshPacketQueue.cpp +++ b/src/mesh/MeshPacketQueue.cpp @@ -44,11 +44,19 @@ void fixPriority(meshtastic_MeshPacket *p) p->priority = (p->want_ack ? meshtastic_MeshPacket_Priority_RELIABLE : meshtastic_MeshPacket_Priority_DEFAULT); if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) { // if acks/naks give very high priority - if (p->decoded.portnum == meshtastic_PortNum_ROUTING_APP) + if (p->decoded.portnum == meshtastic_PortNum_ROUTING_APP) { p->priority = meshtastic_MeshPacket_Priority_ACK; - // if text give high priority - else if (p->decoded.portnum == meshtastic_PortNum_TEXT_MESSAGE_APP) + // if text or admin, give high priority + } else if (p->decoded.portnum == meshtastic_PortNum_TEXT_MESSAGE_APP || + p->decoded.portnum == meshtastic_PortNum_ADMIN_APP) { p->priority = meshtastic_MeshPacket_Priority_HIGH; + // if it is a response, give higher priority to let it arrive early and stop the request being relayed + } else if (p->decoded.request_id != 0) { + p->priority = meshtastic_MeshPacket_Priority_RESPONSE; + // Also if we want a response, give a bit higher priority + } else if (p->decoded.want_response) { + p->priority = meshtastic_MeshPacket_Priority_RELIABLE; + } } } } diff --git a/src/modules/NeighborInfoModule.cpp b/src/modules/NeighborInfoModule.cpp index 2de4374e69..218fb8801d 100644 --- a/src/modules/NeighborInfoModule.cpp +++ b/src/modules/NeighborInfoModule.cpp @@ -107,6 +107,7 @@ void NeighborInfoModule::sendNeighborInfo(NodeNum dest, bool wantReplies) // because we want to get neighbors for the next cycle p->to = dest; p->decoded.want_response = wantReplies; + p->priority = meshtastic_MeshPacket_Priority_BACKGROUND; printNeighborInfo("SENDING", &neighborInfo); service->sendToMesh(p, RX_SRC_LOCAL, true); }