Skip to content

fix(winrtble): request Coded PHY scanning only when the adapter supports it - #474

Open
userepo wants to merge 1 commit into
deviceplug:masterfrom
Poholos:fix/gate-coded-phy-on-adapter-support
Open

userepo wants to merge 1 commit into
deviceplug:masterfrom
Poholos:fix/gate-coded-phy-on-adapter-support

Conversation

@userepo

@userepo userepo commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #473. Related: #472.

Problem

#463 (shipped in 0.13.0) made the WinRT watcher call SetUseCodedPhy(true) unconditionally, next to the existing SetAllowExtendedAdvertisements(true). The assumption was that on adapters without Coded PHY the call would fail and be ignored, like the extended-advertisements flag is.

Fix

Adapter::new asks the BluetoothAdapter it already holds whether IsLowEnergyCodedPhySupported, and passes the answer into BLEWatcher::new. start() requests Coded PHY only when it is true, and logs one debug! line saying which path was taken, so future scan reports on Windows show whether Coded PHY was in play.

Adapters without Coded PHY get the 0.12.0 behavior back. Adapters with it keep the long-range reception #463 added.

Validation

On an Intel adapter that reports IsLowEnergyCodedPhySupported == true (the enabled path), with this branch versus master:

  • An unfiltered start_scan yields the same mix of events on both (several hundred over 25 s: discoveries, updates, manufacturer data, RSSI, service data).
  • BLE 5 extended advertisements sent on the Coded PHY (from an nRF52 peripheral, 69-byte manufacturer-data frames) are received on both.

So the gate is transparent where the capability exists. I do not have an adapter without Coded PHY, so the disabled path is validated by reasoning from the report rather than measured here: with the call skipped, the watcher configuration is byte-for-byte what 0.12.0 set, and start_scan succeeding in the reporter's own program shows nothing else in the start path was affected.

Follow-ups (not in this PR)

  • Windows: SetAllowExtendedAdvertisements(true) makes some peripherals invisible to scan entirely #472 asks for a way to opt out of AllowExtendedAdvertisements / UseCodedPhy from the public API, because an adapter that does support extended scanning can still drop a specific peripheral while it is enabled. That needs a scan-options design across backends; this PR only removes the unconditional Coded PHY request.
  • The same capability-gating pattern could replace the ignored-error handling of SetAllowExtendedAdvertisements (via IsExtendedAdvertisingSupported), left out to keep this a minimal regression fix.

…rts it

SetUseCodedPhy(true) is accepted, and Start succeeds, on adapters without
Coded PHY support (e.g. Bluetooth 4.x dongles), but the scan then never
delivers a single advertisement. Gate the call on
BluetoothAdapter.IsLowEnergyCodedPhySupported so those adapters scan as in
0.12, and log which path was taken. Fixes deviceplug#473.
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.

watcher.SetUseCodedPhy(true) breaks scanning on Windows

1 participant