feat: Log new devices with '(new)' suffix
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
9
scan.py
9
scan.py
@@ -13,6 +13,8 @@ BLUEZ_SERVICE = 'org.bluez'
|
||||
ADAPTER_IFACE = 'org.bluez.Adapter1'
|
||||
DEVICE_IFACE = 'org.bluez.Device1'
|
||||
|
||||
seen_devices = set()
|
||||
|
||||
async def get_adapter(bus):
|
||||
"""Gets the first Bluetooth adapter found."""
|
||||
introspection = await bus.introspect(BLUEZ_SERVICE, '/')
|
||||
@@ -33,7 +35,12 @@ def on_interfaces_added(path, interfaces):
|
||||
address = device_properties.get('Address')
|
||||
alias = device_properties.get('Alias')
|
||||
if address and alias and alias.value:
|
||||
logging.info(f"Found: {alias.value} ({address.value})")
|
||||
addr_str = address.value
|
||||
if addr_str not in seen_devices:
|
||||
seen_devices.add(addr_str)
|
||||
logging.info(f"Found: {alias.value} ({addr_str}) (new)")
|
||||
else:
|
||||
logging.info(f"Found: {alias.value} ({addr_str})")
|
||||
|
||||
async def main():
|
||||
"""Main function to run the scanner."""
|
||||
|
||||
Reference in New Issue
Block a user