From 8350cc611dd453dfbad1bfa04cf01de223a92c15 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 8 Oct 2022 12:47:13 +0200 Subject: [PATCH 1/2] Catch RoutingApp on requestChannel --- meshtastic/node.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/meshtastic/node.py b/meshtastic/node.py index ba06eb0..79f0a6e 100644 --- a/meshtastic/node.py +++ b/meshtastic/node.py @@ -525,6 +525,20 @@ class Node: def onResponseRequestChannel(self, p): """Handle the response packet for requesting a channel _requestChannel()""" logging.debug(f'onResponseRequestChannel() p:{p}') + + if p["decoded"]["portnum"] == portnums_pb2.PortNum.Name(portnums_pb2.PortNum.ROUTING_APP): + print('No admin, error reason: ', p["decoded"]["routing"]["errorReason"]) + if p["decoded"]["routing"]["errorReason"] != "NONE": + logging.warning(f'Channel request failed, error reason: {p["decoded"]["routing"]["errorReason"]}') + self._timeout.expireTime = time.time() # Do not wait any longer + return # Don't try to parse this routing message + lastTried = 0 + if len(self.partialChannels) > 0: + lastTried = self.partialChannels[-1] + logging.debug(f"Retrying previous channel request.") + self._requestChannel(lastTried) + return + c = p["decoded"]["admin"]["raw"].get_channel_response self.partialChannels.append(c) self._timeout.reset() # We made foreward progress From 616a3ab70681fad02ac1e11b9ff41b5c6c8b8bb2 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 8 Oct 2022 12:47:48 +0200 Subject: [PATCH 2/2] Catch RoutingApp on requestGetMetadata --- meshtastic/node.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/meshtastic/node.py b/meshtastic/node.py index 79f0a6e..9e74796 100644 --- a/meshtastic/node.py +++ b/meshtastic/node.py @@ -516,6 +516,17 @@ class Node: def onRequestGetMetadata(self, p): """Handle the response packet for requesting device metadata getMetadata()""" logging.debug(f'onRequestGetMetadata() p:{p}') + + if p["decoded"]["portnum"] == portnums_pb2.PortNum.Name(portnums_pb2.PortNum.ROUTING_APP): + print('No admin, error reason: ', p["decoded"]["routing"]["errorReason"]) + if p["decoded"]["routing"]["errorReason"] != "NONE": + logging.warning(f'Metadata request failed, error reason: {p["decoded"]["routing"]["errorReason"]}') + self._timeout.expireTime = time.time() # Do not wait any longer + return # Don't try to parse this routing message + logging.debug(f"Retrying metadata request.") + self.getMetadata() + return + c = p["decoded"]["admin"]["raw"].get_device_metadata_response self._timeout.reset() # We made foreward progress logging.debug(f"Received metadata {stripnl(c)}")