mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 06:40:00 -07:00
Fix BT device type field collision - 'type' was being overwritten
The device dict had a 'type' field (audio, phone, etc.) that was overwriting the queue message 'type: device' field. Fixed by: - Spreading device first, then setting 'type': 'device' - Adding 'device_type' field for the device classification - Updating frontend to use device_type for display 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
17
intercept.py
17
intercept.py
@@ -3854,7 +3854,7 @@ HTML_TEMPLATE = '''
|
|||||||
address: device.mac,
|
address: device.mac,
|
||||||
message: device.name,
|
message: device.name,
|
||||||
model: device.manufacturer,
|
model: device.manufacturer,
|
||||||
type: device.type
|
device_type: device.device_type || device.type || 'other'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update visualizations
|
// Update visualizations
|
||||||
@@ -3878,22 +3878,24 @@ HTML_TEMPLATE = '''
|
|||||||
card = document.createElement('div');
|
card = document.createElement('div');
|
||||||
card.id = 'bt_' + device.mac.replace(/:/g, '');
|
card.id = 'bt_' + device.mac.replace(/:/g, '');
|
||||||
card.className = 'sensor-card';
|
card.className = 'sensor-card';
|
||||||
|
const devType = device.device_type || device.type || 'other';
|
||||||
card.style.borderLeftColor = device.tracker ? 'var(--accent-red)' :
|
card.style.borderLeftColor = device.tracker ? 'var(--accent-red)' :
|
||||||
device.type === 'phone' ? 'var(--accent-cyan)' :
|
devType === 'phone' ? 'var(--accent-cyan)' :
|
||||||
device.type === 'audio' ? 'var(--accent-green)' :
|
devType === 'audio' ? 'var(--accent-green)' :
|
||||||
'var(--accent-orange)';
|
'var(--accent-orange)';
|
||||||
output.insertBefore(card, output.firstChild);
|
output.insertBefore(card, output.firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const devType = device.device_type || device.type || 'other';
|
||||||
const typeIcon = {
|
const typeIcon = {
|
||||||
'phone': '📱', 'audio': '🎧', 'wearable': '⌚', 'tracker': '📍',
|
'phone': '📱', 'audio': '🎧', 'wearable': '⌚', 'tracker': '📍',
|
||||||
'computer': '💻', 'input': '⌨️', 'other': '📶'
|
'computer': '💻', 'input': '⌨️', 'other': '📶'
|
||||||
}[device.type] || '📶';
|
}[devType] || '📶';
|
||||||
|
|
||||||
card.innerHTML = `
|
card.innerHTML = `
|
||||||
<div class="header" style="display: flex; justify-content: space-between; margin-bottom: 8px;">
|
<div class="header" style="display: flex; justify-content: space-between; margin-bottom: 8px;">
|
||||||
<span class="device-name">${typeIcon} ${escapeHtml(device.name)}</span>
|
<span class="device-name">${typeIcon} ${escapeHtml(device.name)}</span>
|
||||||
<span style="color: #444; font-size: 10px;">${escapeHtml(device.type.toUpperCase())}</span>
|
<span style="color: #444; font-size: 10px;">${escapeHtml(devType.toUpperCase())}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="sensor-data">
|
<div class="sensor-data">
|
||||||
<div class="data-item">
|
<div class="data-item">
|
||||||
@@ -5757,9 +5759,10 @@ def stream_bt_scan(process, scan_mode):
|
|||||||
bt_devices[mac] = device
|
bt_devices[mac] = device
|
||||||
|
|
||||||
queue_data = {
|
queue_data = {
|
||||||
'type': 'device',
|
**device,
|
||||||
|
'type': 'device', # Must come after **device to not be overwritten
|
||||||
|
'device_type': device.get('type', 'other'),
|
||||||
'action': 'new' if is_new else 'update',
|
'action': 'new' if is_new else 'update',
|
||||||
**device
|
|
||||||
}
|
}
|
||||||
print(f"[BT] Queuing device: {mac} - {name}")
|
print(f"[BT] Queuing device: {mac} - {name}")
|
||||||
bt_queue.put(queue_data)
|
bt_queue.put(queue_data)
|
||||||
|
|||||||
Reference in New Issue
Block a user