troubleshoot dropped packets

This commit is contained in:
Jonathan Bennett
2026-04-08 16:42:46 -05:00
parent 4a3f449555
commit f5335f22ea
3 changed files with 19 additions and 11 deletions
+16 -10
View File
@@ -98,13 +98,21 @@ ProcessMessage DMShellModule::handleReceived(const meshtastic_MeshPacket &mp)
return ProcessMessage::STOP;
}
// TODO: double-check the sender is the same as the one we have an active session with before processing ACKs
if (frame.op == meshtastic_DMShell_OpCode_ACK) {
if (session.active && frame.sessionId == session.sessionId && getFrom(&mp) == session.peer) {
handleAckFrame(frame);
}
return ProcessMessage::STOP;
}
if (frame.op >= 64) {
LOG_WARN("DMShell: ignoring frame with op code %d", frame.op);
LOG_WARN("DMShell: ignoring frame with op code %d, seq %d", frame.op, frame.seq);
return ProcessMessage::CONTINUE;
}
if (!isAuthorizedPacket(mp)) {
LOG_WARN("DMShell: unauthorized sender 0x%x", mp.from);
LOG_WARN("DMShell: unauthorized sender 0x%x, %u", mp.from, frame.op);
myReply = allocErrorResponse(meshtastic_Routing_Error_NOT_AUTHORIZED, &mp);
return ProcessMessage::STOP;
}
@@ -113,13 +121,6 @@ ProcessMessage DMShellModule::handleReceived(const meshtastic_MeshPacket &mp)
pruneSentFrames(frame.ackSeq);
}
if (frame.op == meshtastic_DMShell_OpCode_ACK) {
if (session.active && frame.sessionId == session.sessionId && getFrom(&mp) == session.peer) {
handleAckFrame(frame);
}
return ProcessMessage::STOP;
}
if (frame.op == meshtastic_DMShell_OpCode_OPEN) {
LOG_WARN("DMShell: received OPEN from 0x%x sessionId=0x%x", mp.from, frame.sessionId);
if (!openSession(mp, frame)) {
@@ -189,6 +190,10 @@ int32_t DMShellModule::runOnce()
return 100;
}
if (RadioLibInterface::instance->packetsInTxQueue() > 1) {
return 50;
}
uint8_t outBuf[MAX_PTY_READ_SIZE];
while (session.masterFd >= 0) {
const ssize_t bytesRead = read(session.masterFd, outBuf, sizeof(outBuf));
@@ -196,7 +201,8 @@ int32_t DMShellModule::runOnce()
LOG_WARN("DMShell: read %d bytes from PTY", bytesRead);
sendControl(meshtastic_DMShell_OpCode_OUTPUT, outBuf, static_cast<size_t>(bytesRead));
session.lastActivityMs = millis();
continue;
// continue;
return 50;
}
if (bytesRead == 0) {