Skip to content

Commit 5760fb3

Browse files
committed
Add reconnect for firmware_node
1 parent 2281ea5 commit 5760fb3

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

meshtastic/tests/conftest.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,17 @@ def firmware_node():
4949
_skip_firmware_if_unavailable()
5050
mesh = SimMesh(n_nodes=1, base_port=SINGLE_NODE_BASE_PORT)
5151
mesh.start()
52-
set_region(mesh.get_node(0).port, "US")
53-
yield mesh.get_node(0)
52+
node = mesh.get_node(0)
53+
set_region(node.port, "US")
54+
# The region commit restarts the TCP listener, so reconnect the harness
55+
# interface in case a test wants to use it directly.
56+
if node.iface is not None:
57+
try:
58+
node.iface.close()
59+
except Exception: # pylint: disable=broad-except
60+
pass
61+
node.connect()
62+
yield node
5463
mesh.stop()
5564

5665

0 commit comments

Comments
 (0)