fix(corebluetooth): send descriptor discovery event even on error#456
Open
mikatammi wants to merge 1 commit intodeviceplug:devfrom
Open
fix(corebluetooth): send descriptor discovery event even on error#456mikatammi wants to merge 1 commit intodeviceplug:devfrom
mikatammi wants to merge 1 commit intodeviceplug:devfrom
Conversation
On macOS, `peripheral:didDiscoverDescriptorsForCharacteristic:error:` only sent the `DiscoveredCharacteristicDescriptors` event when error was nil. If CoreBluetooth reported an error for any characteristic's descriptors (e.g. "The specified UUID is not allowed for this operation"), the event was never emitted and `discover_services()` would hang indefinitely. This moves the event send outside the error check so it always fires — with an empty descriptor map on error — allowing service discovery to complete. A warning is now logged when descriptor discovery fails. This matches the Windows behaviour where `BLEDevice::get_characteristic_descriptors` uses `unwrap_or` to return an empty list on error (PR deviceplug#362). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Mika Tammi <mikatammi@gmail.com>
Author
|
The clippy issues probably were already there before my PR? Should we fix them first? |
Contributor
|
Yup, I need to do a ton of clippy cleanup and hadn't been paying attention to actions, your PR is fine. I'll try to review soon. |
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.
On macOS,
peripheral:didDiscoverDescriptorsForCharacteristic:error:only sent theDiscoveredCharacteristicDescriptorsevent whenerrorwas nil. If CoreBluetooth reportedan error for any characteristic's descriptors (e.g. "The specified UUID is not allowed for
this operation"), the event was never emitted and
discover_services()would hangindefinitely waiting for all characteristics to be marked as discovered.
This is the macOS/CoreBluetooth equivalent of the Windows fix in #362 — descriptor discovery
errors should not block service discovery from completing.
The fix moves the event send and UUID extraction outside the
if error.is_none()block, soDiscoveredCharacteristicDescriptorsalways fires. On error, an empty descriptor map issent and a warning is logged, which unblocks the discovery future.
Tested with a Shelly Plug SG3 device whose FFF6 service characteristic triggers "The
specified UUID is not allowed for this operation" during descriptor discovery.