Skip to content

Commit

Permalink
Merge pull request #673 from djholt/feature/tcp-port
Browse files Browse the repository at this point in the history
Allow port number to be specified with tcp hostname
  • Loading branch information
ianmcorvidae committed Sep 18, 2024
2 parents 951edfe + 5cc9627 commit 5d6dfb8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,8 +1162,14 @@ def common():
)
elif args.host:
try:
if ":" in args.host:
tcp_hostname, tcp_port = args.host.split(':')
else:
tcp_hostname = args.host
tcp_port = meshtastic.tcp_interface.DEFAULT_TCP_PORT
client = meshtastic.tcp_interface.TCPInterface(
args.host,
tcp_hostname,
portNumber=tcp_port,
debugOut=logfile,
noProto=args.noproto,
noNodes=args.no_nodes,
Expand Down
3 changes: 2 additions & 1 deletion meshtastic/tcp_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from meshtastic.stream_interface import StreamInterface

DEFAULT_TCP_PORT = 4403

class TCPInterface(StreamInterface):
"""Interface class for meshtastic devices over a TCP link"""
Expand All @@ -16,7 +17,7 @@ def __init__(
debugOut=None,
noProto=False,
connectNow=True,
portNumber=4403,
portNumber=DEFAULT_TCP_PORT,
noNodes:bool=False,
):
"""Constructor, opens a connection to a specified IP address/hostname
Expand Down

0 comments on commit 5d6dfb8

Please sign in to comment.