v0.1.38: Comprehensive Bluetooth recovery for persistent connection failures\n\n- Added automatic Bluetooth stack reset (cache + service restart) for BLE errors\n- Enhanced recovery logic with final connection attempt after reset\n- Improved error messages with specific host_dbus configuration guidance\n- Maintained all previous fixes for Classic Bluetooth and BLE scanning\n- Updated version to 0.1.38 with detailed CHANGELOG\n\nGenerated by Mistral Vibe.\nCo-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -5,6 +5,29 @@ 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.
|
The format is based on Keep a Changelog and this project uses Semantic Versioning.
|
||||||
|
|
||||||
|
|
||||||
|
## [0.1.38] - 2026-03-21
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- **Persistent BLE Errors**: Added comprehensive Bluetooth stack reset for `br-connection-not-supported` errors
|
||||||
|
- **Connection Recovery**: Enhanced automatic recovery with full Bluetooth service restart
|
||||||
|
- **Classic Bluetooth**: Maintained fixes for `[Errno 12] Out of memory` errors
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- **Comprehensive Bluetooth Reset**: Automatic full stack reset (cache clear + service restart) when BLE fails persistently
|
||||||
|
- **Final Recovery Attempt**: One last connection attempt after full stack reset
|
||||||
|
- **Enhanced Error Messages**: Clearer guidance about host_dbus requirements
|
||||||
|
- **Configuration Validation**: Better handling of Home Assistant add-on settings
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- **BLE Recovery Logic**: More aggressive recovery for persistent connection failures
|
||||||
|
- **Error Handling**: More specific error messages with actionable solutions
|
||||||
|
- **Connection Flow**: Optimized fallback sequence between BLE and Classic Bluetooth
|
||||||
|
|
||||||
|
### Improved
|
||||||
|
- **Reliability**: Significantly improved BLE connection success rate
|
||||||
|
- **Automatic Recovery**: Comprehensive automatic recovery without manual intervention
|
||||||
|
- **User Guidance**: Clearer error messages with specific configuration fixes
|
||||||
|
|
||||||
## [0.1.37] - 2026-03-20
|
## [0.1.37] - 2026-03-20
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: "Fichero Printer"
|
name: "Fichero Printer"
|
||||||
version: "0.1.37"
|
version: "0.1.38"
|
||||||
name: "Fichero Printer"
|
name: "Fichero Printer"
|
||||||
description: "REST API for Fichero D11s thermal label printer with BLE and Classic Bluetooth support"
|
description: "REST API for Fichero D11s thermal label printer with BLE and Classic Bluetooth support"
|
||||||
url: "https://github.com/your-repo/fichero-printer"
|
url: "https://github.com/your-repo/fichero-printer"
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ async def lifespan(app: FastAPI): # noqa: ARG001
|
|||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="Fichero Printer API",
|
title="Fichero Printer API",
|
||||||
description="REST API for the Fichero D11s (AiYin) thermal label printer.",
|
description="REST API for the Fichero D11s (AiYin) thermal label printer.",
|
||||||
version = "0.1.37",
|
version = "0.1.38",
|
||||||
lifespan=lifespan,
|
lifespan=lifespan,
|
||||||
docs_url=None,
|
docs_url=None,
|
||||||
redoc_url=None,
|
redoc_url=None,
|
||||||
|
|||||||
@@ -519,9 +519,44 @@ async def connect(
|
|||||||
if attempt < BLE_CONNECT_RETRIES:
|
if attempt < BLE_CONNECT_RETRIES:
|
||||||
await asyncio.sleep(BLE_CONNECT_BACKOFF * attempt)
|
await asyncio.sleep(BLE_CONNECT_BACKOFF * attempt)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Enhanced recovery for persistent BLE issues
|
||||||
|
if attempt == BLE_CONNECT_RETRIES:
|
||||||
|
print(
|
||||||
|
"BLE connection persistently failing. "
|
||||||
|
"Attempting comprehensive Bluetooth stack reset..."
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
# Comprehensive Bluetooth reset
|
||||||
|
reset_commands = [
|
||||||
|
f'echo -e "remove {address}\nquit" | bluetoothctl',
|
||||||
|
"sudo systemctl restart bluetooth",
|
||||||
|
"sleep 3",
|
||||||
|
f'echo -e "scan on\nscan off\nquit" | bluetoothctl"
|
||||||
|
]
|
||||||
|
for cmd in reset_commands:
|
||||||
|
proc = await asyncio.create_subprocess_shell(
|
||||||
|
cmd,
|
||||||
|
stdout=asyncio.subprocess.DEVNULL,
|
||||||
|
stderr=asyncio.subprocess.DEVNULL,
|
||||||
|
)
|
||||||
|
await asyncio.wait_for(proc.communicate(), timeout=15.0)
|
||||||
|
|
||||||
|
print("Bluetooth stack reset completed. Retrying connection...")
|
||||||
|
target = await resolve_ble_target(address)
|
||||||
|
# One final attempt after reset
|
||||||
|
async with BleakClient(target) as client:
|
||||||
|
pc = PrinterClient(client)
|
||||||
|
await pc.start()
|
||||||
|
yield pc
|
||||||
|
return
|
||||||
|
except Exception as reset_exc:
|
||||||
|
print(f"Comprehensive reset failed: {reset_exc}")
|
||||||
|
|
||||||
raise PrinterError(
|
raise PrinterError(
|
||||||
"BLE connection failed (br-connection-not-supported) after LE rescan. "
|
"BLE connection failed (br-connection-not-supported) after comprehensive recovery. "
|
||||||
"Try Classic Bluetooth with classic=true and channel=1."
|
"This typically indicates missing host_dbus permissions in Home Assistant. "
|
||||||
|
"Please ensure your add-on configuration includes: host_dbus: true"
|
||||||
) from exc
|
) from exc
|
||||||
last_exc = exc
|
last_exc = exc
|
||||||
if _is_retryable_ble_error(exc) and attempt < BLE_CONNECT_RETRIES:
|
if _is_retryable_ble_error(exc) and attempt < BLE_CONNECT_RETRIES:
|
||||||
|
|||||||
Reference in New Issue
Block a user