diff --git a/src/meshcore_proxy/proxy.py b/src/meshcore_proxy/proxy.py index 069f874..6b23b0d 100644 --- a/src/meshcore_proxy/proxy.py +++ b/src/meshcore_proxy/proxy.py @@ -364,16 +364,8 @@ async def handle_rx(self, data: bytes) -> None: self._radio_connection.set_reader(ReaderAdapter(self._handle_radio_rx)) - disconnect_setter = getattr(self._radio_connection, "set_disconnect_handler", None) - if callable(disconnect_setter): - disconnect_setter(self._handle_radio_disconnect) - else: - callback_setter = getattr(self._radio_connection, "set_disconnect_callback", None) - if not callable(callback_setter): - raise AttributeError( - "Radio connection object does not expose a disconnect handler setter" - ) - callback_setter(self._handle_radio_disconnect) + # Set disconnect callback - both SerialConnection and BLEConnection use set_disconnect_callback + self._radio_connection.set_disconnect_callback(self._handle_radio_disconnect) # Connect result = await self._radio_connection.connect() diff --git a/tests/test_proxy.py b/tests/test_proxy.py index bf3e571..2287d80 100644 --- a/tests/test_proxy.py +++ b/tests/test_proxy.py @@ -33,7 +33,7 @@ async def send(self, data): raise ConnectionError("Not connected") self.send_buffer.append(data) - def set_disconnect_handler(self, handler): + def set_disconnect_callback(self, handler): self.on_disconnect = handler def set_reader(self, reader):