You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used bleak library to pair the ble devices but get error like
| Attempting to pair with EA:A0:01:2B:32:A9-- | -- | Failed to pair: org. bluez.Error.AuthenticationRejected
What I Did
importasynciofrombleakimportBleakScanner, BleakClientWahdat_name="SM-DOM2"characteristic_uuid="00002A37-0000-1000-8000-00805f9b34fb"asyncdefscan_and_pair():
# Scan for devicesprint("Scanning for BLE devices...")
devices=awaitBleakScanner.discover()
ifnotdevices:
print("No BLE devices found.")
return# List found devicesprint("Found devices:")
fori, deviceinenumerate(devices):
print(f"{i}: {device.name} - {device.address}")
# Check if Wahdat's Android Watch is found by namedevice_found=Falsefordeviceindevices:
ifdevice.name==Wahdat_name:
device_found=Trueselected_device=device.addressbreakprint("SELECTED",selected_device)
ifnotdevice_found:
print(f"{Wahdat_name} not found.")
return# Pair with Wahdat's Android WatchasyncwithBleakClient(selected_device) asclient:
try:
print(f"Attempting to pair with {selected_device} ({Wahdat_name})...")
paired=awaitclient.pair()
ifpaired:
value=awaitclient.read_gatt_char(characteristic_uuid)
print("Read value:", value)
print(f"Successfully paired with {selected_device} ({Wahdat_name})")
else:
print(f"Failed to pair with {selected_device} ({Wahdat_name})")
exceptExceptionase:
print(f"Error during pairing: {e}")
asyncio.run(scan_and_pair())
The text was updated successfully, but these errors were encountered:
If BlueZ can't pair, then Bleak isn't going to be able to either. You could try logging Bluetooth packets to see what is going on behind the scenes to try to figure out what the actual problem is.
bleak version: 0.22.2
Python version:3.11.6
BlueZ version:5.68
Description
I used bleak library to pair the ble devices but get error like
What I Did
The text was updated successfully, but these errors were encountered: