diff --git a/main.py b/main.py index 62edbef..1fc328c 100644 --- a/main.py +++ b/main.py @@ -17,6 +17,7 @@ from dbus_next import Variant bus = None +agent_instance = None # --- Bluetooth constants and agent --- BLUEZ_SERVICE = 'org.bluez' @@ -104,8 +105,9 @@ async def get_adapter(): return None async def register_agent(): - agent = Agent(AGENT_IFACE) - bus.export(AGENT_PATH, agent) + global agent_instance + agent_instance = Agent(AGENT_IFACE) + bus.export(AGENT_PATH, agent_instance) introspection = await bus.introspect(BLUEZ_SERVICE, '/org/bluez') manager_obj = bus.get_proxy_object(BLUEZ_SERVICE, '/org/bluez', introspection)