mirror of
https://github.com/meshtastic/python.git
synced 2025-12-30 03:17:54 -05:00
add --noproto option for not using the protocol at all
This commit is contained in:
@@ -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"""
|
||||
|
||||
@@ -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__":
|
||||
|
||||
Reference in New Issue
Block a user