fix: Preserve ScanResponse on Windows and resolve cross-platform N/A device names#461
Open
Yongle-Fu wants to merge 3 commits intodeviceplug:devfrom
Open
fix: Preserve ScanResponse on Windows and resolve cross-platform N/A device names#461Yongle-Fu wants to merge 3 commits intodeviceplug:devfrom
Yongle-Fu wants to merge 3 commits intodeviceplug:devfrom
Conversation
added 3 commits
April 14, 2026 20:21
Stopping a scan or calling clear_peripherals() currently evicts active connections from the internal state map. This fixes cross-platform consistency by ensuring connected devices are always retained (matching the established behavior pattern of macOS CoreBluetooth and Linux BlueZ).
…anResponses The Windows WinRT BLE watcher previously dropped all ScanResponse packets when a UUID filter was applied, because ScanResponses lack the service UUIDs present in the main advertisement. This introduces a lightweight Address cache within the watcher closure, allowing subsequent ScanResponse packets to pass through the filter if the device previously advertised the requested UUID.
…LOCAL_NAME Windows (WinRT): - Parse SHORT_LOCAL_NAME (0x08) and COMPLETE_LOCAL_NAME (0x09) from DataSections - Prevent short names from overwriting complete names across split packets macOS (CoreBluetooth): - Prefer advertisement_name (scan response) over peripheral.name() (GAP cache), as GAP names are frequently truncated short names - Add length protections in update_name() to prevent shorter names from overwriting longer complete names in successive updates Android: - Restore upstream MTU auto-negotiation compatibility
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.
This PR resolves 3 critical and long-standing behavior inconsistencies across the Windows and macOS backends, strictly enforcing lifecycle contracts and BLE specifications.
1. Common: Fix accidental eviction of connected peripherals
Problem:
AdapterManager.clear_peripherals()was previously unconditionally emptying the internal device map. This meant that whenever scanning was stopped, any active/connected peripherals were instantly silently evicted, killing the connection.Fix: Introduced
.retain()to filter out connections checkingis_connected()sync-safe loop. CoreBluetooth/BlueZ semantics are now properly enforced across all platforms.2. WinRT: Prevent Service-UUID filters from silently dropping ScanResponse
Problem: Windows
ScanResponsepackets contain vital identity information (like Name) but often omit the UUIDs found in the primary advertisement. Because the WinRTwatcherapplied the UUID filter strictly to the contents of every single packet, allScanResponsepackets were silently dropped, resulting in "N/A" device names.Fix: Implemented a lightweight, tightly-scoped
BluetoothAddresscache within the WinRTwatcher. If a device's initial advertisement passes the UUID filter, its address is cached, granting safe passage for its subsequent UUIDlessScanResponse.3. Cross-platform: Enforce COMPLETE_LOCAL_NAME priority
macOS (CoreBluetooth):
advertisement_name(Scan Response / Complete Name) is now strongly preferred over the internalperipheral.name()GAP cache (which operates as a truncated short name).update_name()to prevent subsequent incomplete packets from wiping out a previously parsed long name.Windows (WinRT):
SHORT_LOCAL_NAME (0x08)andCOMPLETE_LOCAL_NAME (0x09)directly fromDataSections.