Repository navigation
Conversation
…stics Some peripherals' services refuse GetCharacteristicsWithCacheModeAsync with GattCommunicationStatus::AccessDenied until the service has been opened, so discover_services() returned the service with no characteristics. Open each service with GattSharingMode::SharedReadAndWrite first. If opening fails, discovery is tried as before.
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.
Problem
On Windows,
discover_services()returns a custom service with no characteristics on some peripherals.GetCharacteristicsWithCacheModeAsyncreturnsGattCommunicationStatus::AccessDeniedfor the service, which is only logged at debug level, so the service just looks empty. The standard GAP and GATT services on the same device are fine.Changes
get_characteristicsnow opens each service withOpenAsync(GattSharingMode::SharedReadAndWrite)before discovering its characteristics. Shared mode doesn't stop other apps using the service. If opening fails, discovery is tried as before, so behavior is unchanged for devices that didn't need it.Validation
I hit this with ESP32-S3 peripherals running NimBLE (a 128-bit service with a write characteristic and a notify/indicate one), on Windows 11 (build 26200) with an Intel adapter. With 0.11.8 and 0.13.5 the service had no characteristics on every connection (0 of 6). With this change, characteristic discovery worked on every connection, about 20 at first, and many more since across two devices, including writes, notifications and transfers of over 1 MB. Calling
RequestAccessAsyncfirst didn't help (0 of 2). Thebluestcrate gets the sameAccessDeniedon these devices, so it seems to be WinRT requiring the open for some services rather than anything specific to btleplug.cargo test --libpasses on Windows.