Skip to content

Commit 14813e5

Browse files
committed
Attempt TCP connection to localhost if serial detect fails
1 parent c67d299 commit 14813e5

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

meshtastic/__main__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,16 @@ def common():
984984
message += " After running that command, log out and re-login for it to take effect.\n"
985985
message += f"Error was:{ex}"
986986
meshtastic.util.our_exit(message)
987+
if client.devPath is None:
988+
try:
989+
client = meshtastic.tcp_interface.TCPInterface(
990+
"localhost", debugOut=logfile, noProto=args.noproto
991+
)
992+
except Exception as ex:
993+
meshtastic.util.our_exit(
994+
f"Error connecting to localhost:{ex}", 1
995+
)
996+
987997

988998
# We assume client is fully connected now
989999
onConnected(client)

meshtastic/serial_interface.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def __init__(self, devPath=None, debugOut=None, noProto=False, connectNow=True):
3232
ports = meshtastic.util.findPorts(True)
3333
logging.debug(f"ports:{ports}")
3434
if len(ports) == 0:
35-
meshtastic.util.our_exit("Warning: No Meshtastic devices detected.")
35+
print("No Serial Meshtastic device detected, attempting TCP connection on localhost.")
36+
return
3637
elif len(ports) > 1:
3738
message = "Warning: Multiple serial ports were detected so one serial port must be specified with the '--port'.\n"
3839
message += f" Ports detected:{ports}"

0 commit comments

Comments
 (0)