Attempt TCP connection to localhost if serial detect fails

This commit is contained in:
Jonathan Bennett
2024-03-11 17:00:49 -05:00
parent c67d299984
commit 14813e5c76
2 changed files with 12 additions and 1 deletions

View File

@@ -984,6 +984,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)

View File

@@ -32,7 +32,8 @@ class SerialInterface(StreamInterface):
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}"