From 71d416487db8a912c03d40c8f98b8f2e332a2b00 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Thu, 29 Aug 2024 20:28:38 +0200 Subject: [PATCH] Update ECOINFO cluster to reflect latest spec text (#35285) --------- Co-authored-by: Restyled.io --- .../ecosystem-information-server.cpp | 5 --- .../chip/ecosystem-information-cluster.xml | 4 +- src/python_testing/TC_ECOINFO_2_1.py | 39 ++++++++++++++----- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp index 4af2adcb533ca3..4880c1058dc7f9 100644 --- a/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp +++ b/src/app/clusters/ecosystem-information-server/ecosystem-information-server.cpp @@ -34,9 +34,6 @@ constexpr size_t kUniqueLocationIdMaxSize = 64; constexpr size_t kUniqueLocationIdsListMaxSize = 64; constexpr size_t kLocationDescriptorNameMaxSize = 128; -constexpr size_t kDeviceDirectoryMaxSize = 256; -constexpr size_t kLocationDirectoryMaxSize = 64; - class AttrAccess : public AttributeAccessInterface { public: @@ -264,7 +261,6 @@ CHIP_ERROR EcosystemInformationServer::AddDeviceInfo(EndpointId aEndpoint, std:: VerifyOrReturnError((aEndpoint != kRootEndpointId && aEndpoint != kInvalidEndpointId), CHIP_ERROR_INVALID_ARGUMENT); auto & deviceInfo = mDevicesMap[aEndpoint]; - VerifyOrReturnError((deviceInfo.mDeviceDirectory.size() < kDeviceDirectoryMaxSize), CHIP_ERROR_NO_MEMORY); deviceInfo.mDeviceDirectory.push_back(std::move(aDevice)); return CHIP_NO_ERROR; } @@ -282,7 +278,6 @@ CHIP_ERROR EcosystemInformationServer::AddLocationInfo(EndpointId aEndpoint, con EcosystemLocationKey key = { .mUniqueLocationId = aLocationId, .mFabricIndex = aFabricIndex }; VerifyOrReturnError((deviceInfo.mLocationDirectory.find(key) == deviceInfo.mLocationDirectory.end()), CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError((deviceInfo.mLocationDirectory.size() < kLocationDirectoryMaxSize), CHIP_ERROR_NO_MEMORY); deviceInfo.mLocationDirectory[key] = std::move(aLocation); return CHIP_NO_ERROR; } diff --git a/src/app/zap-templates/zcl/data-model/chip/ecosystem-information-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/ecosystem-information-cluster.xml index 7abf54ccb7942a..cf84a7e229aed6 100644 --- a/src/app/zap-templates/zcl/data-model/chip/ecosystem-information-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/ecosystem-information-cluster.xml @@ -44,11 +44,11 @@ limitations under the License. true - + DeviceDirectory - + LocationDirectory diff --git a/src/python_testing/TC_ECOINFO_2_1.py b/src/python_testing/TC_ECOINFO_2_1.py index 5b952647ab4113..202d1073779cb3 100644 --- a/src/python_testing/TC_ECOINFO_2_1.py +++ b/src/python_testing/TC_ECOINFO_2_1.py @@ -25,11 +25,21 @@ class TC_ECOINFO_2_1(MatterBaseTest): - def _validate_device_directory(self, device_directory): - num_of_devices = len(device_directory) - asserts.assert_less_equal(num_of_devices, 256, "Too many device entries") + def _validate_device_directory(self, current_fabric_index, device_directory): for device in device_directory: - # TODO do fabric index check first + if current_fabric_index != device.fabricIndex: + # Fabric sensitve field still exist in python, just that they have default values + asserts.assert_equal(device.deviceName, None, "Unexpected value in deviceName") + asserts.assert_equal(device.deviceNameLastEdit, None, "Unexpected value in deviceNameLastEdit") + asserts.assert_equal(device.bridgedEndpoint, 0, "Unexpected value in bridgedEndpoint") + asserts.assert_equal(device.originalEndpoint, 0, "Unexpected value in originalEndpoint") + asserts.assert_true(type_matches(device.deviceTypes, list), "DeviceTypes should be a list") + asserts.assert_equal(len(device.deviceTypes), 0, "DeviceTypes list should be empty") + asserts.assert_true(type_matches(device.uniqueLocationIDs, list), "UniqueLocationIds should be a list") + asserts.assert_equal(len(device.uniqueLocationIDs), 0, "uniqueLocationIDs list should be empty") + asserts.assert_equal(device.uniqueLocationIDsLastEdit, 0, "Unexpected value in uniqueLocationIDsLastEdit") + continue + if device.deviceName is not None: asserts.assert_true(type_matches(device.deviceName, str), "DeviceName should be a string") asserts.assert_less_equal(len(device.deviceName), 64, "DeviceName should be <= 64") @@ -72,10 +82,20 @@ def _validate_device_directory(self, device_directory): if num_of_unique_location_ids: asserts.assert_greater(device.uniqueLocationIDsLastEdit, 0, "UniqueLocationIdsLastEdit must be non-zero") - def _validate_location_directory(self, location_directory): - num_of_locations = len(location_directory) - asserts.assert_less_equal(num_of_locations, 64, "Too many location entries") + def _validate_location_directory(self, current_fabric_index, location_directory): for location in location_directory: + if current_fabric_index != location.fabricIndex: + # Fabric sensitve field still exist in python, just that they have default values + asserts.assert_equal(location.uniqueLocationID, "", "Unexpected value in uniqueLocationID") + asserts.assert_equal(location.locationDescriptor.locationName, "", + "Unexpected value in locationDescriptor.locationName") + asserts.assert_equal(location.locationDescriptor.floorNumber, NullValue, + "Unexpected value in locationDescriptor.floorNumber") + asserts.assert_equal(location.locationDescriptor.areaType, NullValue, + "Unexpected value in locationDescriptor.areaType") + asserts.assert_equal(location.locationDescriptorLastEdit, 0, "Unexpected value in locationDescriptorLastEdit") + continue + asserts.assert_true(type_matches(location.uniqueLocationID, str), "UniqueLocationId should be a string") location_id_string_length = len(location.uniqueLocationID) asserts.assert_greater_equal(location_id_string_length, 1, @@ -120,6 +140,7 @@ async def test_TC_ECOINFO_2_1(self): self.wait_for_user_input( "Paused test to allow for manufacturer to satisfy precondition where one or more bridged devices of a supported type is connected to DUT") + current_fabric_index = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.CurrentFabricIndex) self.step(1) endpoint_wild_card_read = await dev_ctrl.ReadAttribute(dut_node_id, [(Clusters.EcosystemInformation.Attributes.ClusterRevision)]) list_of_endpoints = list(endpoint_wild_card_read.keys()) @@ -134,7 +155,7 @@ async def test_TC_ECOINFO_2_1(self): attribute=Clusters.EcosystemInformation.Attributes.DeviceDirectory, fabricFiltered=False) - self._validate_device_directory(device_directory) + self._validate_device_directory(current_fabric_index, device_directory) if idx == 0: self.step(3) @@ -145,7 +166,7 @@ async def test_TC_ECOINFO_2_1(self): attribute=Clusters.EcosystemInformation.Attributes.LocationDirectory, fabricFiltered=False) - self._validate_location_directory(location_directory) + self._validate_location_directory(current_fabric_index, location_directory) if idx == 0: self.step(4)