-
Notifications
You must be signed in to change notification settings - Fork 334
Description
Hi all,
I have the following setup:
bleak version: 1.1.1
Python version: 3.13.7
Operating System: windows 11
and the following relevant code:
async with BleakClient(device, timeout = 60) as client:
if not client.is_connected:
print("Unable to connect.")
return
print("Connected.")
char = services.get_characteristic(uuid)
if char and "write" in char.properties:
timestamp = int(time.time())
timestamp_bytes = struct.pack('<I', timestamp)
try:
#client.pair()
await client.write_gatt_char(uuid, timestamp_bytes, response = True)
except Exception as e:
print(f"Error writing to {uuid}: {e}")
I am unable to write to the characteristic of an external BLE client when authentication is needed. By the way, our device needs the client to pair using a keypass. I have tried to pair the device using Windows control panel and running the above code, but I get the error [WinError -2147023673] The user has cancelled the operation.
If instead I do not pair the device and directly run the code then I get the error Could not write value b'm\x87\xcdh' to characteristic 001C: Protocol Error 0x05: Insufficient Authentication, and no prompt is displayed by Windows so to introduce the passkey.
Finally, if I enable the code line client.pair(), I get another error, Could not pair with device: FAILED.
I would appreciate some help on this.
Thank you in advance