mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-07-06 01:41:45 +02:00
Merge pull request #219 from pdxlocations/allow-port-numbers
Enhance TCP interface initialization to support host:port format
This commit is contained in:
+14
-1
@@ -331,7 +331,20 @@ for i in range(1, 10):
|
||||
if interface_type == 'serial':
|
||||
globals()[f'interface{i}'] = meshtastic.serial_interface.SerialInterface(globals().get(f'port{i}'))
|
||||
elif interface_type == 'tcp':
|
||||
globals()[f'interface{i}'] = meshtastic.tcp_interface.TCPInterface(globals().get(f'hostname{i}'))
|
||||
host = globals().get(f'hostname{i}', '127.0.0.1')
|
||||
port = 4403
|
||||
|
||||
# Allow host:port format
|
||||
if isinstance(host, str) and ':' in host:
|
||||
maybe_host, maybe_port = host.rsplit(':', 1)
|
||||
if maybe_port.isdigit():
|
||||
host = maybe_host
|
||||
try:
|
||||
port = int(maybe_port)
|
||||
except ValueError:
|
||||
port = 4403
|
||||
|
||||
globals()[f'interface{i}'] = meshtastic.tcp_interface.TCPInterface(hostname=host, portNumber=port)
|
||||
elif interface_type == 'ble':
|
||||
globals()[f'interface{i}'] = meshtastic.ble_interface.BLEInterface(globals().get(f'mac{i}'))
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user