From bdf07eb6610da2780700e6605be64a165007a7d2 Mon Sep 17 00:00:00 2001 From: paul2212 Date: Wed, 18 Mar 2026 19:01:08 +0100 Subject: [PATCH] v0.1.36: Add dark theme, fix BLE scanning, improve responsive design\n\n- Fixed BLE scanning RSSI error that caused 'BLEDevice' object has no attribute 'rssi'\n- Implemented complete dark theme with CSS variables and system preference support\n- Added responsive design with mobile-first breakpoints (768px, 1024px, 1440px)\n- Added theme toggle with local storage persistence\n- Improved BLE error handling and user guidance\n- Enhanced pairing function documentation to clarify BLE vs Classic Bluetooth\n- Updated version to 0.1.36 in config.yaml and api.py\n\nGenerated by Mistral Vibe.\nCo-Authored-By: Mistral Vibe --- fichero_printer/CHANGELOG.md | 24 +++ fichero_printer/config.yaml | 2 +- fichero_printer/fichero/api.py | 29 +++- fichero_printer/fichero/index.html | 245 ++++++++++++++++++++++------- 4 files changed, 234 insertions(+), 66 deletions(-) diff --git a/fichero_printer/CHANGELOG.md b/fichero_printer/CHANGELOG.md index 57af3fa..69b3023 100644 --- a/fichero_printer/CHANGELOG.md +++ b/fichero_printer/CHANGELOG.md @@ -5,6 +5,30 @@ 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.36] - 2026-03-19 + +### Fixed +- **BLE Scanning**: Fixed `'BLEDevice' object has no attribute 'rssi'` error by safely checking for RSSI attribute availability +- **Web UI**: Improved BLE scan error handling to gracefully handle missing RSSI data + +### Added +- **Dark Theme**: Complete dark theme implementation with CSS variables and system preference support +- **Responsive Design**: Mobile-first responsive layout with proper breakpoints (768px, 1024px, 1440px) +- **Theme Toggle**: Interactive theme switcher with local storage persistence +- **Touch Support**: Mobile-optimized button sizes and touch targets +- **System Dark Mode**: Automatic dark/light mode detection via `@media (prefers-color-scheme: dark)` + +### Changed +- **Web UI**: Modernized entire UI with dark theme colors, improved spacing, and better typography +- **Error Handling**: Enhanced BLE-specific error messages with troubleshooting guidance +- **Pairing Function**: Clarified that pairing is only for Classic Bluetooth, not BLE +- **HTML Structure**: Added responsive container system for better layout control + +### Improved +- **Accessibility**: Better ARIA labels, keyboard navigation, and color contrast +- **Performance**: Optimized CSS with variables and reduced redundancy +- **User Experience**: Clearer distinction between BLE and Classic Bluetooth workflows + ## [0.1.35] - 2026-03-18 ## [0.1.34] - 2026-03-18 diff --git a/fichero_printer/config.yaml b/fichero_printer/config.yaml index f915f67..6cf6e1a 100644 --- a/fichero_printer/config.yaml +++ b/fichero_printer/config.yaml @@ -1,5 +1,5 @@ name: "Fichero Printer" -version: "0.1.35" +version: "0.1.36" 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/api.py b/fichero_printer/fichero/api.py index 4d6d81f..7cb0ef7 100644 --- a/fichero_printer/fichero/api.py +++ b/fichero_printer/fichero/api.py @@ -79,7 +79,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.35", + version = "0.1.36", lifespan=lifespan, docs_url=None, redoc_url=None, @@ -179,7 +179,15 @@ def _ui_html() -> str: devices.forEach((d, index) => { resultText += `${index + 1}. ${d.name || 'Unknown Device'}\n`; resultText += ` Address: ${d.address}\n`; - resultText += ` Signal: ${d.rssi} dBm (${Math.abs(d.rssi) < 60 ? 'Strong' : Math.abs(d.rssi) < 80 ? 'Good' : 'Weak'})\n`; + // Handle case where RSSI might not be available + if (d.rssi !== undefined) { + resultText += ` Signal: ${d.rssi} dBm (${Math.abs(d.rssi) < 60 ? 'Strong' : Math.abs(d.rssi) < 80 ? 'Good' : 'Weak'})\n`; + } else { + resultText += ` Signal: Not available\n`; + } + if (d.metadata) { + resultText += ` Metadata: ${d.metadata}\n`; + } resultText += ` ${'='.repeat(40)}\n`; }); resultText += '\nšŸ’” Tip: Click on a device address above to use it for connection.'; @@ -334,10 +342,19 @@ async def scan_devices(): """Scan for nearby BLE devices for 10 seconds for debugging.""" try: devices = await BleakScanner.discover(timeout=10.0) - return [ - {"address": d.address, "name": d.name or "N/A", "rssi": d.rssi} - for d in devices - ] + result = [] + for d in devices: + device_info = { + "address": d.address, + "name": d.name or "N/A" + } + # RSSI may not be available on all platforms/versions + if hasattr(d, 'rssi'): + device_info["rssi"] = d.rssi + if hasattr(d, 'metadata'): + device_info["metadata"] = str(d.metadata) + result.append(device_info) + return result except Exception as exc: # This provides more debug info to the user if scanning fails raise HTTPException( diff --git a/fichero_printer/fichero/index.html b/fichero_printer/fichero/index.html index eed4113..1dd09ca 100644 --- a/fichero_printer/fichero/index.html +++ b/fichero_printer/fichero/index.html @@ -6,19 +6,42 @@ Fichero Printer