From a4830f5f626c69b1c40a25d699af196d25303de2 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Tue, 16 Apr 2024 13:10:18 -0700 Subject: [PATCH] Treat a message as an ack if there is an errorReason but it's set to NONE, not just if the errorReason is absent --- meshtastic/mesh_interface.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/meshtastic/mesh_interface.py b/meshtastic/mesh_interface.py index 0e239d7..891de46 100644 --- a/meshtastic/mesh_interface.py +++ b/meshtastic/mesh_interface.py @@ -337,6 +337,7 @@ class MeshInterface: meshPacket.id = self._generatePacketId() if onResponse is not None: + logging.debug(f"Setting a response handler for requestId {meshPacket.id}") self._addResponseHandler(meshPacket.id, onResponse) p = self._sendPacket(meshPacket, destinationId, wantAck=wantAck) return p @@ -1034,14 +1035,16 @@ class MeshInterface: # Is this message in response to a request, if so, look for a handler requestId = decoded.get("requestId") if requestId is not None: + logging.debug(f"Got a response for requestId {requestId}") # We ignore ACK packets, but send NAKs and data responses to the handlers routing = decoded.get("routing") - isAck = routing is not None and ("errorReason" not in routing) + isAck = routing is not None and ("errorReason" not in routing or routing["errorReason"] == "NONE") if not isAck: # we keep the responseHandler in dict until we get a non ack handler = self.responseHandlers.pop(requestId, None) if handler is not None: if not isAck or (isAck and handler.__name__ == "onAckNak"): + logging.debug(f"Calling response handler for requestId {requestId}") handler.callback(asDict) logging.debug(f"Publishing {topic}: packet={stripnl(asDict)} ")