feat: Configure Bluetooth agent for DisplayYesNo and optimize connection
This commit is contained in:
16
main.py
16
main.py
@@ -27,7 +27,7 @@ DEVICE_IFACE = 'org.bluez.Device1'
|
|||||||
AGENT_IFACE = 'org.bluez.Agent1'
|
AGENT_IFACE = 'org.bluez.Agent1'
|
||||||
AGENT_MANAGER_IFACE = 'org.bluez.AgentManager1'
|
AGENT_MANAGER_IFACE = 'org.bluez.AgentManager1'
|
||||||
AGENT_PATH = '/io/bluetooth_speaker/agent'
|
AGENT_PATH = '/io/bluetooth_speaker/agent'
|
||||||
CAPABILITY = 'NoInputNoOutput'
|
CAPABILITY = 'DisplayYesNo'
|
||||||
CALLS_SERVICE_UUID = '0000111e-0000-1000-8000-00805f9b34fb'
|
CALLS_SERVICE_UUID = '0000111e-0000-1000-8000-00805f9b34fb'
|
||||||
AUDIO_SERVICE_UUID = '0000110d-0000-1000-8000-00805f9b34fb'
|
AUDIO_SERVICE_UUID = '0000110d-0000-1000-8000-00805f9b34fb'
|
||||||
|
|
||||||
@@ -94,13 +94,13 @@ async def trust_and_connect_device(device_path):
|
|||||||
|
|
||||||
device_iface = device_obj.get_interface(DEVICE_IFACE)
|
device_iface = device_obj.get_interface(DEVICE_IFACE)
|
||||||
|
|
||||||
try:
|
#try:
|
||||||
logging.info(f"Attempting to disconnect {device_path} before connecting.")
|
# logging.info(f"Attempting to disconnect {device_path} before connecting.")
|
||||||
await device_iface.call_disconnect()
|
# await device_iface.call_disconnect()
|
||||||
await asyncio.sleep(1) # Give it a moment to settle
|
# await asyncio.sleep(1) # Give it a moment to settle
|
||||||
except DBusError as e:
|
#except DBusError as e:
|
||||||
# This is expected if the device is not already connected.
|
# # This is expected if the device is not already connected.
|
||||||
logging.info(f"Disconnect failed (this is likely okay): {e}")
|
# logging.info(f"Disconnect failed (this is likely okay): {e}")
|
||||||
|
|
||||||
await device_iface.call_connect()
|
await device_iface.call_connect()
|
||||||
logging.info(f'Connected to device {device_path}')
|
logging.info(f'Connected to device {device_path}')
|
||||||
|
|||||||
Reference in New Issue
Block a user