mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 06:40:00 -07:00
Parse Bluetooth RSSI from bluetoothctl output
- Capture RSSI from [CHG] Device XX:XX RSSI: -XX lines - Update device RSSI in real-time as bluetoothctl reports changes - Auto-refresh selected device panel when RSSI updates - Preserve RSSI when merging device updates Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -219,10 +219,30 @@ def stream_bt_scan(process, scan_mode):
|
||||
line = re.sub(r'\r', '', line)
|
||||
|
||||
if 'Device' in line:
|
||||
# Check for RSSI update: [CHG] Device XX:XX:XX RSSI: -65
|
||||
rssi_match = re.search(r'([0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}).*RSSI:\s*(-?\d+)', line)
|
||||
if rssi_match:
|
||||
mac = rssi_match.group(1).upper()
|
||||
rssi = int(rssi_match.group(2))
|
||||
if mac in app_module.bt_devices:
|
||||
app_module.bt_devices[mac]['rssi'] = rssi
|
||||
app_module.bt_devices[mac]['last_seen'] = time.time()
|
||||
# Send RSSI update
|
||||
app_module.bt_queue.put({
|
||||
**app_module.bt_devices[mac],
|
||||
'type': 'device',
|
||||
'device_type': app_module.bt_devices[mac].get('type', 'other'),
|
||||
'action': 'update',
|
||||
})
|
||||
continue
|
||||
|
||||
# Check for new device: [NEW] Device XX:XX:XX Name
|
||||
match = re.search(r'([0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2})\s*(.*)', line)
|
||||
if match:
|
||||
mac = match.group(1).upper()
|
||||
name = match.group(2).strip()
|
||||
# Remove "RSSI: -XX" from name if present
|
||||
name = re.sub(r'\s*RSSI:\s*-?\d+\s*', '', name).strip()
|
||||
|
||||
manufacturer = get_manufacturer(mac)
|
||||
device = {
|
||||
|
||||
@@ -5957,6 +5957,10 @@
|
||||
device.tracker = device.tracker || { name: findMyInfo.type };
|
||||
}
|
||||
|
||||
// Merge with existing device data to preserve RSSI if not in update
|
||||
if (btDevices[device.mac] && !device.rssi && btDevices[device.mac].rssi) {
|
||||
device.rssi = btDevices[device.mac].rssi;
|
||||
}
|
||||
btDevices[device.mac] = device;
|
||||
|
||||
// Track signal history for graphs
|
||||
@@ -5971,6 +5975,11 @@
|
||||
pulseSignal();
|
||||
}
|
||||
|
||||
// Update selected device panel if this device is selected
|
||||
if (selectedBtDevice === device.mac) {
|
||||
updateBtSelectedDevice(device);
|
||||
}
|
||||
|
||||
// Check for tracker following
|
||||
checkTrackerFollowing(device);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user