fix: parse multiple 16-bit and 32-bit Service UUIDs in BLE advertisement data#155
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #155 +/- ##
===========================================
+ Coverage 99.59% 100.00% +0.40%
===========================================
Files 6 6
Lines 245 255 +10
Branches 32 38 +6
===========================================
+ Hits 244 255 +11
+ Partials 1 0 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #155 will not alter performanceComparing Summary
|
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 esphome/issues#7182
Fix parsing of multiple Service UUIDs in BLE advertisement data
Summary
This PR fixes a bug in the BLE GAP advertisement parser where only the first UUID was being parsed when multiple 16-bit or 32-bit Service UUIDs were present in a single advertisement data structure. The parser now correctly iterates through all UUIDs in the data.
Changes
Parser fixes (src/bluetooth_data_tools/gap.py)
Test updates (tests/test_gap.py)
test_parse_adv_datato expect two separate 16-bit UUIDs instead of one combined UUIDtest_parse_multiple_16bit_uuids- Tests parsing of 3 16-bit UUIDstest_parse_multiple_32bit_uuids- Tests parsing of 2 32-bit UUIDstest_parse_mixed_16bit_32bit_uuids- Tests parsing mixed 16-bit and 32-bit UUIDs in one advertisementtest_parse_mixed_16bit_128bit_uuids- Tests parsing mixed 16-bit and 128-bit UUIDs in one advertisementTechnical details
The BLE advertisement data format allows multiple UUIDs to be packed in a single record:
The previous implementation incorrectly treated the entire data block as a single UUID, leading to malformed UUID strings.
Testing
All tests pass: