From a0d3555e5cc778aa581e958af000e670fec4345f Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 25 Oct 2023 09:21:08 -0400 Subject: [PATCH] Change Media::ApplicationBasic cluster to match spec (#29959) * Application basic: increase length of application name and mark vendor list as access administer * Zap regen * Switch to long char string, to support 256 characters --------- Co-authored-by: Andrei Litvin --- .../all-clusters-minimal-app.matter | 4 ++-- .../placeholder/linux/apps/app1/config.matter | 8 +++---- .../placeholder/linux/apps/app2/config.matter | 8 +++---- examples/tv-app/tv-common/tv-app.matter | 4 ++-- .../tv-casting-common/tv-casting-app.matter | 4 ++-- .../all-clusters-app/app-templates/access.h | 3 +++ .../app-templates/endpoint_config.h | 18 +++++++------- .../chip/application-basic-cluster.xml | 7 ++++-- .../data_model/controller-clusters.matter | 4 ++-- .../zap-generated/attributes/Accessors.cpp | 24 +++++++++---------- .../zap-generated/attributes/Accessors.h | 2 +- .../zap-generated/cluster-objects.h | 2 +- .../zap-generated/test/Commands.h | 2 +- 13 files changed, 48 insertions(+), 42 deletions(-) diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index d7bc635c8db295..ba7a202c7392e1 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -3621,11 +3621,11 @@ server cluster ApplicationBasic = 1293 { char_string applicationID = 1; } - readonly attribute char_string<32> applicationName = 2; + readonly attribute long_char_string<256> applicationName = 2; readonly attribute ApplicationStruct application = 4; readonly attribute ApplicationStatusEnum status = 5; readonly attribute char_string<32> applicationVersion = 6; - readonly attribute vendor_id allowedVendorList[] = 7; + readonly attribute access(read: administer) vendor_id allowedVendorList[] = 7; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/placeholder/linux/apps/app1/config.matter b/examples/placeholder/linux/apps/app1/config.matter index 4d4815ab53590f..bd3e6875f6d605 100644 --- a/examples/placeholder/linux/apps/app1/config.matter +++ b/examples/placeholder/linux/apps/app1/config.matter @@ -6399,12 +6399,12 @@ client cluster ApplicationBasic = 1293 { readonly attribute optional char_string<32> vendorName = 0; readonly attribute optional vendor_id vendorID = 1; - readonly attribute char_string<32> applicationName = 2; + readonly attribute long_char_string<256> applicationName = 2; readonly attribute optional int16u productID = 3; readonly attribute ApplicationStruct application = 4; readonly attribute ApplicationStatusEnum status = 5; readonly attribute char_string<32> applicationVersion = 6; - readonly attribute vendor_id allowedVendorList[] = 7; + readonly attribute access(read: administer) vendor_id allowedVendorList[] = 7; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -6429,12 +6429,12 @@ server cluster ApplicationBasic = 1293 { readonly attribute char_string<32> vendorName = 0; readonly attribute vendor_id vendorID = 1; - readonly attribute char_string<32> applicationName = 2; + readonly attribute long_char_string<256> applicationName = 2; readonly attribute int16u productID = 3; readonly attribute ApplicationStruct application = 4; readonly attribute ApplicationStatusEnum status = 5; readonly attribute char_string<32> applicationVersion = 6; - readonly attribute vendor_id allowedVendorList[] = 7; + readonly attribute access(read: administer) vendor_id allowedVendorList[] = 7; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/placeholder/linux/apps/app2/config.matter b/examples/placeholder/linux/apps/app2/config.matter index a77ad1f6b06005..541decce5be349 100644 --- a/examples/placeholder/linux/apps/app2/config.matter +++ b/examples/placeholder/linux/apps/app2/config.matter @@ -6358,12 +6358,12 @@ client cluster ApplicationBasic = 1293 { readonly attribute optional char_string<32> vendorName = 0; readonly attribute optional vendor_id vendorID = 1; - readonly attribute char_string<32> applicationName = 2; + readonly attribute long_char_string<256> applicationName = 2; readonly attribute optional int16u productID = 3; readonly attribute ApplicationStruct application = 4; readonly attribute ApplicationStatusEnum status = 5; readonly attribute char_string<32> applicationVersion = 6; - readonly attribute vendor_id allowedVendorList[] = 7; + readonly attribute access(read: administer) vendor_id allowedVendorList[] = 7; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -6388,12 +6388,12 @@ server cluster ApplicationBasic = 1293 { readonly attribute char_string<32> vendorName = 0; readonly attribute vendor_id vendorID = 1; - readonly attribute char_string<32> applicationName = 2; + readonly attribute long_char_string<256> applicationName = 2; readonly attribute int16u productID = 3; readonly attribute ApplicationStruct application = 4; readonly attribute ApplicationStatusEnum status = 5; readonly attribute char_string<32> applicationVersion = 6; - readonly attribute vendor_id allowedVendorList[] = 7; + readonly attribute access(read: administer) vendor_id allowedVendorList[] = 7; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/tv-app/tv-common/tv-app.matter b/examples/tv-app/tv-common/tv-app.matter index be40eb501eb50b..d8ddbe693e42df 100644 --- a/examples/tv-app/tv-common/tv-app.matter +++ b/examples/tv-app/tv-common/tv-app.matter @@ -2402,12 +2402,12 @@ server cluster ApplicationBasic = 1293 { readonly attribute char_string<32> vendorName = 0; readonly attribute vendor_id vendorID = 1; - readonly attribute char_string<32> applicationName = 2; + readonly attribute long_char_string<256> applicationName = 2; readonly attribute int16u productID = 3; readonly attribute ApplicationStruct application = 4; readonly attribute ApplicationStatusEnum status = 5; readonly attribute char_string<32> applicationVersion = 6; - readonly attribute vendor_id allowedVendorList[] = 7; + readonly attribute access(read: administer) vendor_id allowedVendorList[] = 7; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter index 035ae6d9cea09f..ae20bcb56f0403 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter @@ -1949,12 +1949,12 @@ client cluster ApplicationBasic = 1293 { readonly attribute optional char_string<32> vendorName = 0; readonly attribute optional vendor_id vendorID = 1; - readonly attribute char_string<32> applicationName = 2; + readonly attribute long_char_string<256> applicationName = 2; readonly attribute optional int16u productID = 3; readonly attribute ApplicationStruct application = 4; readonly attribute ApplicationStatusEnum status = 5; readonly attribute char_string<32> applicationVersion = 6; - readonly attribute vendor_id allowedVendorList[] = 7; + readonly attribute access(read: administer) vendor_id allowedVendorList[] = 7; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/access.h b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/access.h index 12187528ab8ee1..119829602ee10d 100644 --- a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/access.h +++ b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/access.h @@ -88,6 +88,7 @@ /* Cluster: Color Control, Attribute: ColorPointBY, Privilege: view */ \ /* Cluster: Color Control, Attribute: ColorPointBIntensity, Privilege: view */ \ /* Cluster: Color Control, Attribute: StartUpColorTemperatureMireds, Privilege: view */ \ + 0x0000050D, /* Cluster: Application Basic, Attribute: AllowedVendorList, Privilege: administer */ \ } // Parallel array data (cluster, *attribute*, privilege) for read attribute @@ -151,6 +152,7 @@ /* Cluster: Color Control, Attribute: ColorPointBY, Privilege: view */ \ /* Cluster: Color Control, Attribute: ColorPointBIntensity, Privilege: view */ \ /* Cluster: Color Control, Attribute: StartUpColorTemperatureMireds, Privilege: view */ \ + 0x00000007, /* Cluster: Application Basic, Attribute: AllowedVendorList, Privilege: administer */ \ } // Parallel array data (cluster, attribute, *privilege*) for read attribute @@ -214,6 +216,7 @@ /* Cluster: Color Control, Attribute: ColorPointBY, Privilege: view */ \ /* Cluster: Color Control, Attribute: ColorPointBIntensity, Privilege: view */ \ /* Cluster: Color Control, Attribute: StartUpColorTemperatureMireds, Privilege: view */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Application Basic, Attribute: AllowedVendorList, Privilege: administer */ \ } //////////////////////////////////////////////////////////////////////////////// diff --git a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h index 63d25b1d313ed5..2fe82da68e5572 100644 --- a/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h +++ b/scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/endpoint_config.h @@ -1239,12 +1239,12 @@ { ZAP_SIMPLE_DEFAULT(1), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \ \ /* Endpoint: 1, Cluster: Application Basic (server) */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000000, 33, ZAP_TYPE(CHAR_STRING), 0 }, /* VendorName */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000001, 2, ZAP_TYPE(VENDOR_ID), 0 }, /* VendorID */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000002, 33, ZAP_TYPE(CHAR_STRING), 0 }, /* ApplicationName */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000003, 2, ZAP_TYPE(INT16U), 0 }, /* ProductID */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000005, 1, ZAP_TYPE(ENUM8), 0 }, /* Status */ \ - { ZAP_EMPTY_DEFAULT(), 0x00000006, 33, ZAP_TYPE(CHAR_STRING), 0 }, /* ApplicationVersion */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000000, 33, ZAP_TYPE(CHAR_STRING), 0 }, /* VendorName */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000001, 2, ZAP_TYPE(VENDOR_ID), 0 }, /* VendorID */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000002, 258, ZAP_TYPE(LONG_CHAR_STRING), 0 }, /* ApplicationName */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000003, 2, ZAP_TYPE(INT16U), 0 }, /* ProductID */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000005, 1, ZAP_TYPE(ENUM8), 0 }, /* Status */ \ + { ZAP_EMPTY_DEFAULT(), 0x00000006, 33, ZAP_TYPE(CHAR_STRING), 0 }, /* ApplicationVersion */ \ { ZAP_EMPTY_DEFAULT(), 0x00000007, 0, ZAP_TYPE(ARRAY), ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) }, /* AllowedVendorList */ \ { ZAP_SIMPLE_DEFAULT(0), 0x0000FFFC, 4, ZAP_TYPE(BITMAP32), 0 }, /* FeatureMap */ \ { ZAP_SIMPLE_DEFAULT(1), 0x0000FFFD, 2, ZAP_TYPE(INT16U), 0 }, /* ClusterRevision */ \ @@ -2851,7 +2851,7 @@ .clusterId = 0x0000050D, \ .attributes = ZAP_ATTRIBUTE_INDEX(573), \ .attributeCount = 9, \ - .clusterSize = 110, \ + .clusterSize = 335, \ .mask = ZAP_CLUSTER_MASK(SERVER), \ .functions = NULL, \ .acceptedCommandList = nullptr, \ @@ -3024,7 +3024,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 27, 345 }, { ZAP_CLUSTER_INDEX(27), 44, 3492 }, { ZAP_CLUSTER_INDEX(71), 7, 127 }, \ + { ZAP_CLUSTER_INDEX(0), 27, 345 }, { ZAP_CLUSTER_INDEX(27), 44, 3717 }, { ZAP_CLUSTER_INDEX(71), 7, 127 }, \ { ZAP_CLUSTER_INDEX(78), 2, 4 }, \ } @@ -3037,7 +3037,7 @@ static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, #define ATTRIBUTE_SINGLETONS_SIZE (37) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (3968) +#define ATTRIBUTE_MAX_SIZE (4193) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (4) diff --git a/src/app/zap-templates/zcl/data-model/chip/application-basic-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/application-basic-cluster.xml index c9e90052dc649d..a3c54b8c1d8c53 100644 --- a/src/app/zap-templates/zcl/data-model/chip/application-basic-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/application-basic-cluster.xml @@ -26,12 +26,15 @@ limitations under the License. This cluster provides information about an application running on a TV or media player device which is represented as an endpoint. VendorName VendorID - ApplicationName + ApplicationName ProductID Application Status ApplicationVersion - AllowedVendorList + + AllowedVendorList + + diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 375927d3defd0a..c9cccf0f94db2c 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -6375,12 +6375,12 @@ client cluster ApplicationBasic = 1293 { readonly attribute optional char_string<32> vendorName = 0; readonly attribute optional vendor_id vendorID = 1; - readonly attribute char_string<32> applicationName = 2; + readonly attribute long_char_string<256> applicationName = 2; readonly attribute optional int16u productID = 3; readonly attribute ApplicationStruct application = 4; readonly attribute ApplicationStatusEnum status = 5; readonly attribute char_string<32> applicationVersion = 6; - readonly attribute vendor_id allowedVendorList[] = 7; + readonly attribute access(read: administer) vendor_id allowedVendorList[] = 7; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index a6d4db3c67ae22..de97d22f4d964e 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -20823,29 +20823,29 @@ namespace ApplicationName { EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan & value) { - uint8_t zclString[32 + 1]; + uint8_t zclString[256 + 2]; EmberAfStatus status = emberAfReadAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, zclString, sizeof(zclString)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + size_t length = emberAfLongStringLength(zclString); + if (length == NumericAttributeTraits::kNullValue) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - VerifyOrReturnError(value.size() == 32, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 32); + VerifyOrReturnError(value.size() == 256, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); + memcpy(value.data(), &zclString[2], 256); value.reduce_size(length); return status; } EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value) { - static_assert(32 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 32, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[32 + 1]; - auto length = static_cast(value.size()); - Encoding::Put8(zclString, length); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, zclString, ZCL_CHAR_STRING_ATTRIBUTE_TYPE); + static_assert(256 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); + VerifyOrReturnError(value.size() <= 256, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + uint8_t zclString[256 + 2]; + auto length = static_cast(value.size()); + Encoding::LittleEndian::Put16(zclString, length); + memcpy(&zclString[2], value.data(), value.size()); + return emberAfWriteAttribute(endpoint, Clusters::ApplicationBasic::Id, Id, zclString, ZCL_LONG_CHAR_STRING_ATTRIBUTE_TYPE); } } // namespace ApplicationName diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index 3a9493da84cfcc..4486856ee4a374 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -3729,7 +3729,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, chip::VendorId value); } // namespace VendorID namespace ApplicationName { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan & value); // char_string +EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableCharSpan & value); // long_char_string EmberAfStatus Set(chip::EndpointId endpoint, chip::CharSpan value); } // namespace ApplicationName diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index e6ee9799d18ea7..62e1ea48e51715 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -30336,7 +30336,7 @@ struct TypeInfo static constexpr ClusterId GetClusterId() { return Clusters::ApplicationBasic::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::ApplicationName::Id; } static constexpr bool MustUseTimedWrite() { return false; } - static constexpr size_t MaxLength() { return 32; } + static constexpr size_t MaxLength() { return 256; } }; } // namespace ApplicationName namespace ProductID { diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index 99f21c7cbcafb7..19518f0203335d 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -75138,7 +75138,7 @@ class Test_TC_APBSC_9_1 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - VerifyOrReturn(CheckConstraintType("applicationName", "char_string", "char_string")); + VerifyOrReturn(CheckConstraintType("applicationName", "long_char_string", "char_string")); VerifyOrReturn(CheckConstraintMaxLength("applicationName", value, 256)); NextTest(); }];