Repository navigation
feat: one-click Connect / Disconnect for paired AirPods - #195
Merged
Merged
Conversation
Replace the tray "Pair / Reconnect" deep link with real "Connect AirPods" / "Disconnect AirPods" actions for already-paired AirPods (follow-up to bhemsen#7). - Core: IBluetoothAudioConnector boundary plus BluetoothAudioLinkController (send, confirm via endpoint state every 500 ms, re-send every 10 s, give up after 45 s) and BluetoothAudioLinkText (labels, honest notices, and the Bluetooth-settings fallback decision), covered by fake-based tests. - Windows: WindowsBluetoothAudioConnector walks the AirPods' render and capture endpoint topology to the Bluetooth A2DP and hands-free filters and sends the public one-shot reconnect/disconnect KS property (KSPROPSETID_BtAudio, ksmedia.h) via IKsControl, the same request the Sound control panel's Connect uses. It is driver-free, needs no admin, and never throws. - App: TrayConnectController runs the operation off the UI thread, shows Connecting... / Disconnecting..., notifies the outcome and opens Windows Bluetooth settings on any failure. "Open Bluetooth settings" stays for pairing. - Docs: README, the user guide and the architecture docs (component map, flow 6, diagrams) are updated; the user guide labels are pinned by tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
Hi @bhemsen 👋 friendly ping on this one. I've tested it on my own AirPods Pro (Windows 11): one-click Connect and Disconnect from the tray work, and I've been using this build every day since. It's become my favourite PodBridge feature. The CI / CodeQL / Dependency Review workflows are waiting for maintainer approval since this PR comes from a fork ("Approve and run" on the Checks tab). Locally Happy to adjust anything — naming, menu layout, retry timings, or splitting the PR if that makes it easier to review. Thanks! |
bhemsen
reviewed
Oct 6, 2026
- Skip an endpoint that fails mid-enumeration instead of degrading the whole result to NotFound/Rejected (and a confirmation poll to a false timeout). - Match AirPods only (new AirPodsNameHeuristic.IsAirPodsName) so the "AirPods" items never connect or disconnect a paired Beats device. - Read the filter id with IConnector::GetDeviceIdConnectedTo instead of the IPart/GetTopologyObject walk (same ids, verified read-only on hardware); drop the now-unused IPart declaration. - Rename the KSPROPERTY struct to KsPropertyHeader and make the IMMDeviceWithState slot comments 0-based. - Docs: user guide and architecture flow 6. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
bhemsen
added a commit
that referenced
this pull request
Oct 6, 2026
Release notes fragment for v1.3.0: one-click Connect / Disconnect (#195) plus CI and dependency maintenance since v1.2.1. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
The tray's "Pair / Reconnect" entry only deep-linked to Windows Bluetooth settings (Phase-1 placeholder, see the old comment in
TrayIcon.cs). This PR replaces it with a real one-clickConnect AirPodsfor already-paired AirPods, plusDisconnect AirPods. Both are driver-free and need no admin (Tier 1,asInvokerunchanged).Open Bluetooth settingsstays for pairing new AirPods, and is also the automatic fallback whenever a connect or disconnect fails.This follows up on #7 (closed; it delivered the tray status and the pairing deep link that this replaces), so there is no
Closes.How it works
The adapter sends the same driver request the Windows Sound control panel → Connect uses:
ACTIVE | UNPLUGGED) and keeps the AirPods ones usingAirPodsNameHeuristic.IsAirPodsName, which matches AirPods only, so paired Beats are excluded. An endpoint that fails during enumeration is skipped and doesn't degrade the whole result.IDeviceTopology→IConnector::GetDeviceIdConnectedTo. It keeps the Bluetooth audio filters ({2}.\\?\bth…): the A2DP filter (BTHENUM) and the hands-free filter (BTHHFENUM).KSPROPERTY_ONESHOT_RECONNECT/KSPROPERTY_ONESHOT_DISCONNECT(KSPROPSETID_BtAudio,KSPROPERTY_TYPE_GET, no data buffer) viaIKsControl::KsPropertyto every filter, like Windows does.DEVICE_STATE_ACTIVEmeans connected,DEVICE_STATE_UNPLUGGEDmeans paired but disconnected.S_OKonly means the driver accepted the request, so success is always confirmed by the endpoint state.Layering
Bluetooth/IBluetoothAudioConnectoris the new OS boundary.BluetoothAudioLinkControlleris the policy: a pre-check (not found / already in state), then send, confirm by polling every 500 ms, re-send every 10 s, and give up after 45 s. Real-hardware testing showed that the first reconnect right after a disconnect is often silently ignored while the old link winds down, and that 15 s was too short. A single-operation guard makes it returnBusyif an operation is already running.BluetoothAudioLinkTextholds the labels, the honest notifications, and the decision to fall back to settings.WindowsBluetoothAudioConnectorandInterop/BluetoothAudioInteropuse classic[ComImport]interop, consistent with the existing Core Audio interop, and reuseIMMDeviceEnumerator,IMMDeviceandNativeMethods.TrayConnectControllerruns the operation on the thread pool, so the UI thread is never blocked. While it runs, the item showsConnecting…/Disconnecting…and both items are disabled.Connected; Disconnect is enabled whileConnected(or when the status is still unknown).Honest behaviour
Clean-room / licensing
The constants are the public ones from the Windows SDK headers (
ksmedia.h:KSPROPSETID_BtAudio,KSPROPERTY_ONESHOT_RECONNECT/DISCONNECT;ks.h;mmdeviceapi.h;devicetopology.h) and are cited inBluetoothAudioInterop.cs. Prior art for the technique is m2jean/ToothTray (BSD-2); no code was copied from it. No driver, no elevation, no network.Docs
README.md: the quickstart now usesOpen Bluetooth settingsto pair and mentions one-clickConnect AirPods. The image alt text is made neutral.docs/user/README.md: covers setup, the tray menu (Connect / Disconnect, the wait of up to 45 s, the fallback, the several-AirPods note) and troubleshooting.docs/architecture.md: component map and a new key flow 6.docs/architecture-diagrams.md: layer map, interface map, and a new sequence diagram (3.3).UserDocsTestspins the new labels in the docs.Open Bluetooth settings.Not changed:
docs/example.pngstill shows the oldPair / Reconnectlabel; the screenshot needs re-capturing.docs/qa/and the archived specs are unchanged.Testing
Automated:
build/verify.ps1is green (build, analyzers as errors,dotnet format --verify-no-changes, tests: 388 Core + 46 Windows passing). The new tests are:BluetoothAudioLinkControllerTests(11 tests: already connected, not found, confirmed on poll, first request ignored then re-sent at 10 s, timeout after 45 s with 5 sends, result mapping, disconnect, busy guard, cancellation, …).BluetoothAudioLinkTextTests.AirPodsNameHeuristicTestsfor the AirPods-onlyIsAirPodsName(Beats excluded).The timing tests are deterministic: a lock-step
FakeTimeProviderwrapper, with no real delays. I re-ran them 5× with no flakes.Real hardware (AirPods Pro "AirPods Pro (Anton)", Windows 11, this PR's code):
WindowsBluetoothAudioConnectorreportedGetLinkState() = Connectedwhile the AirPods were connected.BTHENUM#{0000110b-…}source and the hands-freeBTHHFENUM#bthhfpaudiowave filter.GetLinkState()reportedDisconnected(both endpointsUNPLUGGED), and the newGetDeviceIdConnectedTolookup returned exactly the same two filter ids as the previousIPartwalk.Connect AirPods/Disconnect AirPodsitems on the AirPods Pro. Both work, and I have been using it daily since.