Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- `BacnetReadAccessSpecification` equality and `hashCode` compared only the
number of properties, so two specifications for the same object that
requested different properties compared equal and collided in a `Set` or
`Map`. They now compare the property list by content.

### Changed

- The internal `mapConcurrent` fan-out helper is no longer exported from the
public API; it was unintentionally re-exported through `device_scanner.dart`.

## [0.9.0] - 2026-10-12

### Added
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,8 @@ client.covEvents.listen((event) {
```

Devices without the service reject it (`BacnetRejectException`); use
`subscribeCOV` for them. bacnet-stack, and so the server of this package,
does not implement it.
`subscribeCOV` for them. The server of this package implements
SubscribeCOVPropertyMultiple as a target (since 0.9.0).

## Device descriptions and the command line tool

Expand Down
3 changes: 2 additions & 1 deletion lib/bacnet_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export 'src/server/server_state.dart';
export 'src/utilities/alarm_subscription.dart';
export 'src/utilities/device_backup.dart';
export 'src/utilities/device_description.dart';
export 'src/utilities/device_scanner.dart';
// mapConcurrent is an internal fan-out helper, not part of the public API.
export 'src/utilities/device_scanner.dart' hide mapConcurrent;
export 'src/utilities/file_transfer.dart';
export 'src/utilities/network_discovery.dart';
export 'src/utilities/property_monitor.dart';
14 changes: 10 additions & 4 deletions lib/src/models/rpm_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,19 @@ class BacnetReadAccessSpecification {
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is BacnetReadAccessSpecification &&
other.objectIdentifier == objectIdentifier &&
other.properties.length == properties.length;
if (other is! BacnetReadAccessSpecification ||
other.objectIdentifier != objectIdentifier ||
other.properties.length != properties.length) {
return false;
}
for (var i = 0; i < properties.length; i++) {
if (other.properties[i] != properties[i]) return false;
}
return true;
}

@override
int get hashCode => Object.hash(objectIdentifier, properties.length);
int get hashCode => Object.hash(objectIdentifier, Object.hashAll(properties));

@override
String toString() => '$objectIdentifier: $properties';
Expand Down
35 changes: 35 additions & 0 deletions test/models/rpm_models_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,41 @@ void main() {
expect(spec1, isNot(equals(spec3)));
});

test('equality compares property contents, not just count', () {
const obj = BacnetObject(type: BacnetObjectType.analogInput, instance: 1);
const presentValue = BacnetReadAccessSpecification(
objectIdentifier: obj,
properties: [
BacnetPropertyReference(
propertyIdentifier: BacnetPropertyId.presentValue,
),
],
);
const samePresentValue = BacnetReadAccessSpecification(
objectIdentifier: obj,
properties: [
BacnetPropertyReference(
propertyIdentifier: BacnetPropertyId.presentValue,
),
],
);
// same object and same property count, but a different property
const statusFlags = BacnetReadAccessSpecification(
objectIdentifier: obj,
properties: [
BacnetPropertyReference(
propertyIdentifier: BacnetPropertyId.statusFlags,
),
],
);

expect(presentValue, equals(samePresentValue));
expect(presentValue.hashCode, equals(samePresentValue.hashCode));
expect(presentValue, isNot(equals(statusFlags)));
// distinct specs must not collapse in a hash set
expect({presentValue, statusFlags}, hasLength(2));
});

group('JSON serialization', () {
test('toJson serializes nested objects', () {
const obj = BacnetObject(
Expand Down
Loading