add --noproto option for not using the protocol at all

This commit is contained in:
geeksville
2020-06-09 18:19:37 -07:00
parent e156bae854
commit e2a037ef1e
2 changed files with 11 additions and 6 deletions

View File

@@ -72,7 +72,7 @@ BROADCAST_NUM = 0xffffffff
MY_CONFIG_ID = 42
"""The numeric buildnumber (shared with android apps) specifying the level of device code we are guaranteed to understand"""
OUR_APP_VERSION = 167
OUR_APP_VERSION = 172
class MeshInterface:
@@ -85,12 +85,13 @@ class MeshInterface:
debugOut
"""
def __init__(self, debugOut=None):
def __init__(self, debugOut=None, noProto=False):
"""Constructor"""
self.debugOut = debugOut
self.nodes = None # FIXME
self.isConnected = False
self._startConfig()
if not noProto:
self._startConfig()
def sendText(self, text, destinationId=BROADCAST_ADDR, wantAck=False, wantResponse=False):
"""Send a utf8 string to some other node, if the node has a display it will also be shown on the device.
@@ -316,7 +317,7 @@ class BLEInterface(MeshInterface):
class StreamInterface(MeshInterface):
"""Interface class for meshtastic devices over a stream link (serial, TCP, etc)"""
def __init__(self, devPath=None, debugOut=None):
def __init__(self, devPath=None, debugOut=None, noProto=False):
"""Constructor, opens a connection to a specified serial port, or if unspecified try to
find one Meshtastic device by probing
@@ -347,7 +348,7 @@ class StreamInterface(MeshInterface):
devPath, 921600, exclusive=True, timeout=0.5)
self._rxThread = threading.Thread(target=self.__reader, args=())
self._rxThread.start()
MeshInterface.__init__(self, debugOut=debugOut)
MeshInterface.__init__(self, debugOut=debugOut, noProto=noProto)
def _sendToRadio(self, toRadio):
"""Send a ToRadio protobuf to the device"""

View File

@@ -102,6 +102,9 @@ def main():
parser.add_argument("--ble", help="hack for testing BLE code (BLE is not yet supported for this tool)",
action="store_true")
parser.add_argument("--noproto", help="Don't start the API, just function as a dumb serial terminal.",
action="store_true")
global args
args = parser.parse_args()
logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO)
@@ -125,7 +128,8 @@ def main():
if args.ble:
client = BLEInterface(args.device, debugOut=logfile)
else:
client = StreamInterface(args.device, debugOut=logfile)
client = StreamInterface(
args.device, debugOut=logfile, noProto=args.noproto)
if __name__ == "__main__":