From 42e56e1b9f2892241c90988e8bdd7c583a906a34 Mon Sep 17 00:00:00 2001 From: paul2212 Date: Sat, 7 Mar 2026 15:12:56 +0100 Subject: [PATCH] Retry BLE service-discovery disconnect errors and bump to 0.1.13 --- CHANGELOG.md | 5 +++++ fichero/printer.py | 11 ++++++++++- fichero_printer/CHANGELOG.md | 4 ++++ fichero_printer/config.yaml | 2 +- fichero_printer/fichero/printer.py | 11 ++++++++++- pyproject.toml | 2 +- 6 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e29a1f2..3ba2329 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project are documented in this file. The format is based on Keep a Changelog and this project uses Semantic Versioning. +## [0.1.13] - 2026-03-07 + +### Fixed +- Treated BLE service-discovery disconnects (`failed to discover services, device disconnected`) as retryable transient errors in the BLE connect loop. + ## [0.1.12] - 2026-03-07 ### Fixed diff --git a/fichero/printer.py b/fichero/printer.py index a9fa089..be6f18f 100644 --- a/fichero/printer.py +++ b/fichero/printer.py @@ -426,7 +426,16 @@ async def connect( target = await resolve_ble_target(address) def _is_retryable_ble_error(exc: Exception) -> bool: msg = str(exc).lower() - return any(token in msg for token in ("timeout", "timed out", "br-connection-timeout")) + return any( + token in msg + for token in ( + "timeout", + "timed out", + "br-connection-timeout", + "failed to discover services", + "device disconnected", + ) + ) last_exc: Exception | None = None for attempt in range(1, BLE_CONNECT_RETRIES + 1): diff --git a/fichero_printer/CHANGELOG.md b/fichero_printer/CHANGELOG.md index 874fed6..72089ce 100644 --- a/fichero_printer/CHANGELOG.md +++ b/fichero_printer/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.1.13 + +- Marked BLE service-discovery disconnect errors as retryable (`failed to discover services, device disconnected`), so the add-on retries automatically. + ## 0.1.12 - Improved BLE connection target resolution by preferring discovered BLE device objects over raw MAC strings to avoid BlueZ `br-connection-not-supported` on some hosts. diff --git a/fichero_printer/config.yaml b/fichero_printer/config.yaml index 8189e2b..66475d0 100644 --- a/fichero_printer/config.yaml +++ b/fichero_printer/config.yaml @@ -1,5 +1,5 @@ name: "Fichero Printer" -version: "0.1.12" +version: "0.1.13" slug: "fichero_printer" description: "REST API for the Fichero D11s (AiYin) thermal label printer over Bluetooth" url: "https://git.leuschner.dev/Tobias/Fichero" diff --git a/fichero_printer/fichero/printer.py b/fichero_printer/fichero/printer.py index a9fa089..be6f18f 100644 --- a/fichero_printer/fichero/printer.py +++ b/fichero_printer/fichero/printer.py @@ -426,7 +426,16 @@ async def connect( target = await resolve_ble_target(address) def _is_retryable_ble_error(exc: Exception) -> bool: msg = str(exc).lower() - return any(token in msg for token in ("timeout", "timed out", "br-connection-timeout")) + return any( + token in msg + for token in ( + "timeout", + "timed out", + "br-connection-timeout", + "failed to discover services", + "device disconnected", + ) + ) last_exc: Exception | None = None for attempt in range(1, BLE_CONNECT_RETRIES + 1): diff --git a/pyproject.toml b/pyproject.toml index 8ee907c..49716c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fichero-printer" -version = "0.1.12" +version = "0.1.13" description = "Fichero D11s thermal label printer - BLE CLI tool" requires-python = ">=3.10" dependencies = [