Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,16 @@ def common():
message += " After running that command, log out and re-login for it to take effect.\n"
message += f"Error was:{ex}"
meshtastic.util.our_exit(message)
if client.devPath is None:
try:
client = meshtastic.tcp_interface.TCPInterface(
"localhost", debugOut=logfile, noProto=args.noproto
)
except Exception as ex:
meshtastic.util.our_exit(
f"Error connecting to localhost:{ex}", 1
)


# We assume client is fully connected now
onConnected(client)
Expand Down Expand Up @@ -1016,7 +1026,7 @@ def initParser():

parser.add_argument(
"--port",
help="The port the Meshtastic device is connected to, i.e. /dev/ttyUSB0. If unspecified, we'll try to find it.",
help="The port the Meshtastic device is connected to, i.e. /dev/ttyUSB0.",
default=None,
)

Expand Down Expand Up @@ -1368,7 +1378,9 @@ def initParser():
def main():
"""Perform command line meshtastic operations"""
our_globals = Globals.getInstance()
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(
epilog="If neither --port nor --host are specified, we search for a compatible serial device, "
"and if none is found, then attempt a TCP connection to localhost.")
our_globals.set_parser(parser)
initParser()
common()
Expand Down
3 changes: 2 additions & 1 deletion meshtastic/serial_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def __init__(self, devPath=None, debugOut=None, noProto=False, connectNow=True):
ports = meshtastic.util.findPorts(True)
logging.debug(f"ports:{ports}")
if len(ports) == 0:
meshtastic.util.our_exit("Warning: No Meshtastic devices detected.")
print("No Serial Meshtastic device detected, attempting TCP connection on localhost.")
return
elif len(ports) > 1:
message = "Warning: Multiple serial ports were detected so one serial port must be specified with the '--port'.\n"
message += f" Ports detected:{ports}"
Expand Down