mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-08 05:31:25 +00:00
Set high priority for text messages (#4592)
This commit is contained in:
parent
8144dcbc25
commit
eb071ec80d
@ -40,19 +40,22 @@ void fixPriority(meshtastic_MeshPacket *p)
|
|||||||
// We might receive acks from other nodes (and since generated remotely, they won't have priority assigned. Check for that
|
// We might receive acks from other nodes (and since generated remotely, they won't have priority assigned. Check for that
|
||||||
// and fix it
|
// and fix it
|
||||||
if (p->priority == meshtastic_MeshPacket_Priority_UNSET) {
|
if (p->priority == meshtastic_MeshPacket_Priority_UNSET) {
|
||||||
// if acks give high priority
|
|
||||||
// if a reliable message give a bit higher default priority
|
// if a reliable message give a bit higher default priority
|
||||||
p->priority = (p->decoded.portnum == meshtastic_PortNum_ROUTING_APP)
|
p->priority = (p->want_ack ? meshtastic_MeshPacket_Priority_RELIABLE : meshtastic_MeshPacket_Priority_DEFAULT);
|
||||||
? meshtastic_MeshPacket_Priority_ACK
|
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
|
||||||
: (p->want_ack ? meshtastic_MeshPacket_Priority_RELIABLE : meshtastic_MeshPacket_Priority_DEFAULT);
|
// if acks/naks give very high priority
|
||||||
|
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)
|
||||||
|
p->priority = meshtastic_MeshPacket_Priority_HIGH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** enqueue a packet, return false if full */
|
/** enqueue a packet, return false if full */
|
||||||
bool MeshPacketQueue::enqueue(meshtastic_MeshPacket *p)
|
bool MeshPacketQueue::enqueue(meshtastic_MeshPacket *p)
|
||||||
{
|
{
|
||||||
fixPriority(p);
|
|
||||||
|
|
||||||
// no space - try to replace a lower priority packet in the queue
|
// no space - try to replace a lower priority packet in the queue
|
||||||
if (queue.size() >= maxLen) {
|
if (queue.size() >= maxLen) {
|
||||||
return replaceLowerPriorityPacket(p);
|
return replaceLowerPriorityPacket(p);
|
||||||
|
@ -48,4 +48,7 @@ extern Allocator<meshtastic_MeshPacket> &packetPool;
|
|||||||
* Most (but not always) of the time we want to treat packets 'from' the local phone (where from == 0), as if they originated on
|
* Most (but not always) of the time we want to treat packets 'from' the local phone (where from == 0), as if they originated on
|
||||||
* the local node. If from is zero this function returns our node number instead
|
* the local node. If from is zero this function returns our node number instead
|
||||||
*/
|
*/
|
||||||
NodeNum getFrom(const meshtastic_MeshPacket *p);
|
NodeNum getFrom(const meshtastic_MeshPacket *p);
|
||||||
|
|
||||||
|
/* Some clients might not properly set priority, therefore we fix it here. */
|
||||||
|
void fixPriority(meshtastic_MeshPacket *p);
|
@ -252,6 +252,8 @@ ErrorCode Router::send(meshtastic_MeshPacket *p)
|
|||||||
return meshtastic_Routing_Error_BAD_REQUEST;
|
return meshtastic_Routing_Error_BAD_REQUEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fixPriority(p); // Before encryption, fix the priority if it's unset
|
||||||
|
|
||||||
// If the packet is not yet encrypted, do so now
|
// If the packet is not yet encrypted, do so now
|
||||||
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
|
if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
|
||||||
ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it
|
ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it
|
||||||
|
Loading…
Reference in New Issue
Block a user