Skip to content

Commit

Permalink
Drop packets if toPhoneQueue is full, unless it's text/RangeTest (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
GUVWAF authored Oct 30, 2023
1 parent 4052194 commit 8b8fffd
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/mesh/MeshService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,22 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies)

void MeshService::sendToPhone(meshtastic_MeshPacket *p)
{
perhapsDecode(p);

if (toPhoneQueue.numFree() == 0) {
LOG_WARN("ToPhone queue is full, discarding oldest\n");
meshtastic_MeshPacket *d = toPhoneQueue.dequeuePtr(0);
if (d)
releaseToPool(d);
if (p->decoded.portnum == meshtastic_PortNum_TEXT_MESSAGE_APP ||
p->decoded.portnum == meshtastic_PortNum_RANGE_TEST_APP) {
LOG_WARN("ToPhone queue is full, discarding oldest\n");
meshtastic_MeshPacket *d = toPhoneQueue.dequeuePtr(0);
if (d)
releaseToPool(d);
} else {
LOG_WARN("ToPhone queue is full, dropping packet.\n");
releaseToPool(p);
return;
}
}

perhapsDecode(p);
assert(toPhoneQueue.enqueue(p, 0));
fromNum++;
}
Expand Down

0 comments on commit 8b8fffd

Please sign in to comment.