Skip to content

fix: compare BleCharacteristic values consistently - #275

Closed
xianjianlf2 wants to merge 4 commits into
Navideck:mainfrom
xianjianlf2:fix/ble-characteristic-equality-list
Closed

fix: compare BleCharacteristic values consistently#275
xianjianlf2 wants to merge 4 commits into
Navideck:mainfrom
xianjianlf2:fix/ble-characteristic-equality-list

Conversation

@xianjianlf2

Copy link
Copy Markdown
Contributor

Summary

Compare BleCharacteristic values by their service UUID, characteristic UUID, and device ID instead of relying on list identity. This makes equality and hashCode stable for equivalent characteristics built from separate list instances.

Validation

  • Not run locally: this environment does not have dart or flutter installed. The branch includes test/ble_characteristic_equality_test.dart for CI coverage.

xianjianlf2 and others added 3 commits July 15, 2026 20:47
BleCharacteristic.operator== compared the `properties` list with `!=`,
which is List identity comparison, and hashCode used `properties.hashCode`
(also identity based). As a result two characteristics with equal content
but distinct list instances were never equal and produced different hash
codes, breaking the equality contract and Set/Map lookups.

Use `listEquals` for comparison and `Object.hashAll` for hashing, matching
the pattern already used in ManufacturerData.
Co-authored-by: Cursor <cursoragent@cursor.com>
@xianjianlf2
xianjianlf2 marked this pull request as ready for review August 1, 2026 07:44
@xianjianlf2

Copy link
Copy Markdown
Contributor Author

已核对当前 main:rebase 后该分支与 upstream/main 完全一致,没有剩余 diff。BleCharacteristic 的值比较修复已由主线提交 975f37b(PR #267)包含,相关 equality 测试也已在主线。当前 PR 是重复变更,无需再推送代码,建议由维护者关闭本 PR。

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes BleCharacteristic value semantics so that characteristics built from equivalent data (but different list instances) compare equal and produce stable hashCodes, enabling correct use in Set/Map keys.

Changes:

  • Update BleCharacteristic.== to compare properties by list content rather than list identity.
  • Update BleCharacteristic.hashCode to hash properties by content.
  • Add a Flutter test covering equality/hashCode behavior and document the change in the changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/ble_characteristic_equality_test.dart Adds regression tests for value-based equality/hashCode and keying in Set/Map.
lib/src/models/ble_service.dart Implements list-content equality for properties and updates hashCode.
CHANGELOG.md Notes the BleCharacteristic equality/hashCode fix in 2.1.1.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/src/models/ble_service.dart
@fotiDim

fotiDim commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@xianjianlf2 this was addressed already in #267. Am I missing something?

@fotiDim fotiDim closed this Aug 11, 2026
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.

3 participants