Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding option to avoid using cached services in .NET backend. #431

Merged
merged 3 commits into from
Jan 26, 2021

Conversation

hbldh
Copy link
Owner

@hbldh hbldh commented Jan 25, 2021

Added

  • Keyword arguments to get_services method on BleakClient.
  • Keyword argument use_cached on .NET backend, to enable uncached reading of services, characteristics and descriptors in Windows.

Setting use_cached to True by default, since reading them from device noticably increased the connection time. Devices with mutable services are more rare than the opposite I think.

This might solve #429.

@hbldh hbldh added enhancement New feature or request Backend: pythonnet Issues or PRs relating to the .NET/pythonnet backend labels Jan 25, 2021
@hbldh hbldh requested a review from dlech January 25, 2021 09:38
@hbldh hbldh self-assigned this Jan 25, 2021
@ChinmayJoshi-eaton
Copy link

bleak.exc.BleakDotNetTaskError: System.Exception: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

facing this issue

Copy link
Collaborator

@dlech dlech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me.

Do you know what the behavior is on macOS? I know on Linux/BlueZ you have to actually remove the device and discover it again to no use the cache. So it might be worth mentioning that in the docs somewhere. It causes problems for people with microcontrollers that can change the services on the device.

@hbldh
Copy link
Owner Author

hbldh commented Jan 25, 2021

I will have to look into #429 before merging this...

No, I have very little knowledge about how it performs in the other backends, primarily because I do not modify my devices services. I implemented this because it looked like low hanging fruit that might solve an issue...

On macOS I have no idea how to handle this and on Linux only what you have found out and shared here and in other issues.
It might go in the FAQ/troubleshooting section that you set up.

@hbldh
Copy link
Owner Author

hbldh commented Jan 26, 2021

Added some documentation on the topic.

@hbldh hbldh merged commit 7c65d74 into develop Jan 26, 2021
@hbldh hbldh deleted the feature/caching-improvement-windows branch January 26, 2021 09:18
@dlech
Copy link
Collaborator

dlech commented Jan 26, 2021

Added some documentation on the topic.

I like it. 👍

@hbldh
Copy link
Owner Author

hbldh commented Jan 27, 2021

I might have used your words from another issue describing what needs to be done on BlueZ...😄 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend: pythonnet Issues or PRs relating to the .NET/pythonnet backend enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants