Repository navigation
fix(windows): fall back to an RFCOMM channel when UUID connect fails - #10
Merged
almasumdev merged 1 commit intoNov 12, 2026
Merged
Conversation
Some paired SPP devices make Winsock's own service-class resolution fail with WSAEADDRNOTAVAIL (10049) although their serial service works. On that error only, retry on the channel an SDP query reports and, for SPP, on RFCOMM channel 1. Other failures end as before. The connectionFailed message now carries the WSA error codes, and its details add wsaError. Tested on Windows 11 with a serial thermal printer that failed with 10049 before the fix and connects and prints after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Thanks a lot @ahmeddhus, this is a great fix. Limiting the fallback to It's merged and released in 1.7.4, now on pub.dev. The red Android check on this PR came from a Gradle version the newest Flutter no longer accepts, not from your change. That's fixed on main now. If flutter_classic_bluetooth is useful to you, a star on the repo would be much appreciated. And you're very welcome to send more fixes. |
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 this changes
On Windows,
connect()lets Winsock resolve the service UUID through SDP. With somedevices that resolution fails with
WSAEADDRNOTAVAIL(10049), even though the deviceis paired and its SPP service works. Windows had created a COM port for it, and a raw
socket on RFCOMM channel 1 connected and printed.
On that error only,
connect()now:WSALookupServiceBegin) reports, thenOther failures (out of range, refused, …) end exactly as before, with no extra wait.
The
connectionFailedmessage now includes the WSA error codes, and its details addwsaError, so a failure like this one is visible from Dart. The change is limited towindows/flutter_classic_bluetooth_plugin.cpp, and the Dart API is unchanged.Platforms touched
How it was tested
Windows 11 (build 26300) with a "Qsprinter" serial thermal printer (it reports vendor
ID
05AC).securewas true or false.The printer was paired, and Windows showed its SPP service as COM4.
RFCOMM channel 1 connected and printed.
connect()succeeds and the printer prints, from a real app that uses theplugin. Discovery and pairing are unchanged.
Checks
dart format .flutter analyzereports no issuesflutter testpasses (214 tests); native Windows tests pass (3/3)CHANGELOG.mdupdated (as 1.7.4; happy to rename the heading)