diff --git a/main.py b/main.py index 9fa6dca..b2e0f28 100644 --- a/main.py +++ b/main.py @@ -13,6 +13,7 @@ from aiomqtt import Client from dbus_next.aio import MessageBus from dbus_next.service import ServiceInterface, method from dbus_next.constants import BusType +from dbus_next.errors import DBusError from dbus_next import Variant @@ -27,6 +28,7 @@ AGENT_IFACE = 'org.bluez.Agent1' AGENT_MANAGER_IFACE = 'org.bluez.AgentManager1' AGENT_PATH = '/io/bluetooth_speaker/agent' CAPABILITY = 'DisplayYesNo' +HFP_UUID = '0000111e-0000-1000-8000-00805f9b34fb' class Agent(ServiceInterface): def __init__(self, interface_name): @@ -69,8 +71,11 @@ class Agent(ServiceInterface): @method() def AuthorizeService(self, device: 'o', uuid: 's'): - logging.info(f"AuthorizeService for {device} with uuid {uuid}") - pass + logging.info(f"AuthorizeService request for device {device} with UUID {uuid}") + if uuid.lower() == HFP_UUID: + logging.warning("Rejecting Hands-Free Profile (HFP) connection.") + raise DBusError('org.bluez.Error.Rejected', 'HFP profile not supported') + logging.info(f"Authorizing service UUID {uuid}") @method() def Cancel(self):