Skip to content

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
Oppzippy:masterfrom
krus22222-art:fix/windows-rfcomm-winsock-fallback
Open

krus22222-art wants to merge 1 commit into
Oppzippy:masterfrom
krus22222-art:fix/windows-rfcomm-winsock-fallback

Conversation

@krus22222-art

Copy link
Copy Markdown

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 GetRfcommServicesForIdWithCacheModeAsync only returns the headset (00001108) and handsfree (0000111e) services, both cached and uncached. The vendor service 0cf12d31-fac3-4553-bd80-d6832e7b3116 is never listed, so select_service fails with DeviceNotFound. This matches the output posted in #215.

However, the service is there:

  • A Winsock AF_BTH / BTHPROTO_RFCOMM socket connected with serviceClassId = 0cf12d31-… and port = 0 (so Windows does its own SDP lookup) connects, and the device answers the state request.
  • Connecting by raw RFCOMM channel (1) also works and returns the same state packet.

Change

When the strategy is RfcommServiceSelectionStrategy::Constant(uuid) and WinRT doesn't list the service, WindowsRfcommBackend::connect now falls back to a Winsock connection by service class id (new connection_backend/windows/winsock.rs). The WinRT path is unchanged for devices where it already works.

  • WinsockRfcommConnection implements RfcommConnection: a reader thread using recv, send for writes, and the connection status set to Disconnected when recv ends.
  • as_windows_u64 is no longer test-only, because it's needed to build SOCKADDR_BTH.
  • Adds the Win32_Devices_Bluetooth and Win32_Networking_WinSock features to the windows dependency.

Testing

On Windows 11 with the Motion+ connected:

  • openscq30 device -a <mac> list-settings lists 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 --get reads back the new values from the device.
  • cargo test -p openscq30-lib connection_backend, cargo fmt, and cargo clippy -p openscq30-lib all 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

…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>
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