From 014946ad0e2e012871d96292a7e661583a4f5d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 23 Jan 2023 12:29:10 +0100 Subject: [PATCH] tryfix: also clear the second buffer. Todo: do we really need 2 buffers here? --- src/mesh/PhoneAPI.cpp | 4 +++- src/xmodem.cpp | 5 +++++ src/xmodem.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 8177cc2b6..0c430ea5c 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -378,8 +378,10 @@ bool PhoneAPI::available() if (xmodemPacketForPhone.control == meshtastic_XModem_Control_NUL) xmodemPacketForPhone = xModem.getForPhone(); - if (xmodemPacketForPhone.control != meshtastic_XModem_Control_NUL) + if (xmodemPacketForPhone.control != meshtastic_XModem_Control_NUL) { + xModem.resetForPhone(); return true; + } if (!packetForPhone) packetForPhone = service.getForPhone(); diff --git a/src/xmodem.cpp b/src/xmodem.cpp index 5f30de253..473635e67 100644 --- a/src/xmodem.cpp +++ b/src/xmodem.cpp @@ -74,6 +74,11 @@ meshtastic_XModem XModemAdapter::getForPhone() return xmodemStore; } +void XModemAdapter::resetForPhone() +{ + xmodemStore = meshtastic_XModem_init_zero; +} + void XModemAdapter::handlePacket(meshtastic_XModem xmodemPacket) { switch (xmodemPacket.control) { diff --git a/src/xmodem.h b/src/xmodem.h index 894488c02..848e926bd 100644 --- a/src/xmodem.h +++ b/src/xmodem.h @@ -48,6 +48,7 @@ class XModemAdapter void handlePacket(meshtastic_XModem xmodemPacket); meshtastic_XModem getForPhone(); + void resetForPhone(); private: bool isReceiving = false;