Skip to content

Fix stale Bluetooth readings and the integration becoming unavailable - #16

Merged
PyFlat-JR merged 2 commits into
feature/inferred-chargingfrom
fix/widget-device-limit
Oct 8, 2026
Merged

PyFlat-JR merged 2 commits into
feature/inferred-chargingfrom
fix/widget-device-limit

Conversation

@PyFlat-JR

Copy link
Copy Markdown
Member

What does this PR do?

Fixes Bluetooth devices going stale and the integration becoming unavailable with many devices.

Bluetooth on Windows

  • Each Bluetooth device ran its own PowerShell per poll, which scanned the whole PnP tree twice. That took 3.3 s per device, and six at once took 13.5 s against the 10 s read timeout, so from about five Bluetooth devices every one went stale ("No signal").
  • WindowsBluetoothBatteryReader (replaces PowerShellPnpBatteryReader) 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 through BluetoothSnapshot, like on macOS.
  • Get-PnpDeviceProperty batched 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.
  • BluetoothPnpLevels keeps 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

  • Macro Deck throttles all of a plugin's callbacks together, adb included. With four phones over adb the poll used up that budget, and a refused RegisterWidgetTypeAsync left the whole integration unusable (every widget "unavailable").
  • HostCallRetry retries refused calls with backoff; the widget-type registration and the config reads use it.
  • adb phones are read two at a time, so the poll never hits the host's four concurrent adb calls.

Checklist

  • I have read AGENTS.md and CONTRIBUTING.md.
  • dotnet build and dotnet test pass locally (0 warnings, 274 tests).
  • I updated README.md / AGENTS.md if this changes what they describe.
  • If this touches a device backend: I tested it against the real hardware (see below).

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.

@PyFlat-JR
PyFlat-JR added this pull request to stack #18 October 8, 2026 07:25
@PyFlat-JR
PyFlat-JR merged commit 8c51915 into main Oct 8, 2026
3 checks passed
@PyFlat-JR
PyFlat-JR deleted the fix/widget-device-limit branch October 8, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant