Setup:
Windows 11 (22H2 version 2261.4317)
Python 3.12.10
bleak-3.0.1
winrt-Windows.Devices.Bluetooth-3.2.1
winrt-Windows.Devices.Bluetooth.Advertisement-3.2.1
winrt-Windows.Devices.Bluetooth.GenericAttributeProfile-3.2.1
winrt-Windows.Devices.Enumeration-3.2.1
winrt-Windows.Devices.Radios-3.2.1
winrt-Windows.Foundation-3.2.1
winrt-Windows.Foundation.Collections-3.2.1
winrt-Windows.Storage.Streams-3.2.1
winrt-runtime-3.2.1
Minimal python code to reproduce the issue:
import asyncio
import bleak
_client = bleak.BleakClient(address_or_ble_device="5C:53:10:5A:DF:CD", services=("0000ffe5-0000-1000-8000-00805f9b34fb",), timeout=10.0, pair=False,)
asyncio.run(_client.connect())
Console log:
C:\Users\khrusas>python
Python 3.12.10 (tags/v3.12.10:0cc8128, Apr 8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> import bleak
>>> _client = bleak.BleakClient(address_or_ble_device="5C:53:10:5A:DF:CD", services=("0000ffe5-0000-1000-8000-00805f9b34fb",), timeout=10.0, pair=False,)
>>> asyncio.run(_client.connect())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\khrusas\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 195, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\khrusas\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\khrusas\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 691, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\khrusas\AppData\Local\Programs\Python\Python312\Lib\site-packages\bleak\__init__.py", line 660, in connect
await self._backend.connect(self._pair_before_connect, **kwargs)
File "C:\Users\khrusas\AppData\Local\Programs\Python\Python312\Lib\site-packages\bleak\backends\winrt\client.py", line 430, in connect
self.services = await self._get_services(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\khrusas\AppData\Local\Programs\Python\Python312\Lib\site-packages\bleak\backends\winrt\client.py", line 735, in _get_services
result = await FutureLike(
^^^^^^^^^^^^^^^^^
File "C:\Users\khrusas\AppData\Local\Programs\Python\Python312\Lib\site-packages\bleak\backends\winrt\client.py", line 1195, in __await__
yield self # This tells Task to wait for completion.
^^^^^^^^^^
File "C:\Users\khrusas\AppData\Local\Programs\Python\Python312\Lib\site-packages\bleak\backends\winrt\client.py", line 1136, in result
raise WinError(error_code)
PermissionError: [WinError -2147024874] The device does not recognize the command.
BUT
If I change the setup to following (Windows 11 -> Windows 10):
Windows 10 (22H2 version 19045.6456)
Python 3.12.10
bleak-3.0.1
And try to connect to the same BLE peripheral device following the same way, everything works fine (no any errors are raised from WinRT backend, so the conection is successfull).
I attached zip-archive which contains all packets captured in Wireshark .pcapng format (captured by Windows BTP btvs.exe):
win11_error.pcapng (from Windows 11 - error during connection)
win10_no_error.pcapng (from Windows 10 - successfull connection)
wireshark.zip
Setup:
Minimal python code to reproduce the issue:
Console log:
BUT
If I change the setup to following (Windows 11 -> Windows 10):
And try to connect to the same BLE peripheral device following the same way, everything works fine (no any errors are raised from WinRT backend, so the conection is successfull).
I attached zip-archive which contains all packets captured in Wireshark .pcapng format (captured by Windows BTP btvs.exe):
win11_error.pcapng(from Windows 11 - error during connection)win10_no_error.pcapng(from Windows 10 - successfull connection)wireshark.zip