mirror of
https://github.com/smittix/intercept.git
synced 2026-07-08 01:28:13 -07:00
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:
+21
-9
@@ -5796,13 +5796,22 @@
|
|||||||
let btRadarAnimFrame = null;
|
let btRadarAnimFrame = null;
|
||||||
let btRadarDevices = [];
|
let btRadarDevices = [];
|
||||||
|
|
||||||
// Refresh Bluetooth interfaces
|
// Refresh Bluetooth interfaces (legacy - now handled by BluetoothMode.init())
|
||||||
function refreshBtInterfaces() {
|
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')
|
fetch('/bt/interfaces')
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
const select = document.getElementById('btInterfaceSelect');
|
if (!data.interfaces || data.interfaces.length === 0) {
|
||||||
if (data.interfaces.length === 0) {
|
|
||||||
select.innerHTML = '<option value="">No BT interfaces found</option>';
|
select.innerHTML = '<option value="">No BT interfaces found</option>';
|
||||||
} else {
|
} else {
|
||||||
select.innerHTML = data.interfaces.map(i =>
|
select.innerHTML = data.interfaces.map(i =>
|
||||||
@@ -5810,13 +5819,16 @@
|
|||||||
).join('');
|
).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update tool status
|
// Update tool status (if element exists)
|
||||||
const statusDiv = document.getElementById('btToolStatus');
|
const statusDiv = document.getElementById('btToolStatus');
|
||||||
statusDiv.innerHTML = `
|
if (statusDiv) {
|
||||||
<span>hcitool:</span><span class="tool-status ${data.tools.hcitool ? 'ok' : 'missing'}">${data.tools.hcitool ? 'OK' : 'Missing'}</span>
|
statusDiv.innerHTML = `
|
||||||
<span>bluetoothctl:</span><span class="tool-status ${data.tools.bluetoothctl ? 'ok' : 'missing'}">${data.tools.bluetoothctl ? 'OK' : 'Missing'}</span>
|
<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
|
// Start Bluetooth scan
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ class BleakScanner:
|
|||||||
manufacturer_data=manufacturer_data,
|
manufacturer_data=manufacturer_data,
|
||||||
service_uuids=list(adv_data.service_uuids) if adv_data.service_uuids else [],
|
service_uuids=list(adv_data.service_uuids) if adv_data.service_uuids else [],
|
||||||
service_data=service_data,
|
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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user