From 78bd9f4e92bd4a59453f6925a51ccf28ab906c8d Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Thu, 17 Dec 2020 11:25:15 +0800 Subject: [PATCH] 1.1.25 --- docs/meshtastic/index.html | 44 +++++++++++++++++++++----------------- setup.py | 2 +- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/docs/meshtastic/index.html b/docs/meshtastic/index.html index 6366c73..8f6c1b2 100644 --- a/docs/meshtastic/index.html +++ b/docs/meshtastic/index.html @@ -194,8 +194,7 @@ class MeshInterface: self.nodes = None # FIXME self.isConnected = threading.Event() self.noProto = noProto - if not noProto: - self._startConfig() + self._startConfig() def __enter__(self): return self @@ -431,6 +430,13 @@ class MeshInterface: self._sendToRadio(startConfig) def _sendToRadio(self, toRadio): + """Send a ToRadio protobuf to the device""" + if self.noProto: + logging.warn(f"Not sending packet because protocol use is disabled by noProto") + else: + self._sendToRadioImpl(toRadio) + + def _sendToRadioImpl(self, toRadio): """Send a ToRadio protobuf to the device""" logging.error(f"Subclass must provide toradio: {toRadio}") @@ -626,7 +632,7 @@ class BLEInterface(MeshInterface): self.device.subscribe(FROMNUM_UUID, callback=handle_data) - def _sendToRadio(self, toRadio): + def _sendToRadioImpl(self, toRadio): """Send a ToRadio protobuf to the device""" logging.debug(f"Sending: {toRadio}") b = toRadio.SerializeToString() @@ -706,7 +712,7 @@ class StreamInterface(MeshInterface): """Read an array of bytes from our stream""" return self.stream.read(len) - def _sendToRadio(self, toRadio): + def _sendToRadioImpl(self, toRadio): """Send a ToRadio protobuf to the device""" logging.debug(f"Sending: {toRadio}") b = toRadio.SerializeToString() @@ -795,7 +801,7 @@ class SerialInterface(StreamInterface): raise Exception("No Meshtastic devices detected") elif len(ports) > 1: raise Exception( - f"Multiple ports detected, you must specify a device, such as {ports[0].device}") + f"Multiple ports detected, you must specify a device, such as {ports[0]}") else: devPath = ports[0] @@ -811,8 +817,7 @@ class SerialInterface(StreamInterface): # control and will always drive RTS either high or low (rather than letting the CP102 leave # it as an open-collector floating pin). Since it is going to drive it anyways we want to make # sure it is driven low, so that the TBEAM won't reset - if platform.system() != 'Linux': - self.stream.rts = False + self.stream.rts = False self.stream.open() StreamInterface.__init__( @@ -821,9 +826,6 @@ class SerialInterface(StreamInterface): def _disconnected(self): """We override the superclass implementation to close our port""" - if platform.system() != 'Linux': - self.stream.rts = True # Return RTS high, so that the reset button still works - StreamInterface._disconnected(self) @@ -948,7 +950,7 @@ noProto – If True, don't try to run our protocol on the link - just be a d self.device.subscribe(FROMNUM_UUID, callback=handle_data) - def _sendToRadio(self, toRadio): + def _sendToRadioImpl(self, toRadio): """Send a ToRadio protobuf to the device""" logging.debug(f"Sending: {toRadio}") b = toRadio.SerializeToString() @@ -1039,8 +1041,7 @@ noProto – If True, don't try to run our protocol on the link - just be a d self.nodes = None # FIXME self.isConnected = threading.Event() self.noProto = noProto - if not noProto: - self._startConfig() + self._startConfig() def __enter__(self): return self @@ -1276,6 +1277,13 @@ noProto – If True, don't try to run our protocol on the link - just be a d self._sendToRadio(startConfig) def _sendToRadio(self, toRadio): + """Send a ToRadio protobuf to the device""" + if self.noProto: + logging.warn(f"Not sending packet because protocol use is disabled by noProto") + else: + self._sendToRadioImpl(toRadio) + + def _sendToRadioImpl(self, toRadio): """Send a ToRadio protobuf to the device""" logging.error(f"Subclass must provide toradio: {toRadio}") @@ -1812,7 +1820,7 @@ debugOut {stream} – If a stream is provided, any debug serial output from raise Exception("No Meshtastic devices detected") elif len(ports) > 1: raise Exception( - f"Multiple ports detected, you must specify a device, such as {ports[0].device}") + f"Multiple ports detected, you must specify a device, such as {ports[0]}") else: devPath = ports[0] @@ -1828,8 +1836,7 @@ debugOut {stream} – If a stream is provided, any debug serial output from # control and will always drive RTS either high or low (rather than letting the CP102 leave # it as an open-collector floating pin). Since it is going to drive it anyways we want to make # sure it is driven low, so that the TBEAM won't reset - if platform.system() != 'Linux': - self.stream.rts = False + self.stream.rts = False self.stream.open() StreamInterface.__init__( @@ -1838,9 +1845,6 @@ debugOut {stream} – If a stream is provided, any debug serial output from def _disconnected(self): """We override the superclass implementation to close our port""" - if platform.system() != 'Linux': - self.stream.rts = True # Return RTS high, so that the reset button still works - StreamInterface._disconnected(self)

Ancestors

@@ -1950,7 +1954,7 @@ debugOut {stream} – If a stream is provided, any debug serial output from """Read an array of bytes from our stream""" return self.stream.read(len) - def _sendToRadio(self, toRadio): + def _sendToRadioImpl(self, toRadio): """Send a ToRadio protobuf to the device""" logging.debug(f"Sending: {toRadio}") b = toRadio.SerializeToString() diff --git a/setup.py b/setup.py index 569b178..b2a1ea9 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ with open("README.md", "r") as fh: # This call to setup() does all the work setup( name="meshtastic", - version="1.1.24", + version="1.1.25", description="Python API & client shell for talking to Meshtastic devices", long_description=long_description, long_description_content_type="text/markdown",