From 3c34c6b34ea26330d974ca1c7b73de97746849dc Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 27 Oct 2025 14:45:48 +0100 Subject: [PATCH] deal with bad established ble cx --- src/meshcore/ble_cx.py | 7 ++++++- src/meshcore/meshcore.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/meshcore/ble_cx.py b/src/meshcore/ble_cx.py index afe0c05..e0bd429 100644 --- a/src/meshcore/ble_cx.py +++ b/src/meshcore/ble_cx.py @@ -113,7 +113,12 @@ class BLEConnection: except TimeoutError: return None - await self.client.start_notify(UART_TX_CHAR_UUID, self.handle_rx) + try: + await self.client.start_notify(UART_TX_CHAR_UUID, self.handle_rx) + except AttributeError : + logger.info("Connection is not established, need to restart it") + logger.debug("in ble_cx.connect()") + return None nus = self.client.services.get_service(UART_SERVICE_UUID) if nus is None: diff --git a/src/meshcore/meshcore.py b/src/meshcore/meshcore.py index 17aba46..1c5a373 100644 --- a/src/meshcore/meshcore.py +++ b/src/meshcore/meshcore.py @@ -165,6 +165,7 @@ class MeshCore: await self.dispatcher.start() result = await self.connection_manager.connect() if result is None: + await self.dispatcher.stop() raise ConnectionError("Failed to connect to device") return await self.commands.send_appstart()