Unable to unpair with device
See original GitHub issue- bleak version: 0.13.0
- Python version: 3.8.5
- Operating System: Win10
Description
I am trying to pair and unpair with an Arduino Nano 33 BLE. I want to pair since there is an HID service I want to use which won’t work using the standard connect method since it throws an Access Denied.
What I Did
Pairing works fine and I can use it as an HID. I am planning to use unpair for disconnecting. Calling unpair does nothing.
The issue seems to be that unpair uses the following boolean variable -
self._requester.device_information.pairing.is_paired
client=BleakClientWinRT(device_address)
is_connected=await client.connect()
is_paired=await client.pair(2)
print(is_paired)
await asyncio.sleep(10)
await client.unpair()
Even though the pair
function returns true, the above boolean variable remains false. Possibly something on the firmware end and I can’t figure out how to fix that.
Is it possible to have another boolean instance variable to store the pairing status at the software end and raise an exception if unpair fails? Is it also possible that the above boolean variable isn’t being refreshed after pairing in Bleak?
This is a bit urgent so I’d appreciate some quick help! TIA
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (8 by maintainers)
Top GitHub Comments
Yes, that was exactly what I was looking at. However, I guess the attributes of
_requester
are not writable. When I added the following-self._requester.device_information=await DeviceInformation.create_from_id_async(self._requester.device_information.id)
I get this attribute error-
AttributeError: attribute 'device_information' of '_bleak_winrt_Windows_Devices_Bluetooth.BluetoothLEDevice' objects is not writable
The device_information object is being used only in the
pair
andunpair
functions. If you intend to keep the_requester
read-only, what we can do is create a localdevice_information
object for these functions and use them for checks.I tried this and it worked. Doesn’t seem to break anything for now.
Hi guys, I have been MIA for a while, but I was able to test this enough and the solution does work and would be a good stand-in while the new pairing functionality is completed. I have linked the PR to the issue 😃 (#757 )