Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BleakClientWinRT.get_services takes longer time in Windows 11 than in Windows 10 #686

@hbldh

Description

@hbldh
  • bleak version: 0.14.0a1 (feature/wtd branch)
  • Python version: 3.7.8
  • Operating System: Windows 11 ('10', '10.0.22000', 'SP0', 'Multiprocessor Free')

Description

get_services call take a lot longer time in Windows 11 than in Windows 10.

What I Did

A near 10 second connection delay in Windows 11 comparing to 1-5 seconds in Windows 10 was surprising to me. This issue is more of a mental note than an error report. Based on memory, it was faster than 10 seconds earlier.

If anyone else using Bleak and noticing the same, please verify that it takes longer time in Windows 11 if you have experienced the same, or refute it if you have experienced the opposite.

import os

os.environ["BLEAK_LOGGING"] = "1"

import asyncio
from bleak import BleakClient, BleakScanner

address = "24:71:89:cc:09:05"
MODEL_NBR_UUID = "00002a24-0000-1000-8000-00805f9b34fb"


async def run(address):
    device = await BleakScanner.find_device_by_address(address)
    async with BleakClient(device) as client:
        model_number = await client.read_gatt_char(MODEL_NBR_UUID)
        print("Model Number: {0}".format("".join(map(chr, model_number))))

asyncio.run(run(address))

Output:

2021-11-06 21:54:40,931 bleak.backends.winrt.scanner DEBUG: Received 24:71:89:CC:09:05: Unknown.
2021-11-06 21:54:40,933 bleak.backends.winrt.scanner DEBUG: 2 devices found. Watcher status: 3.
2021-11-06 21:54:40,933 bleak.backends.winrt.client DEBUG: Connecting to BLE device @ 24:71:89:CC:09:05
2021-11-06 21:54:41,551 bleak.backends.winrt.client DEBUG: _ConnectionStatusChanged_Handler: 1
2021-11-06 21:54:41,551 bleak.backends.winrt.client DEBUG: Get Services...
2021-11-06 21:54:53,966 bleak.backends.winrt.client INFO: Services resolved for BleakClientWinRT (24:71:89:CC:09:05)
2021-11-06 21:54:54,085 bleak.backends.winrt.client DEBUG: Read Characteristic 000C : bytearray(b'CC2650 SensorTag')
Model Number: CC2650 SensorTag
2021-11-06 21:54:54,086 bleak.backends.winrt.client DEBUG: Disconnecting from BLE device...
2021-11-06 21:54:57,205 bleak.backends.winrt.client DEBUG: _ConnectionStatusChanged_Handler: 0

Metadata

Metadata

Assignees

Labels

Backend: WinRTIssues or PRs relating to the WinRT backendOpinions AppreciatedPlease add an opinion on your desired resolution on this issue!help wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions