diff --git a/scan.py b/scan.py index 3a13274..7966dcf 100644 --- a/scan.py +++ b/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."""