Skip to content

Windows: Add support for setting use_cached_services to False in connect method #96

@gudnimg

Description

@gudnimg

https://bleak.readthedocs.io/en/latest/api/args.html#bleak.args.winrt.WinRTClientArgs

On most machines I've used I need to set this flag on the newest version of Bleak & WinRT. Otherwise connecting can take multiple retries (dozens most of the time) before I get a connection. A real productivity killer :)

This is a quirk in Windows and can be hardware dependent, which is why Bleak exposes this flag. It would be awesome if this library can support it.

Not sure what is the best way to do this, but this works in another script I have:

winrt = {}
if args.disable_service_cache:
    winrt = {"use_cached_services": False}

async with BleakClient( device, disconnected_handler, winrt=winrt ) as client:
    # Do stuff

Works on Linux too since the winrt argument is just ignored when not using Windows WinRT backend.

I can help contribute this change if needed. Just a question about how we want the interface to look like 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions