diff --git a/fichero_printer/CHANGELOG.md b/fichero_printer/CHANGELOG.md index 9e18f48..a52b579 100644 --- a/fichero_printer/CHANGELOG.md +++ b/fichero_printer/CHANGELOG.md @@ -4,6 +4,15 @@ 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.30] - 2026-03-16 + +### Fixed +- **BLE Connection**: Restored fallback to raw address string when BLE scan fails to find the specific device. This fixes connectivity for devices that are reachable but not advertising (e.g. during rapid reconnection or BlueZ cache issues), resolving "BLE device not found during scan" errors. + +### Added +- **Web UI**: Restored support for the modern, responsive web interface. If the build artifacts are present in `fichero/web`, they will be served by default. +- **Web UI**: Added a `?legacy=true` query parameter to the root URL to force the simple server-side rendered UI, which includes the new debug scan tool. ## [0.1.29] - 2026-03-16 ### Fixed diff --git a/fichero_printer/fichero/api.py b/fichero_printer/fichero/api.py index 55018e9..fbedf20 100644 --- a/fichero_printer/fichero/api.py +++ b/fichero_printer/fichero/api.py @@ -27,8 +27,10 @@ from typing import Annotated from fastapi import FastAPI, File, Form, HTTPException, UploadFile from fastapi.middleware.cors import CORSMiddleware from fastapi.openapi.docs import get_swagger_ui_html -from fastapi.responses import HTMLResponse, RedirectResponse +from fastapi.responses import HTMLResponse +from fastapi.staticfiles import StaticFiles from PIL import Image +from bleak import BleakScanner from fichero.cli import DOTS_PER_MM, do_print from fichero.imaging import text_to_image @@ -75,7 +77,7 @@ async def lifespan(app: FastAPI): # noqa: ARG001 app = FastAPI( title="Fichero Printer API", description="REST API for the Fichero D11s (AiYin) thermal label printer.", - version = "0.1.29", + version = "0.1.30", lifespan=lifespan, docs_url=None, redoc_url=None, @@ -88,6 +90,13 @@ app.add_middleware( allow_headers=["*"], ) +# Serve static files for the modern web UI (if built and present in 'web' dir) +_WEB_ROOT = Path(__file__).parent / "web" +if _WEB_ROOT.exists(): + # Typical SPA assets folder + if (_WEB_ROOT / "assets").exists(): + app.mount("/assets", StaticFiles(directory=_WEB_ROOT / "assets"), name="assets") + def _address(address: str | None) -> str | None: """Return the effective BLE address (request value overrides env default).""" @@ -105,21 +114,67 @@ def _ui_html() -> str: return "
Scans for all nearby BLE devices to help with debugging connection issues.
+ + +