From 5016327bc25cf7411ebe0b8a915771d0243a3da7 Mon Sep 17 00:00:00 2001 From: Smittix Date: Wed, 21 Jan 2026 15:54:05 +0000 Subject: [PATCH] Fix API/frontend field name mismatches - Add 'available' alias for 'can_scan' in capabilities - Add 'preferred_backend' alias for 'recommended_backend' - Add 'id' field to adapter info for frontend compatibility Co-Authored-By: Claude Opus 4.5 --- utils/bluetooth/capability_check.py | 7 +++++-- utils/bluetooth/models.py | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/utils/bluetooth/capability_check.py b/utils/bluetooth/capability_check.py index 3609dac..7995501 100644 --- a/utils/bluetooth/capability_check.py +++ b/utils/bluetooth/capability_check.py @@ -130,6 +130,7 @@ def _check_adapters(caps: SystemCapabilities) -> None: if 'org.bluez.Adapter1' in interfaces: adapter_props = interfaces['org.bluez.Adapter1'] adapter_info = { + 'id': str(path), # Alias for frontend 'path': str(path), 'name': str(adapter_props.get('Name', 'Unknown')), 'address': str(adapter_props.get('Address', 'Unknown')), @@ -168,9 +169,11 @@ def _check_adapters_hciconfig(caps: SystemCapabilities) -> None: # Match adapter line (e.g., "hci0: Type: Primary Bus: USB") adapter_match = re.match(r'^(hci\d+):', line) if adapter_match: + adapter_name = adapter_match.group(1) current_adapter = { - 'path': f'/org/bluez/{adapter_match.group(1)}', - 'name': adapter_match.group(1), + 'id': adapter_name, # Alias for frontend + 'path': f'/org/bluez/{adapter_name}', + 'name': adapter_name, 'address': 'Unknown', 'powered': False, 'discovering': False, diff --git a/utils/bluetooth/models.py b/utils/bluetooth/models.py index 7400c66..9261cca 100644 --- a/utils/bluetooth/models.py +++ b/utils/bluetooth/models.py @@ -336,6 +336,8 @@ class SystemCapabilities: def to_dict(self) -> dict: """Convert to dictionary for JSON serialization.""" return { + 'available': self.can_scan, # Alias for frontend compatibility + 'can_scan': self.can_scan, 'has_dbus': self.has_dbus, 'has_bluez': self.has_bluez, 'bluez_version': self.bluez_version, @@ -349,7 +351,7 @@ class SystemCapabilities: 'has_hcitool': self.has_hcitool, 'has_bluetoothctl': self.has_bluetoothctl, 'has_btmgmt': self.has_btmgmt, + 'preferred_backend': self.recommended_backend, # Alias for frontend 'recommended_backend': self.recommended_backend, - 'can_scan': self.can_scan, 'issues': self.issues, }