diff --git a/src/meshcore/meshcore.py b/src/meshcore/meshcore.py index 5471fac..f965af3 100644 --- a/src/meshcore/meshcore.py +++ b/src/meshcore/meshcore.py @@ -118,10 +118,11 @@ class MeshCore: auto_reconnect: bool = False, max_reconnect_attempts: int = 3, cx_dly: float = 0.1, - rts = True + rts = False, + dtr = True ) -> "MeshCore": """Create and connect a MeshCore instance using serial connection""" - connection = SerialConnection(port, baudrate, cx_dly=cx_dly, rts=rts) + connection = SerialConnection(port, baudrate, cx_dly=cx_dly, rts=rts, dtr=dtr) mc = cls( connection, diff --git a/src/meshcore/serial_cx.py b/src/meshcore/serial_cx.py index c4fee30..56a4605 100644 --- a/src/meshcore/serial_cx.py +++ b/src/meshcore/serial_cx.py @@ -11,7 +11,7 @@ logger = logging.getLogger("meshcore") class SerialConnection: - def __init__(self, port, baudrate, cx_dly=0.2, rts=True): + def __init__(self, port, baudrate, cx_dly=0.2, rts=False, dtr=True): self.port = port self.baudrate = baudrate self.transport = None @@ -22,6 +22,7 @@ class SerialConnection: self._connected_event = asyncio.Event() self._background_tasks: set[asyncio.Task] = set() self.rts = rts + self.dtr = dtr self.frame_expected_size = 0 self.inframe = b"" @@ -42,7 +43,7 @@ class SerialConnection: self.cx.transport = transport logger.debug('port opened') if isinstance(transport, serial_asyncio.SerialTransport) and transport.serial: - transport.serial.dtr = False # Deassert DTR to avoid serial-open reset/handshake issues + transport.serial.dtr = self.cx.dtr # DTR should be deasserted on heltec_v2 to avoid serial-open reset/handshake issues transport.serial.rts = self.cx.rts self.cx._connected_event.set()