I'm attempting to read some characteristics from a Bluetooth device. The device requires a Pin to pair but I can't find any resources on how to enter a pin with python-bleak.
My code is below. It will successfully connect and get the services. Any attempt to bond with the device gives me an error.
bleak.exc.BleakError: Could not pair with device: 19
Is it possible to pair to a device that requires a pin using python-bleak? If not is there a different way to pair to the device with python?
import asyncio
from bleak import BleakScanner, BleakClient, exc, BLEDevice, backends
from typing import Any, List, Dict
deviceAdress = "zz:yy:xx:ww:vv:uu".upper()
fixedPin = "012345"
async def GetServices(client:BleakClient) -> backends.service.BleakGATTServiceCollection:
services = await client.get_services()
return services
async def main():
device:BLEDevice = await BleakScanner.find_device_by_address(deviceAdress)
print(device)
client:BleakClient = BleakClient(device, timeout=60)
try:
connectResults = await client.connect()
except Exception as e:
print(e)
await GetServices(client) # Successfully gets services
pairResults = await client.pair() # Fails here
asyncio.run(main())