bleak icon indicating copy to clipboard operation
bleak copied to clipboard

Cache service resolution on connect when using BlueZ/Dbus backend when requested

Open bdraco opened this issue 1 year ago • 2 comments

If the device was previously connected and we have the the service collection already built, it can be reused for the next connection if the device has not since been removed from the bus when the dangerous_use_bleak_cache flag is passed.

For devices that connect and disconnect frequently this can make operations up to an magnitude faster once the first connection has been made and the device has not been removed from the bus since the last connection.

In testing this significantly reduced the time it took to execute operations on Ble devices. The goal is to be able to quickly operate Bluetooth locks (and other similar devices)

bdraco avatar Aug 06 '22 19:08 bdraco

This will not work with devices that suffer from the issues described in #882. We need to wait for "ServicesResolved" after connect to ensure that BlueZ is not longer adding or removing service/characteristic/descriptor d-bus objects.

I suppose we could make this opt-in for devices that are known to be well behaved (meaning they don't trigger the BlueZ bugs).

dlech avatar Aug 06 '22 19:08 dlech

I reworked it to be opt-in and renamed it to be dangerous_use_bleak_cache

bdraco avatar Aug 06 '22 20:08 bdraco

Thanks

bdraco avatar Sep 05 '22 23:09 bdraco