From 92a722477416fd29075e5a6ea12ca57e5fc696e5 Mon Sep 17 00:00:00 2001 From: paul2212 Date: Sat, 7 Mar 2026 22:50:57 +0100 Subject: [PATCH] Avoid raw MAC BLE fallback and bump to 0.1.14 --- CHANGELOG.md | 5 +++++ fichero/printer.py | 14 +++++++++++++- fichero_printer/CHANGELOG.md | 4 ++++ fichero_printer/config.yaml | 2 +- fichero_printer/fichero/printer.py | 14 +++++++++++++- pyproject.toml | 2 +- 6 files changed, 37 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ba2329..e51400f 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.14] - 2026-03-07 + +### Fixed +- Removed BLE fallback to raw MAC string when device resolution fails. The connector now requires a discovered LE device object, avoiding BlueZ BR/EDR misclassification that can cause `br-connection-not-supported`. + ## [0.1.13] - 2026-03-07 ### Fixed diff --git a/fichero/printer.py b/fichero/printer.py index be6f18f..38773e4 100644 --- a/fichero/printer.py +++ b/fichero/printer.py @@ -98,7 +98,19 @@ async def resolve_ble_target(address: str | None = None): """ if address: device = await BleakScanner.find_device_by_address(address, timeout=8.0) - return device or address + if device is not None: + return device + # Fallback to active scan/match before giving up; do not fall back to + # raw address because BlueZ may then attempt BR/EDR and fail with + # br-connection-not-supported. + devices = await BleakScanner.discover(timeout=8) + for d in devices: + if d.address and d.address.lower() == address.lower(): + return d + raise PrinterNotFound( + f"BLE device {address} not found during scan. " + "Ensure printer is on, awake, and in range." + ) devices = await BleakScanner.discover(timeout=8) for d in devices: if d.name and any(d.name.startswith(p) for p in PRINTER_NAME_PREFIXES): diff --git a/fichero_printer/CHANGELOG.md b/fichero_printer/CHANGELOG.md index 72089ce..62d281c 100644 --- a/fichero_printer/CHANGELOG.md +++ b/fichero_printer/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.1.14 + +- Prevented BLE fallback to raw MAC connects and now require discovered LE device resolution, reducing `br-connection-not-supported` regressions on some BlueZ hosts. + ## 0.1.13 - Marked BLE service-discovery disconnect errors as retryable (`failed to discover services, device disconnected`), so the add-on retries automatically. diff --git a/fichero_printer/config.yaml b/fichero_printer/config.yaml index 66475d0..a0171a7 100644 --- a/fichero_printer/config.yaml +++ b/fichero_printer/config.yaml @@ -1,5 +1,5 @@ name: "Fichero Printer" -version: "0.1.13" +version: "0.1.14" 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 be6f18f..38773e4 100644 --- a/fichero_printer/fichero/printer.py +++ b/fichero_printer/fichero/printer.py @@ -98,7 +98,19 @@ async def resolve_ble_target(address: str | None = None): """ if address: device = await BleakScanner.find_device_by_address(address, timeout=8.0) - return device or address + if device is not None: + return device + # Fallback to active scan/match before giving up; do not fall back to + # raw address because BlueZ may then attempt BR/EDR and fail with + # br-connection-not-supported. + devices = await BleakScanner.discover(timeout=8) + for d in devices: + if d.address and d.address.lower() == address.lower(): + return d + raise PrinterNotFound( + f"BLE device {address} not found during scan. " + "Ensure printer is on, awake, and in range." + ) devices = await BleakScanner.discover(timeout=8) for d in devices: if d.name and any(d.name.startswith(p) for p in PRINTER_NAME_PREFIXES): diff --git a/pyproject.toml b/pyproject.toml index 49716c2..7ce7b9a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fichero-printer" -version = "0.1.13" +version = "0.1.14" description = "Fichero D11s thermal label printer - BLE CLI tool" requires-python = ">=3.10" dependencies = [