Repository navigation
Windows: map ATT errors to UniversalBleErrorCode; share the mapping table - #353
Merged
Merged
Conversation
fotiDim
force-pushed
the
windows-att-error-codes
branch
from
October 16, 2026 13:02
bfe7b2a to
c5fa51f
Compare
Clarify the docs touched by the Windows ATT error mapping change: - att_error_cases.tsv: 0x80-0xFF are unknownError only for the mappings the fixture drives (Dart/Android/Windows); note the Linux wrapper falls back to the caller's default code. - extractBlueZAttErrorCode: document the case-insensitive phrase match and the best-effort bare 0x fallback. - att_error_mapper.h: describe the raw ProtocolError byte (also used for descriptor discovery) and the application-defined range. - CHANGELOG/README: state what is covered on Windows (characteristic and descriptor reads/writes, SetNotifiable) and that connect-time discovery and Linux/Web are unchanged. - universal_ble_plugin.cpp: comment why discovery failures skip the ATT code mapping.
rohitsangwan01
approved these changes
Oct 19, 2026
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 half of #348, and guards the ATT error mapping so the per-platform tables cannot drift apart.
Windows: map ATT errors to
UniversalBleErrorCodeOn Windows, a read, write or subscription that the peripheral refuses now reports the matching
UniversalBleErrorCode(insufficientEncryption,insufficientAuthentication,readNotPermitted, ...), as Android already does. Until now every refusal reached Dart as the genericfailed.Windows reports a refused GATT operation as
GattCommunicationStatus::ProtocolErrorand puts the ATT error code in the result'sProtocolErrorbyte, which the plugin was discarding.att_error_mappermaps every ATT error code to the sameUniversalBleErrorCodeAndroid'sgattStatusToUniversalBleErrorCodegives the same code.create_flutter_error_from_gatt_resultuses that mapping when the status isProtocolErrorand Windows supplied a protocol error, otherwise it falls back tocreate_flutter_error_from_gatt_communication_status. The raw ATT code is kept indetails.GetDescriptorsForUuidAsync). Writes and subscribe move to the...WithResultAsyncoverloads (GattWriteResultcarriesProtocolError); these require Windows 10 1703 (API contract v4), and the plugin already requires SDK 10.0.19041.Shared conformance fixture
New
test/fixtures/att_error_cases.tsvis driven by the Dart, Kotlin and C++ tests, so the Android, Dart and Windows mappings are held to one table instead of four hand-maintained copies (the same pattern astest/fixtures/scan_filter_cases.tsv):test/att_error_conformance_test.dartandroid/src/test/.../UniversalBleAttErrorConformanceTest.ktwindows/test/att_error_mapper_test.cppApple's
attErrorToUniversalBleErrorCode(#350, now onmain) maps identically; its XCTest still asserts a hand-written list and can be pointed at this fixture later.Linux: stricter BlueZ ATT-code extraction
UniversalBleErrorParser.extractBlueZAttErrorCodenow matches theATT error: 0xNNphrase before falling back to a bare hex value, so an unrelated hex value elsewhere in the BlueZ message is no longer mistaken for the ATT code. Extracted into the parser so it is unit tested.Docs
Corrected the
createFlutterError(detailsis numeric, not the enum name) comments on Apple and Windows.Tests
flutter test: 290 pass, including the new Dart conformance test and the BlueZ extraction tests.flutter analyzeanddart formatclean.ctest(portable Windows suite) passes locally, including the fixture-drivenatt_error_mapper_test.Notes
...WithResultAsync/ProtocolErrorAPIs; CI'swindowsjob (flutter build windows+ctest) validates them.