Fix Bluetooth RSSI capture from initial device discovery

When a new device is discovered with bluetoothctl, extract and
capture the RSSI value from the discovery line instead of
discarding it.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-01-08 14:56:55 +00:00
parent 82830c86ac
commit 97c957b70f
+7 -2
View File
@@ -275,7 +275,12 @@ def stream_bt_scan(process, scan_mode):
if match:
mac = match.group(1).upper()
name = match.group(2).strip()
# Remove "RSSI: -XX" from name if present
# Extract RSSI from name if present
rssi_in_name = re.search(r'RSSI:\s*(-?\d+)', name)
initial_rssi = int(rssi_in_name.group(1)) if rssi_in_name else None
# Remove "RSSI: -XX" from name
name = re.sub(r'\s*RSSI:\s*-?\d+\s*', '', name).strip()
manufacturer = get_manufacturer(mac)
@@ -284,7 +289,7 @@ def stream_bt_scan(process, scan_mode):
'name': name or '[Unknown]',
'manufacturer': manufacturer,
'type': classify_bt_device(name, None, None, manufacturer),
'rssi': None,
'rssi': initial_rssi,
'last_seen': time.time()
}