hbldh / bleak

A cross platform Bluetooth Low Energy Client for Python using asyncio
MIT License
1.74k stars 292 forks source link

Services not refreshed on Windows 11 #1639

Open mplantey-io opened 4 days ago

mplantey-io commented 4 days ago

Description

We need to connect to a BLE device, previously scanned. We connect successfully. Then enable the notify on SERVICE_CHANGED. We send a secret through one characteristic automatically discovered when connected. This secret activate a bunch of new services/characteristics. So we need to update the local view of the services when receiving SERVICE_CHANGED event.

What I Did

On linux, we discovered that trying to open a second connection to the device forces the services discovery, even if we get an error from the python script. On windows, we tried the same trick and we are just stuck without any error when creating the second connection to the same device.

After that, anyway, we can't disconnect. And we need a proper disconnection. When trying to disconnect, nothing happens.

In case we don't create a new parallel connection, we cannot access to the new services and we are stuck in the usage.

I know it seems OS specific but with Windows 11 it becomes difficult to capture logs. I'm trying to use Wireshark but nothing goes right, for now.

If you have any hint on how I can solve this, I would be very grateful.

Thanks,

dlech commented 4 days ago

Thanks for the report. This is the first time, if I recall correctly, we've had an actual use case for the services changed event like this.

I would be nice to find a nicer way to handle this. It would be helpful if I could get my hands on some hardware that works like this for testing.