Repository navigation
Fix stale Bluetooth readings and the integration becoming unavailable - #16
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes Bluetooth devices going stale and the integration becoming unavailable with many devices.
Bluetooth on Windows
WindowsBluetoothBatteryReader(replacesPowerShellPnpBatteryReader) walks the Bluetooth PnP nodes once per poll through cfgmgr32 (NativeDeviceProperties): 38 ms for every device. Every Bluetooth source of a poll shares that walk throughBluetoothSnapshot, like on macOS.Get-PnpDevicePropertybatched over many nodes returned values for only some of them, a different set on every run, so the config-flow picker sometimes showed devices without their level. It uses the same walk now.BluetoothPnpLevelskeeps the old rules: the level comes from the sibling node sharing the device's address (BLE first), a hand-typed sibling name such as "<device> Hands-Free AG" still resolves, and names compare ignoring case.Host throttle
RegisterWidgetTypeAsyncleft the whole integration unusable (every widget "unavailable").HostCallRetryretries refused calls with backoff; the widget-type registration and the config reads use it.Checklist
dotnet buildanddotnet testpass locally (0 warnings, 274 tests).Device/hardware tested against (if applicable)
Windows 11, Bluetooth: soundcore Sleep A30, soundcore Liberty 4 NC, Anker A7908, CORSAIR HS80 MAX, JBL Flip 4, JBL Go 4, POCO F8 Ultra, SC-PMX94. Every level matches the old per-device read, and the picker lists the same devices (
HardwareTests.Reads_every_bluetooth_device_in_one_poll). The throttle fix follows a user's log with four adb phones; the throttle itself was not reproduced here.