Fix legacy code conflicts and Bleak deprecation warning

- Add null checks to legacy refreshBtInterfaces() function
- Redirect to BluetoothMode.checkCapabilities() when available
- Fix Bleak deprecation: use AdvertisementData.connectable instead of device.metadata

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-01-21 15:56:04 +00:00
parent 5016327bc2
commit 187347e64b
2 changed files with 22 additions and 10 deletions
+21 -9
View File
@@ -5796,13 +5796,22 @@
let btRadarAnimFrame = null;
let btRadarDevices = [];
// Refresh Bluetooth interfaces
// Refresh Bluetooth interfaces (legacy - now handled by BluetoothMode.init())
function refreshBtInterfaces() {
// New Bluetooth mode uses /api/bluetooth/capabilities instead
// This function is kept for backwards compatibility but uses new API
if (typeof BluetoothMode !== 'undefined') {
BluetoothMode.checkCapabilities();
return;
}
// Legacy fallback (shouldn't be needed)
const select = document.getElementById('btInterfaceSelect') || document.getElementById('btAdapterSelect');
if (!select) return;
fetch('/bt/interfaces')
.then(r => r.json())
.then(data => {
const select = document.getElementById('btInterfaceSelect');
if (data.interfaces.length === 0) {
if (!data.interfaces || data.interfaces.length === 0) {
select.innerHTML = '<option value="">No BT interfaces found</option>';
} else {
select.innerHTML = data.interfaces.map(i =>
@@ -5810,13 +5819,16 @@
).join('');
}
// Update tool status
// Update tool status (if element exists)
const statusDiv = document.getElementById('btToolStatus');
statusDiv.innerHTML = `
<span>hcitool:</span><span class="tool-status ${data.tools.hcitool ? 'ok' : 'missing'}">${data.tools.hcitool ? 'OK' : 'Missing'}</span>
<span>bluetoothctl:</span><span class="tool-status ${data.tools.bluetoothctl ? 'ok' : 'missing'}">${data.tools.bluetoothctl ? 'OK' : 'Missing'}</span>
`;
});
if (statusDiv) {
statusDiv.innerHTML = `
<span>hcitool:</span><span class="tool-status ${data.tools.hcitool ? 'ok' : 'missing'}">${data.tools.hcitool ? 'OK' : 'Missing'}</span>
<span>bluetoothctl:</span><span class="tool-status ${data.tools.bluetoothctl ? 'ok' : 'missing'}">${data.tools.bluetoothctl ? 'OK' : 'Missing'}</span>
`;
}
})
.catch(err => console.warn('Legacy BT interface check failed:', err));
}
// Start Bluetooth scan
+1 -1
View File
@@ -164,7 +164,7 @@ class BleakScanner:
manufacturer_data=manufacturer_data,
service_uuids=list(adv_data.service_uuids) if adv_data.service_uuids else [],
service_data=service_data,
is_connectable=device.metadata.get('connectable', True) if hasattr(device, 'metadata') else True,
is_connectable=getattr(adv_data, 'connectable', True) if adv_data else True,
)