Skip to content

Commit

Permalink
core: libs: update bridges to use new, more flexible and less ambiguo…
Browse files Browse the repository at this point in the history
…us interface
  • Loading branch information
Williangalvani committed Jan 19, 2024
1 parent 8b8ebd6 commit d2ae539
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/libs/bridges/bridges/bridges.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ def __init__(
serial_port: SysFS,
baud: Baudrate,
ip: str,
udp_port: int,
udp_target_port: int,
udp_listen_port: int,
automatic_disconnect: bool = True,
) -> None:
bridges = which("bridges")
automatic_disconnect_clients = "" if automatic_disconnect else "--no-udp-disconnection"
command_line = f"{bridges} -u {ip}:{udp_port} -p {serial_port.device}:{baud} {automatic_disconnect_clients}"
is_server = ip == "0.0.0.0"
port = udp_listen_port if is_server else udp_target_port

command_line = f"{bridges} -u {ip}:{port} -p {serial_port.device}:{baud} {automatic_disconnect_clients}"
if not is_server and udp_listen_port != 0:
command_line += f" --listen-port {udp_listen_port}"

logging.info(f"Launching bridge link with command '{command_line}'.")
# pylint: disable=consider-using-with
self.process = Popen(shlex.split(command_line), stdout=PIPE, stderr=PIPE)
Expand Down

0 comments on commit d2ae539

Please sign in to comment.