Repository navigation
fix(lib): fall back to winsock when windows doesn't list rfcomm service (GH-215) - #417
Open
krus22222-art wants to merge 1 commit into
Open
krus22222-art wants to merge 1 commit into
krus22222-art wants to merge 1 commit into
Conversation
…ce (OppzippyGH-215) On some Soundcore Motion+ units, GetRfcommServicesForIdWithCacheModeAsync only returns the headset and handsfree services, so the vendor service 0cf12d31-fac3-4553-bd80-d6832e7b3116 is never found and connecting fails with "device not found". Connecting with a Winsock AF_BTH socket using the service class id and port 0 makes Windows do its own SDP lookup, which does find the service, so use that as a fallback for RfcommServiceSelectionStrategy::Constant. 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.
Fixes the Windows "device not found" error with the Soundcore Motion+ from #215.
Problem
On my Motion+ (A3116, firmware 90.01, serial ACCR7L4G…), WinRT's
GetRfcommServicesForIdWithCacheModeAsynconly returns the headset (00001108) and handsfree (0000111e) services, both cached and uncached. The vendor service0cf12d31-fac3-4553-bd80-d6832e7b3116is never listed, soselect_servicefails withDeviceNotFound. This matches the output posted in #215.However, the service is there:
AF_BTH/BTHPROTO_RFCOMMsocket connected withserviceClassId = 0cf12d31-…andport = 0(so Windows does its own SDP lookup) connects, and the device answers the state request.Change
When the strategy is
RfcommServiceSelectionStrategy::Constant(uuid)and WinRT doesn't list the service,WindowsRfcommBackend::connectnow falls back to a Winsock connection by service class id (newconnection_backend/windows/winsock.rs). The WinRT path is unchanged for devices where it already works.WinsockRfcommConnectionimplementsRfcommConnection: a reader thread usingrecv,sendfor writes, and the connection status set toDisconnectedwhenrecvends.as_windows_u64is no longer test-only, because it's needed to buildSOCKADDR_BTH.Win32_Devices_BluetoothandWin32_Networking_WinSockfeatures to thewindowsdependency.Testing
On Windows 11 with the Motion+ connected:
openscq30 device -a <mac> list-settingslists all settings (equalizer, volume, voice prompt, auto power off, battery, serial, firmware). It logs the warning about falling back to winsock.setting --set volumeAdjustments=…followed by a fresh--getreads back the new values from the device.cargo test -p openscq30-lib connection_backend,cargo fmt, andcargo clippy -p openscq30-liball pass.I haven't tested other devices on Windows. The fallback only runs when the WinRT lookup already failed, so the existing path shouldn't be affected.
🤖 Generated with Claude Code