question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 2 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
harshdeepsehgalcommented, Dec 27, 2021

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 and unpair functions. If you intend to keep the _requester read-only, what we can do is create a local device_information object for these functions and use them for checks.

device_information=await DeviceInformation.create_from_id_async(self._requester.device_information.id)
if device_information.pairing.is_paired:
    unpairing_result = (
        await device_information.pairing.unpair_async()
     )

I tried this and it worked. Doesn’t seem to break anything for now.

0reactions
harshdeepsehgalcommented, Feb 4, 2022

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 )

Read more comments on GitHub >

github_iconTop Results From Across the Web

6 Ways to Troubleshoot If You Can't Remove a Bluetooth Device
Remove a device using Settings · 1. Click Start and then click Settings. · 2. Click Bluetooth & devices in the pane on...
Read more >
FIX: Can't Remove Bluetooth Devices on Windows 10
FIX: Can't Remove Bluetooth Devices on Windows 10 · Use Airplane Mode on Windows 10 · Restart Device Association Service · Update the...
Read more >
Fix Unable to remove Bluetooth device on windows 10 / 11
Fix 1 – Try to remove bluetooth device in Airplane mode · Fix 2 – Using Control Panel · Fix 3 – Using...
Read more >
How to Fix Bluetooth Pairing Problems - Techlicious
What you can do about Bluetooth pairing failures · 1. Make sure Bluetooth is turned on · 2. Determine which pairing process your...
Read more >
If you can't pair an Apple Watch with your iPhone
If you have its paired iPhone, unpair your Apple Watch · Open the Watch app on your iPhone, tap the My Watch tab,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found