feat: filter scanner Bluetooth devices from display
- Add bt_mac field to scanner config for identifying scanner BT adapters - Store bt_mac in peers table for peer scanners - Filter out devices matching scanner BT MACs from all views - Prevents scanners from appearing as devices in device lists/maps Config: scanner.bt_mac = "XX:XX:XX:XX:XX:XX" API: /api/peers/register accepts bt_mac field Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -210,6 +210,12 @@ class DeviceDatabase:
|
||||
)
|
||||
""")
|
||||
|
||||
# Add bt_mac column to peers table if missing (for scanner BT filtering)
|
||||
try:
|
||||
cursor.execute("ALTER TABLE peers ADD COLUMN bt_mac TEXT")
|
||||
except sqlite3.OperationalError:
|
||||
pass # Column already exists
|
||||
|
||||
# Add notes column to devices table if missing (for sync)
|
||||
try:
|
||||
cursor.execute("ALTER TABLE devices ADD COLUMN notes TEXT")
|
||||
@@ -941,7 +947,7 @@ class DeviceDatabase:
|
||||
|
||||
def register_peer(self, scanner_id: str, name: str, url: str,
|
||||
floor: Optional[int] = None, latitude: Optional[float] = None,
|
||||
longitude: Optional[float] = None) -> bool:
|
||||
longitude: Optional[float] = None, bt_mac: Optional[str] = None) -> bool:
|
||||
"""Register a peer scanner.
|
||||
|
||||
Args:
|
||||
@@ -951,6 +957,7 @@ class DeviceDatabase:
|
||||
floor: Floor where peer scanner is located
|
||||
latitude: GPS latitude of peer
|
||||
longitude: GPS longitude of peer
|
||||
bt_mac: Bluetooth MAC address of the scanner (for filtering from device lists)
|
||||
|
||||
Returns:
|
||||
True if newly registered, False if updated existing
|
||||
@@ -964,16 +971,17 @@ class DeviceDatabase:
|
||||
exists = cursor.fetchone() is not None
|
||||
|
||||
cursor.execute("""
|
||||
INSERT INTO peers (scanner_id, name, url, floor, latitude, longitude, last_seen, registered_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO peers (scanner_id, name, url, floor, latitude, longitude, bt_mac, last_seen, registered_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(scanner_id) DO UPDATE SET
|
||||
name = excluded.name,
|
||||
url = excluded.url,
|
||||
floor = excluded.floor,
|
||||
latitude = excluded.latitude,
|
||||
longitude = excluded.longitude,
|
||||
bt_mac = COALESCE(excluded.bt_mac, peers.bt_mac),
|
||||
last_seen = excluded.last_seen
|
||||
""", (scanner_id, name, url, floor, latitude, longitude, timestamp, timestamp))
|
||||
""", (scanner_id, name, url, floor, latitude, longitude, bt_mac, timestamp, timestamp))
|
||||
|
||||
conn.commit()
|
||||
return not exists
|
||||
|
||||
Reference in New Issue
Block a user