From 5728f01b1517331a380cdd92bbd41825956f378d Mon Sep 17 00:00:00 2001 From: Karsten Sperling Date: Fri, 20 Dec 2024 17:19:11 +1300 Subject: [PATCH] Define per-cluster server and client targets in GN Have chip_data_model targets depend on these, instead of making up a source set on the fly. --- examples/network-manager-app/linux/main.cpp | 4 +- src/app/chip_data_model.gni | 86 ++++- src/app/clusters/bindings/BUILD.gn | 31 ++ src/app/clusters/descriptor/BUILD.gn | 26 ++ src/app/clusters/descriptor/descriptor.cpp | 2 +- .../thread-network-directory/BUILD.gn | 31 ++ .../DefaultThreadNetworkDirectoryStorage.cpp | 2 +- .../DefaultThreadNetworkDirectoryStorage.h | 2 +- .../ThreadNetworkDirectoryStorage.h | 0 .../thread-network-directory-server.cpp | 0 .../thread-network-directory-server.h | 4 +- .../clusters/wifi-network-management/BUILD.gn | 23 ++ .../wifi-network-management-server.cpp | 0 .../wifi-network-management-server.h | 0 src/app/tests/BUILD.gn | 15 +- ...stDefaultThreadNetworkDirectoryStorage.cpp | 2 +- src/app/util/BUILD.gn | 8 + src/app/util/attribute-storage.h | 332 +---------------- src/app/util/ember-api.h | 348 ++++++++++++++++++ src/app/zap_cluster_list.json | 4 +- src/app/zap_cluster_list.py | 10 +- 21 files changed, 553 insertions(+), 377 deletions(-) create mode 100644 src/app/clusters/bindings/BUILD.gn create mode 100644 src/app/clusters/descriptor/BUILD.gn create mode 100644 src/app/clusters/thread-network-directory/BUILD.gn rename src/app/clusters/{thread-network-directory-server => thread-network-directory}/DefaultThreadNetworkDirectoryStorage.cpp (98%) rename src/app/clusters/{thread-network-directory-server => thread-network-directory}/DefaultThreadNetworkDirectoryStorage.h (96%) rename src/app/clusters/{thread-network-directory-server => thread-network-directory}/ThreadNetworkDirectoryStorage.h (100%) rename src/app/clusters/{thread-network-directory-server => thread-network-directory}/thread-network-directory-server.cpp (100%) rename src/app/clusters/{thread-network-directory-server => thread-network-directory}/thread-network-directory-server.h (95%) create mode 100644 src/app/clusters/wifi-network-management/BUILD.gn rename src/app/clusters/{wifi-network-management-server => wifi-network-management}/wifi-network-management-server.cpp (100%) rename src/app/clusters/{wifi-network-management-server => wifi-network-management}/wifi-network-management-server.h (100%) create mode 100644 src/app/util/ember-api.h diff --git a/examples/network-manager-app/linux/main.cpp b/examples/network-manager-app/linux/main.cpp index 84c4a2ce88e9a5..2a72932d59b942 100644 --- a/examples/network-manager-app/linux/main.cpp +++ b/examples/network-manager-app/linux/main.cpp @@ -16,8 +16,8 @@ */ #include -#include -#include +#include +#include #include #include #include diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 02be8ebaccf05b..90ac5e3e2c5627 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -247,7 +247,12 @@ template("chip_data_model") { defines = [] } - foreach(cluster, _cluster_sources) { + foreach(cluster_target, _cluster_sources) { + # Work out the legacy ${cluster} directory name + cluster_target_parts = [] + cluster_target_parts = string_split(cluster_target, ":") + cluster = cluster_target_parts[0] + if (cluster == "door-lock-server") { sources += [ "${_app_root}/clusters/${cluster}/door-lock-server-callback.cpp", @@ -299,14 +304,6 @@ template("chip_data_model") { # TODO: DefaultOTARequestor depends on controller, however the cluster server itself does not. # Maybe DefaultOTARequestor and related code should have its own source set. deps += [ "${chip_root}/src/controller:interactions" ] - } else if (cluster == "bindings") { - sources += [ - "${_app_root}/clusters/${cluster}/${cluster}.cpp", - "${_app_root}/clusters/${cluster}/BindingManager.cpp", - "${_app_root}/clusters/${cluster}/BindingManager.h", - "${_app_root}/clusters/${cluster}/PendingNotificationMap.cpp", - "${_app_root}/clusters/${cluster}/PendingNotificationMap.h", - ] } else if (cluster == "time-synchronization-server") { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp", @@ -428,14 +425,6 @@ template("chip_data_model") { "${_app_root}/clusters/${cluster}/${cluster}.h", "${_app_root}/clusters/${cluster}/WaterHeaterManagementTestEventTriggerHandler.h", ] - } else if (cluster == "thread-network-directory-server") { - sources += [ - "${_app_root}/clusters/${cluster}/${cluster}.cpp", - "${_app_root}/clusters/${cluster}/${cluster}.h", - "${_app_root}/clusters/${cluster}/DefaultThreadNetworkDirectoryStorage.cpp", - "${_app_root}/clusters/${cluster}/DefaultThreadNetworkDirectoryStorage.h", - "${_app_root}/clusters/${cluster}/ThreadNetworkDirectoryStorage.h", - ] } else if (cluster == "thermostat-server") { sources += [ "${_app_root}/clusters/${cluster}/${cluster}-atomic.cpp", @@ -452,8 +441,68 @@ template("chip_data_model") { "${_app_root}/clusters/${cluster}/ArlEncoder.cpp", "${_app_root}/clusters/${cluster}/ArlEncoder.h", ] - } else { + } else if (cluster == "account-login-server" || + cluster == "administrator-commissioning-server" || + cluster == "application-basic-server" || + cluster == "audio-output-server" || + cluster == "basic-information" || + cluster == "bridged-device-basic-information-server" || + cluster == "channel-server" || cluster == "chime-server" || + cluster == "color-control-server" || + cluster == "commissioner-control-server" || + cluster == "content-app-observer" || + cluster == "content-control-server" || + cluster == "content-launch-server" || + cluster == "ecosystem-information-server" || + cluster == "electrical-power-measurement-server" || + cluster == "energy-preference-server" || + cluster == "ethernet-network-diagnostics-server" || + cluster == "fan-control-server" || + cluster == "fault-injection-server" || + cluster == "fixed-label-server" || + cluster == "general-commissioning-server" || + cluster == "general-diagnostics-server" || + cluster == "group-key-mgmt-server" || + cluster == "groups-server" || cluster == "identify-server" || + cluster == "keypad-input-server" || + cluster == "laundry-dryer-controls-server" || + cluster == "laundry-washer-controls-server" || + cluster == "level-control" || + cluster == "localization-configuration-server" || + cluster == "low-power-server" || + cluster == "media-input-server" || + cluster == "media-playback-server" || + cluster == "messages-server" || + cluster == "microwave-oven-control-server" || + cluster == "network-commissioning" || + cluster == "occupancy-sensor-server" || + cluster == "on-off-server" || + cluster == "operational-credentials-server" || + cluster == "ota-provider" || + cluster == "power-source-configuration-server" || + cluster == "power-source-server" || + cluster == "power-topology-server" || + cluster == "pump-configuration-and-control-server" || + cluster == "pump-configuration-and-control-client" || + cluster == "refrigerator-alarm-server" || + cluster == "sample-mei-server" || + cluster == "software-diagnostics-server" || + cluster == "switch-server" || + cluster == "target-navigator-server" || + cluster == "test-cluster-server" || + cluster == "thermostat-user-interface-configuration-server" || + cluster == "thermostat-client" || + cluster == "time-format-localization-server" || + cluster == "timer-server" || cluster == "user-label-server" || + cluster == "valve-configuration-and-control-server" || + cluster == "wake-on-lan-server" || + cluster == "wifi-network-diagnostics-server" || + cluster == "window-covering-server") { + # Fallback for clusters not yet migrated, do not add to this list sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ] + } else { + # New clusters should follow this pattern and provide a BUILD.gn with a "server" or "client" target as appropriate + public_deps += [ "${_app_root}/clusters/${cluster_target}" ] } } @@ -470,6 +519,7 @@ template("chip_data_model") { "${chip_root}/src/app/common:cluster-objects", "${chip_root}/src/app/common:enums", "${chip_root}/src/app/server", + "${chip_root}/src/app/util:binding-table-headers", "${chip_root}/src/app/util:types", "${chip_root}/src/app/util/persistence", "${chip_root}/src/lib/core", diff --git a/src/app/clusters/bindings/BUILD.gn b/src/app/clusters/bindings/BUILD.gn new file mode 100644 index 00000000000000..cd5e7d0f7aebe5 --- /dev/null +++ b/src/app/clusters/bindings/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +source_set("server") { + deps = [ + "${chip_root}/src/app", + "${chip_root}/src/app/server", + "${chip_root}/src/app/util:binding-table-headers", + ] + sources = [ + "BindingManager.cpp", + "BindingManager.h", + "PendingNotificationMap.cpp", + "PendingNotificationMap.h", + "bindings.cpp", + "bindings.h", + ] +} diff --git a/src/app/clusters/descriptor/BUILD.gn b/src/app/clusters/descriptor/BUILD.gn new file mode 100644 index 00000000000000..6a353ceb7ce5a3 --- /dev/null +++ b/src/app/clusters/descriptor/BUILD.gn @@ -0,0 +1,26 @@ +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +source_set("server") { + deps = [ + "${chip_root}/src/app", + "${chip_root}/src/app/util:ember-api-headers", + ] + sources = [ + "descriptor.cpp", + "descriptor.h", + ] +} diff --git a/src/app/clusters/descriptor/descriptor.cpp b/src/app/clusters/descriptor/descriptor.cpp index 7d8854bca1fb5f..d9e88ad3f85f4a 100644 --- a/src/app/clusters/descriptor/descriptor.cpp +++ b/src/app/clusters/descriptor/descriptor.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/app/clusters/thread-network-directory/BUILD.gn b/src/app/clusters/thread-network-directory/BUILD.gn new file mode 100644 index 00000000000000..4040310d81b595 --- /dev/null +++ b/src/app/clusters/thread-network-directory/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +source_set("server") { + deps = [ + "${chip_root}/src/app", + "${chip_root}/src/app/server", # Only DefaultThreadNetworkDirectoryServer + # depends on this, could split into a + # separate target + ] + sources = [ + "DefaultThreadNetworkDirectoryStorage.cpp", + "DefaultThreadNetworkDirectoryStorage.h", + "ThreadNetworkDirectoryStorage.h", + "thread-network-directory-server.cpp", + "thread-network-directory-server.h", + ] +} diff --git a/src/app/clusters/thread-network-directory-server/DefaultThreadNetworkDirectoryStorage.cpp b/src/app/clusters/thread-network-directory/DefaultThreadNetworkDirectoryStorage.cpp similarity index 98% rename from src/app/clusters/thread-network-directory-server/DefaultThreadNetworkDirectoryStorage.cpp rename to src/app/clusters/thread-network-directory/DefaultThreadNetworkDirectoryStorage.cpp index c272e0acdd7461..a67127950beaee 100644 --- a/src/app/clusters/thread-network-directory-server/DefaultThreadNetworkDirectoryStorage.cpp +++ b/src/app/clusters/thread-network-directory/DefaultThreadNetworkDirectoryStorage.cpp @@ -16,7 +16,7 @@ */ #include "DefaultThreadNetworkDirectoryStorage.h" -#include +#include #include #include diff --git a/src/app/clusters/thread-network-directory-server/DefaultThreadNetworkDirectoryStorage.h b/src/app/clusters/thread-network-directory/DefaultThreadNetworkDirectoryStorage.h similarity index 96% rename from src/app/clusters/thread-network-directory-server/DefaultThreadNetworkDirectoryStorage.h rename to src/app/clusters/thread-network-directory/DefaultThreadNetworkDirectoryStorage.h index 0cda5e3e188c7f..50b06b756120b5 100644 --- a/src/app/clusters/thread-network-directory-server/DefaultThreadNetworkDirectoryStorage.h +++ b/src/app/clusters/thread-network-directory/DefaultThreadNetworkDirectoryStorage.h @@ -17,7 +17,7 @@ #pragma once -#include +#include #include #include diff --git a/src/app/clusters/thread-network-directory-server/ThreadNetworkDirectoryStorage.h b/src/app/clusters/thread-network-directory/ThreadNetworkDirectoryStorage.h similarity index 100% rename from src/app/clusters/thread-network-directory-server/ThreadNetworkDirectoryStorage.h rename to src/app/clusters/thread-network-directory/ThreadNetworkDirectoryStorage.h diff --git a/src/app/clusters/thread-network-directory-server/thread-network-directory-server.cpp b/src/app/clusters/thread-network-directory/thread-network-directory-server.cpp similarity index 100% rename from src/app/clusters/thread-network-directory-server/thread-network-directory-server.cpp rename to src/app/clusters/thread-network-directory/thread-network-directory-server.cpp diff --git a/src/app/clusters/thread-network-directory-server/thread-network-directory-server.h b/src/app/clusters/thread-network-directory/thread-network-directory-server.h similarity index 95% rename from src/app/clusters/thread-network-directory-server/thread-network-directory-server.h rename to src/app/clusters/thread-network-directory/thread-network-directory-server.h index 2f671bdd6b4e09..cf72cb87cc83f4 100644 --- a/src/app/clusters/thread-network-directory-server/thread-network-directory-server.h +++ b/src/app/clusters/thread-network-directory/thread-network-directory-server.h @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/src/app/clusters/wifi-network-management/BUILD.gn b/src/app/clusters/wifi-network-management/BUILD.gn new file mode 100644 index 00000000000000..59c08ac917457b --- /dev/null +++ b/src/app/clusters/wifi-network-management/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +source_set("server") { + deps = [ "${chip_root}/src/app" ] + sources = [ + "wifi-network-management-server.cpp", + "wifi-network-management-server.h", + ] +} diff --git a/src/app/clusters/wifi-network-management-server/wifi-network-management-server.cpp b/src/app/clusters/wifi-network-management/wifi-network-management-server.cpp similarity index 100% rename from src/app/clusters/wifi-network-management-server/wifi-network-management-server.cpp rename to src/app/clusters/wifi-network-management/wifi-network-management-server.cpp diff --git a/src/app/clusters/wifi-network-management-server/wifi-network-management-server.h b/src/app/clusters/wifi-network-management/wifi-network-management-server.h similarity index 100% rename from src/app/clusters/wifi-network-management-server/wifi-network-management-server.h rename to src/app/clusters/wifi-network-management/wifi-network-management-server.h diff --git a/src/app/tests/BUILD.gn b/src/app/tests/BUILD.gn index 912c1e32a0ef5a..69c4c529436dbd 100644 --- a/src/app/tests/BUILD.gn +++ b/src/app/tests/BUILD.gn @@ -74,19 +74,6 @@ source_set("ota-requestor-test-srcs") { ] } -source_set("thread-network-directory-test-srcs") { - sources = [ - "${chip_root}/src/app/clusters/thread-network-directory-server/DefaultThreadNetworkDirectoryStorage.cpp", - "${chip_root}/src/app/clusters/thread-network-directory-server/DefaultThreadNetworkDirectoryStorage.h", - "${chip_root}/src/app/clusters/thread-network-directory-server/ThreadNetworkDirectoryStorage.h", - ] - - public_deps = [ - "${chip_root}/src/app/common:cluster-objects", - "${chip_root}/src/lib/core", - ] -} - source_set("time-sync-data-provider-test-srcs") { sources = [ "${chip_root}/src/app/clusters/time-synchronization-server/TimeSyncDataProvider.cpp" ] @@ -244,10 +231,10 @@ chip_test_suite("tests") { ":operational-state-test-srcs", ":ota-requestor-test-srcs", ":power-cluster-test-srcs", - ":thread-network-directory-test-srcs", ":time-sync-data-provider-test-srcs", "${chip_root}/src/app", "${chip_root}/src/app:attribute-persistence", + "${chip_root}/src/app/clusters/thread-network-directory:server", "${chip_root}/src/app/common:cluster-objects", "${chip_root}/src/app/data-model-provider/tests:encode-decode", "${chip_root}/src/app/icd/client:handler", diff --git a/src/app/tests/TestDefaultThreadNetworkDirectoryStorage.cpp b/src/app/tests/TestDefaultThreadNetworkDirectoryStorage.cpp index 761b78afad4ff9..2211e41ea4c902 100644 --- a/src/app/tests/TestDefaultThreadNetworkDirectoryStorage.cpp +++ b/src/app/tests/TestDefaultThreadNetworkDirectoryStorage.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include +#include #include #include #include diff --git a/src/app/util/BUILD.gn b/src/app/util/BUILD.gn index 29b3bc9563c487..e4b9097462a752 100644 --- a/src/app/util/BUILD.gn +++ b/src/app/util/BUILD.gn @@ -75,3 +75,11 @@ source_set("callbacks") { "${chip_root}/src/app:paths", ] } + +source_set("binding-table-headers") { + sources = [ "binding-table.h" ] +} + +source_set("ember-api-headers") { + sources = [ "ember-api.h" ] +} diff --git a/src/app/util/attribute-storage.h b/src/app/util/attribute-storage.h index 6930db7a965ea2..95224c88b9ac85 100644 --- a/src/app/util/attribute-storage.h +++ b/src/app/util/attribute-storage.h @@ -17,22 +17,16 @@ #pragma once -#include -#include -#include -#include -#include -#include +#include // used to be defined in this file, include for compatibility #include #include +#include // NOTE: direct include here even though app/util/config.h is the public header, // because MAX_ENDPOINT_COUNT needs FIXED_ENDPOINT_COUNT definitions. #include -static constexpr uint16_t kEmberInvalidEndpointIndex = 0xFFFF; - // If we have fixed number of endpoints, then max is the same. #ifdef FIXED_ENDPOINT_COUNT #define MAX_ENDPOINT_COUNT (FIXED_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT) @@ -70,325 +64,3 @@ static constexpr uint16_t kEmberInvalidEndpointIndex = 0xFFFF; { \ ZAP_EMPTY_DEFAULT(), attId, attSizeBytes, ZAP_TYPE(attType), attrMask | ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) \ } - -/** - * @brief locate attribute metadata - * - * Function returns pointer to the attribute metadata structure, - * or NULL if attribute was not found. - * - * @param endpoint Zigbee endpoint number. - * @param clusterId Cluster ID of the sought cluster. - * @param attributeId Attribute ID of the sought attribute. - * - * @return Returns pointer to the attribute metadata location. - */ -const EmberAfAttributeMetadata * emberAfLocateAttributeMetadata(chip::EndpointId endpoint, chip::ClusterId clusterId, - chip::AttributeId attributeId); - -/** - * @brief Returns true if endpoint contains the ZCL server with specified id. - * - * This function returns true if - * the endpoint contains server of a given cluster. - */ -bool emberAfContainsServer(chip::EndpointId endpoint, chip::ClusterId clusterId); - -/** - * @brief Returns true if endpoint of given index contains the ZCL server with specified id. - * - * This function returns true if - * the endpoint of given index contains server of a given cluster. - * If this function is used with a manufacturer specific clusterId - * then this will return the first cluster that it finds in the Cluster table. - * and will not return any other clusters that share that id. - */ -bool emberAfContainsServerFromIndex(uint16_t index, chip::ClusterId clusterId); - -/** - * @brief Returns true if endpoint contains the ZCL client with specified id. - * - * This function returns true if - * the endpoint contains client of a given cluster. - */ -bool emberAfContainsClient(chip::EndpointId endpoint, chip::ClusterId clusterId); - -/** - * @brief macro that returns size of attribute in bytes. - * - * @param metadata EmberAfAttributeMetadata* to consider. - */ -#define emberAfAttributeSize(metadata) ((metadata)->size) - -/** - * Returns the index of a given endpoint. Will return 0xFFFF if this is not a - * valid endpoint id or if the endpoint is disabled. - */ -uint16_t emberAfIndexFromEndpoint(chip::EndpointId endpoint); - -/** - * @brief Returns parent endpoint for a given endpoint index - */ -chip::EndpointId emberAfParentEndpointFromIndex(uint16_t index); - -/** - * @brief Returns the index of the given endpoint in the list of all endpoints that might support the given cluster server. - * - * Returns kEmberInvalidEndpointIndex if the given endpoint does not support the - * given cluster or if the given endpoint is disabled. - * - * This function always returns the same index for a given endpointId instance, fixed or dynamic. - * - * The return index for fixed endpoints will range from 0 to (fixedClusterServerEndpointCount - 1), - * For dynamic endpoints the indexing assumes that any dynamic endpoint could start supporting - * the given server cluster and their index will range from fixedClusterServerEndpointCount to - * (fixedClusterServerEndpointCount + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT - 1). - * - * For example, if a device has 4 fixed endpoints (ids 0-3) and 2 dynamic - * endpoints, and cluster X is supported on endpoints 1 and 3, then - * fixedClusterServerEndpointCount should be 2 and - * - * 1) emberAfGetClusterServerEndpointIndex(0, X) returns kEmberInvalidEndpointIndex - * 2) emberAfGetClusterServerEndpointIndex(1, X) returns 0 - * 3) emberAfGetClusterServerEndpointIndex(2, X) returns kEmberInvalidEndpointIndex - * 4) emberAfGetClusterServerEndpointIndex(3, X) returns 1 - - * The Dynamic endpoints are placed after the fixed ones; - * therefore their return index will always be >= to fixedClusterServerEndpointCount - * - * If a dynamic endpoint, supporting cluster X, is defined to dynamic index 1 with endpoint id 7, - * (via emberAfSetDynamicEndpoint(1, 7, ...)) - * then emberAfGetClusterServerEndpointIndex(7, X) returns 3 (fixedClusterServerEndpointCount{2} + DynamicEndpointIndex {1}). - * - * If now a second dynamic endpoint, also supporting cluster X, is defined to dynamic index 0 - * with endpoint id 9 (via emberAfSetDynamicEndpoint(0, 9, ...)), - * emberAfGetClusterServerEndpointIndex(9, X) returns 2. (fixedClusterServerEndpointCount{2} + DynamicEndpointIndex {0}). - * and emberAfGetClusterServerEndpointIndex(7, X) still returns 3 - * - * @param endpoint Endpoint number - * @param cluster Id the of the Cluster server you are interrested on - * @param fixedClusterServerEndpointCount The number of fixed endpoints containing this cluster server. Typically one of the - MATTER_DM_*_CLUSTER_SERVER_ENDPOINT_COUNT constants. - */ -uint16_t emberAfGetClusterServerEndpointIndex(chip::EndpointId endpoint, chip::ClusterId cluster, - uint16_t fixedClusterServerEndpointCount); - -/** - * Returns the pointer to the data version storage for the given endpoint and - * cluster. Can return null in the following cases: - * - * 1) There is no such endpoint. - * 2) There is no such server cluster on the given endpoint. - * 3) No storage for a data version was provided for the endpoint. - */ -chip::DataVersion * emberAfDataVersionStorage(const chip::app::ConcreteClusterPath & aConcreteClusterPath); - -/** - * @brief Returns the number of pre-compiled endpoints. - */ -uint16_t emberAfFixedEndpointCount(); - -/** - * Get the semantic tags of the endpoint. - * Fills in the provided SemanticTagStruct with tag at index `index` if there is one, - * or returns CHIP_ERROR_NOT_FOUND if the index is out of range for the list of tag, - * or returns CHIP_ERROR_NOT_FOUND if the endpoint is invalid. - * @param endpoint The target endpoint. - * @param index The index of the tag, with 0 representing the first tag. - * @param tag The SemanticTagStruct is filled. - */ -CHIP_ERROR GetSemanticTagForEndpointAtIndex(chip::EndpointId endpoint, size_t index, - chip::app::Clusters::Descriptor::Structs::SemanticTagStruct::Type & tag); - -// -// Override the tag list current associated with an endpoint with a user-provided list. The buffers backing -// that list have to live as long as the endpoint is enabled. -// -// NOTE: It is the application's responsibility to free the existing list that is being replaced if needed. -// -CHIP_ERROR SetTagList(chip::EndpointId endpoint, - chip::Span tagList); - -// Returns number of clusters put into the passed cluster list -// for the given endpoint and client/server polarity -uint8_t emberAfGetClustersFromEndpoint(chip::EndpointId endpoint, chip::ClusterId * clusterList, uint8_t listLen, bool server); - -// Note the difference in for server filtering. -// This method will return the cluster count for BOTH client and server -// and those do NOT work with NthCluster/NthClusterId -// - Use emberAfGetClustersFromEndpoint() with emberAfGetNthCluster() emberAfGetNthClusterId() -// -uint8_t emberAfGetClusterCountForEndpoint(chip::EndpointId endpoint); - -// Check if a cluster is implemented or not. If yes, the cluster is returned. -// -// mask = 0 -> find either client or server -// mask = CLUSTER_MASK_CLIENT -> find client -// mask = CLUSTER_MASK_SERVER -> find server -// -// If a pointer to an index is provided, it will be updated to point to the relative index of the cluster -// within the set of clusters that match the mask criteria. -// -const EmberAfCluster * emberAfFindClusterInType(const EmberAfEndpointType * endpointType, chip::ClusterId clusterId, - EmberAfClusterMask mask, uint8_t * index = nullptr); - -// Initial configuration -void emberAfEndpointConfigure(); - -// Register a dynamic endpoint. This involves registering descriptors that describe -// the composition of the endpoint (encapsulated in the 'ep' argument) as well as providing -// storage for data versions. -// -// dataVersionStorage.size() needs to be at least as large as the number of -// server clusters on this endpoint. If it's not, the endpoint will not be able -// to store data versions, which may break consumers. -// -// The memory backing dataVersionStorage needs to remain allocated until this dynamic -// endpoint is cleared. -// -// An optional device type list can be passed in as well. If provided, the memory -// backing the list needs to remain allocated until this dynamic endpoint is cleared. -// -// An optional parent endpoint id should be passed for child endpoints of composed device. -// -// Returns CHIP_NO_ERROR No error. -// CHIP_ERROR_NO_MEMORY MAX_ENDPOINT_COUNT is reached or when no storage is left for clusters -// CHIP_ERROR_INVALID_ARGUMENT The EndpointId value passed is kInvalidEndpointId -// CHIP_ERROR_ENDPOINT_EXISTS If the EndpointId value passed already exists -// -CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, chip::EndpointId id, const EmberAfEndpointType * ep, - const chip::Span & dataVersionStorage, - chip::Span deviceTypeList = {}, - chip::EndpointId parentEndpointId = chip::kInvalidEndpointId); -chip::EndpointId emberAfClearDynamicEndpoint(uint16_t index); -uint16_t emberAfGetDynamicIndexFromEndpoint(chip::EndpointId id); -/** - * @brief Loads attribute defaults and any non-volatile attributes stored - * - * @param endpoint EnpointId. Use chip::kInvalidEndpointId to initialize all endpoints - */ -void emberAfInitializeAttributes(chip::EndpointId endpoint); - -// If server == true, returns the number of server clusters, -// otherwise number of client clusters on this endpoint -uint8_t emberAfClusterCount(chip::EndpointId endpoint, bool server); - -// Returns the cluster of Nth server or client cluster, -// depending on server toggle. -const EmberAfCluster * emberAfGetNthCluster(chip::EndpointId endpoint, uint8_t n, bool server); - -// -// Retrieve the device type list associated with a specific endpoint. -// -chip::Span emberAfDeviceTypeListFromEndpoint(chip::EndpointId endpoint, CHIP_ERROR & err); -chip::Span emberAfDeviceTypeListFromEndpointIndex(unsigned endpointIndex, CHIP_ERROR & err); - -// -// Override the device type list current associated with an endpoint with a user-provided list. The buffers backing -// that list have to live as long as the endpoint is enabled. -// -// NOTE: It is the application's responsibility to free the existing list that is being replaced if needed. -// -CHIP_ERROR emberAfSetDeviceTypeList(chip::EndpointId endpoint, chip::Span deviceTypeList); - -/// Returns a change listener that uses the global InteractionModelEngine -/// instance to report dirty paths -chip::app::AttributesChangedListener * emberAfGlobalInteractionModelAttributesChangedListener(); - -/// Mark the given attribute as having changed: -/// - increases the cluster data version for the given cluster -/// - uses `listener` to `MarkDirty` the given path. This is typically done to mark an -/// attribute as dirty within the matter attribute reporting engine, so that subscriptions -/// receive updated attribute values for a cluster. -/// -/// This is a convenience function to make it clear when a `emberAfDataVersionStorage` increase -/// and a `AttributesChangeListener::MarkDirty` always occur in lock-step. -void emberAfAttributeChanged(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, - chip::app::AttributesChangedListener * listener); - -/// Mark attributes on the given endpoint as having changed. -/// -/// Schedules reporting engine to consider the endpoint dirty, however does NOT increase/alter -/// any cluster data versions. -void emberAfEndpointChanged(chip::EndpointId endpoint, chip::app::AttributesChangedListener * listener); - -/// Maintains a increasing index of structural changes within ember -/// that determine if existing "indexes" and metadata pointers within ember -/// are still valid or not. -/// -/// Changes to metadata structure (e.g. endpoint enable/disable and dynamic endpoint changes) -/// are reflected in this generation count changing. -unsigned emberAfMetadataStructureGeneration(); - -namespace chip { -namespace app { - -class EnabledEndpointsWithServerCluster -{ -public: - EnabledEndpointsWithServerCluster(ClusterId clusterId); - - // Instead of having a separate Iterator class, optimize for codesize by - // just reusing ourselves as our own iterator. We could do a bit better - // here with C++17 and using a different type for the end iterator, but this - // is the best I've found with C++14 so far. - // - // This does mean that you can only iterate a given - // EnabledEndpointsWithServerCluster once, but that's OK given how we use it - // in practice. - EnabledEndpointsWithServerCluster & begin() { return *this; } - const EnabledEndpointsWithServerCluster & end() const { return *this; } - - bool operator!=(const EnabledEndpointsWithServerCluster & other) const { return mEndpointIndex != mEndpointCount; } - - EnabledEndpointsWithServerCluster & operator++(); - - EndpointId operator*() const; - -private: - void EnsureMatchingEndpoint(); - - uint16_t mEndpointIndex = 0; - uint16_t mEndpointCount = 0; - ClusterId mClusterId; -}; - -/** - * @brief Sets the parent endpoint for a given endpoint - */ -CHIP_ERROR SetParentEndpointForEndpoint(EndpointId childEndpoint, EndpointId parentEndpoint); - -/** - * @brief Sets an Endpoint to use Flat Composition - */ -CHIP_ERROR SetFlatCompositionForEndpoint(EndpointId endpoint); - -/** - * @brief Sets an Endpoint to use Tree Composition - */ -CHIP_ERROR SetTreeCompositionForEndpoint(EndpointId endpoint); - -/** - * @brief Returns true is an Endpoint has flat composition - */ -bool IsFlatCompositionForEndpoint(EndpointId endpoint); - -/** - * @brief Returns true is an Endpoint has tree composition - */ -bool IsTreeCompositionForEndpoint(EndpointId endpoint); - -enum class EndpointComposition : uint8_t -{ - kFullFamily, - kTree, - kInvalid, -}; - -/** - * @brief Returns the composition for a given endpoint index - */ -EndpointComposition GetCompositionForEndpointIndex(uint16_t index); - -} // namespace app -} // namespace chip diff --git a/src/app/util/ember-api.h b/src/app/util/ember-api.h new file mode 100644 index 00000000000000..1225c1c0b634ff --- /dev/null +++ b/src/app/util/ember-api.h @@ -0,0 +1,348 @@ +/** + * + * Copyright (c) 2024 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +// #include +// #include + +static constexpr uint16_t kEmberInvalidEndpointIndex = 0xFFFF; + +/** + * @brief locate attribute metadata + * + * Function returns pointer to the attribute metadata structure, + * or NULL if attribute was not found. + * + * @param endpoint Zigbee endpoint number. + * @param clusterId Cluster ID of the sought cluster. + * @param attributeId Attribute ID of the sought attribute. + * + * @return Returns pointer to the attribute metadata location. + */ +const EmberAfAttributeMetadata * emberAfLocateAttributeMetadata(chip::EndpointId endpoint, chip::ClusterId clusterId, + chip::AttributeId attributeId); + +/** + * @brief Returns true if endpoint contains the ZCL server with specified id. + * + * This function returns true if + * the endpoint contains server of a given cluster. + */ +bool emberAfContainsServer(chip::EndpointId endpoint, chip::ClusterId clusterId); + +/** + * @brief Returns true if endpoint of given index contains the ZCL server with specified id. + * + * This function returns true if + * the endpoint of given index contains server of a given cluster. + * If this function is used with a manufacturer specific clusterId + * then this will return the first cluster that it finds in the Cluster table. + * and will not return any other clusters that share that id. + */ +bool emberAfContainsServerFromIndex(uint16_t index, chip::ClusterId clusterId); + +/** + * @brief Returns true if endpoint contains the ZCL client with specified id. + * + * This function returns true if + * the endpoint contains client of a given cluster. + */ +bool emberAfContainsClient(chip::EndpointId endpoint, chip::ClusterId clusterId); + +/** + * @brief macro that returns size of attribute in bytes. + * + * @param metadata EmberAfAttributeMetadata* to consider. + */ +#define emberAfAttributeSize(metadata) ((metadata)->size) + +/** + * Returns the index of a given endpoint. Will return 0xFFFF if this is not a + * valid endpoint id or if the endpoint is disabled. + */ +uint16_t emberAfIndexFromEndpoint(chip::EndpointId endpoint); + +/** + * @brief Returns parent endpoint for a given endpoint index + */ +chip::EndpointId emberAfParentEndpointFromIndex(uint16_t index); + +/** + * @brief Returns the index of the given endpoint in the list of all endpoints that might support the given cluster server. + * + * Returns kEmberInvalidEndpointIndex if the given endpoint does not support the + * given cluster or if the given endpoint is disabled. + * + * This function always returns the same index for a given endpointId instance, fixed or dynamic. + * + * The return index for fixed endpoints will range from 0 to (fixedClusterServerEndpointCount - 1), + * For dynamic endpoints the indexing assumes that any dynamic endpoint could start supporting + * the given server cluster and their index will range from fixedClusterServerEndpointCount to + * (fixedClusterServerEndpointCount + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT - 1). + * + * For example, if a device has 4 fixed endpoints (ids 0-3) and 2 dynamic + * endpoints, and cluster X is supported on endpoints 1 and 3, then + * fixedClusterServerEndpointCount should be 2 and + * + * 1) emberAfGetClusterServerEndpointIndex(0, X) returns kEmberInvalidEndpointIndex + * 2) emberAfGetClusterServerEndpointIndex(1, X) returns 0 + * 3) emberAfGetClusterServerEndpointIndex(2, X) returns kEmberInvalidEndpointIndex + * 4) emberAfGetClusterServerEndpointIndex(3, X) returns 1 + + * The Dynamic endpoints are placed after the fixed ones; + * therefore their return index will always be >= to fixedClusterServerEndpointCount + * + * If a dynamic endpoint, supporting cluster X, is defined to dynamic index 1 with endpoint id 7, + * (via emberAfSetDynamicEndpoint(1, 7, ...)) + * then emberAfGetClusterServerEndpointIndex(7, X) returns 3 (fixedClusterServerEndpointCount{2} + DynamicEndpointIndex {1}). + * + * If now a second dynamic endpoint, also supporting cluster X, is defined to dynamic index 0 + * with endpoint id 9 (via emberAfSetDynamicEndpoint(0, 9, ...)), + * emberAfGetClusterServerEndpointIndex(9, X) returns 2. (fixedClusterServerEndpointCount{2} + DynamicEndpointIndex {0}). + * and emberAfGetClusterServerEndpointIndex(7, X) still returns 3 + * + * @param endpoint Endpoint number + * @param cluster Id the of the Cluster server you are interrested on + * @param fixedClusterServerEndpointCount The number of fixed endpoints containing this cluster server. Typically one of the + MATTER_DM_*_CLUSTER_SERVER_ENDPOINT_COUNT constants. + */ +uint16_t emberAfGetClusterServerEndpointIndex(chip::EndpointId endpoint, chip::ClusterId cluster, + uint16_t fixedClusterServerEndpointCount); + +/** + * Returns the pointer to the data version storage for the given endpoint and + * cluster. Can return null in the following cases: + * + * 1) There is no such endpoint. + * 2) There is no such server cluster on the given endpoint. + * 3) No storage for a data version was provided for the endpoint. + */ +chip::DataVersion * emberAfDataVersionStorage(const chip::app::ConcreteClusterPath & aConcreteClusterPath); + +/** + * @brief Returns the number of pre-compiled endpoints. + */ +uint16_t emberAfFixedEndpointCount(); + +/** + * Get the semantic tags of the endpoint. + * Fills in the provided SemanticTagStruct with tag at index `index` if there is one, + * or returns CHIP_ERROR_NOT_FOUND if the index is out of range for the list of tag, + * or returns CHIP_ERROR_NOT_FOUND if the endpoint is invalid. + * @param endpoint The target endpoint. + * @param index The index of the tag, with 0 representing the first tag. + * @param tag The SemanticTagStruct is filled. + */ +CHIP_ERROR GetSemanticTagForEndpointAtIndex(chip::EndpointId endpoint, size_t index, + chip::app::Clusters::Descriptor::Structs::SemanticTagStruct::Type & tag); + +// +// Override the tag list current associated with an endpoint with a user-provided list. The buffers backing +// that list have to live as long as the endpoint is enabled. +// +// NOTE: It is the application's responsibility to free the existing list that is being replaced if needed. +// +CHIP_ERROR SetTagList(chip::EndpointId endpoint, + chip::Span tagList); + +// Returns number of clusters put into the passed cluster list +// for the given endpoint and client/server polarity +uint8_t emberAfGetClustersFromEndpoint(chip::EndpointId endpoint, chip::ClusterId * clusterList, uint8_t listLen, bool server); + +// Note the difference in for server filtering. +// This method will return the cluster count for BOTH client and server +// and those do NOT work with NthCluster/NthClusterId +// - Use emberAfGetClustersFromEndpoint() with emberAfGetNthCluster() emberAfGetNthClusterId() +// +uint8_t emberAfGetClusterCountForEndpoint(chip::EndpointId endpoint); + +// Check if a cluster is implemented or not. If yes, the cluster is returned. +// +// mask = 0 -> find either client or server +// mask = CLUSTER_MASK_CLIENT -> find client +// mask = CLUSTER_MASK_SERVER -> find server +// +// If a pointer to an index is provided, it will be updated to point to the relative index of the cluster +// within the set of clusters that match the mask criteria. +// +const EmberAfCluster * emberAfFindClusterInType(const EmberAfEndpointType * endpointType, chip::ClusterId clusterId, + EmberAfClusterMask mask, uint8_t * index = nullptr); + +// Initial configuration +void emberAfEndpointConfigure(); + +// Register a dynamic endpoint. This involves registering descriptors that describe +// the composition of the endpoint (encapsulated in the 'ep' argument) as well as providing +// storage for data versions. +// +// dataVersionStorage.size() needs to be at least as large as the number of +// server clusters on this endpoint. If it's not, the endpoint will not be able +// to store data versions, which may break consumers. +// +// The memory backing dataVersionStorage needs to remain allocated until this dynamic +// endpoint is cleared. +// +// An optional device type list can be passed in as well. If provided, the memory +// backing the list needs to remain allocated until this dynamic endpoint is cleared. +// +// An optional parent endpoint id should be passed for child endpoints of composed device. +// +// Returns CHIP_NO_ERROR No error. +// CHIP_ERROR_NO_MEMORY MAX_ENDPOINT_COUNT is reached or when no storage is left for clusters +// CHIP_ERROR_INVALID_ARGUMENT The EndpointId value passed is kInvalidEndpointId +// CHIP_ERROR_ENDPOINT_EXISTS If the EndpointId value passed already exists +// +CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, chip::EndpointId id, const EmberAfEndpointType * ep, + const chip::Span & dataVersionStorage, + chip::Span deviceTypeList = {}, + chip::EndpointId parentEndpointId = chip::kInvalidEndpointId); +chip::EndpointId emberAfClearDynamicEndpoint(uint16_t index); +uint16_t emberAfGetDynamicIndexFromEndpoint(chip::EndpointId id); +/** + * @brief Loads attribute defaults and any non-volatile attributes stored + * + * @param endpoint EnpointId. Use chip::kInvalidEndpointId to initialize all endpoints + */ +void emberAfInitializeAttributes(chip::EndpointId endpoint); + +// If server == true, returns the number of server clusters, +// otherwise number of client clusters on this endpoint +uint8_t emberAfClusterCount(chip::EndpointId endpoint, bool server); + +// Returns the cluster of Nth server or client cluster, +// depending on server toggle. +const EmberAfCluster * emberAfGetNthCluster(chip::EndpointId endpoint, uint8_t n, bool server); + +// +// Retrieve the device type list associated with a specific endpoint. +// +chip::Span emberAfDeviceTypeListFromEndpoint(chip::EndpointId endpoint, CHIP_ERROR & err); +chip::Span emberAfDeviceTypeListFromEndpointIndex(unsigned endpointIndex, CHIP_ERROR & err); + +// +// Override the device type list current associated with an endpoint with a user-provided list. The buffers backing +// that list have to live as long as the endpoint is enabled. +// +// NOTE: It is the application's responsibility to free the existing list that is being replaced if needed. +// +CHIP_ERROR emberAfSetDeviceTypeList(chip::EndpointId endpoint, chip::Span deviceTypeList); + +/// Returns a change listener that uses the global InteractionModelEngine +/// instance to report dirty paths +chip::app::AttributesChangedListener * emberAfGlobalInteractionModelAttributesChangedListener(); + +/// Mark the given attribute as having changed: +/// - increases the cluster data version for the given cluster +/// - uses `listener` to `MarkDirty` the given path. This is typically done to mark an +/// attribute as dirty within the matter attribute reporting engine, so that subscriptions +/// receive updated attribute values for a cluster. +/// +/// This is a convenience function to make it clear when a `emberAfDataVersionStorage` increase +/// and a `AttributesChangeListener::MarkDirty` always occur in lock-step. +void emberAfAttributeChanged(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, + chip::app::AttributesChangedListener * listener); + +/// Mark attributes on the given endpoint as having changed. +/// +/// Schedules reporting engine to consider the endpoint dirty, however does NOT increase/alter +/// any cluster data versions. +void emberAfEndpointChanged(chip::EndpointId endpoint, chip::app::AttributesChangedListener * listener); + +/// Maintains a increasing index of structural changes within ember +/// that determine if existing "indexes" and metadata pointers within ember +/// are still valid or not. +/// +/// Changes to metadata structure (e.g. endpoint enable/disable and dynamic endpoint changes) +/// are reflected in this generation count changing. +unsigned emberAfMetadataStructureGeneration(); + +namespace chip { +namespace app { + +class EnabledEndpointsWithServerCluster +{ +public: + EnabledEndpointsWithServerCluster(ClusterId clusterId); + + // Instead of having a separate Iterator class, optimize for codesize by + // just reusing ourselves as our own iterator. We could do a bit better + // here with C++17 and using a different type for the end iterator, but this + // is the best I've found with C++14 so far. + // + // This does mean that you can only iterate a given + // EnabledEndpointsWithServerCluster once, but that's OK given how we use it + // in practice. + EnabledEndpointsWithServerCluster & begin() { return *this; } + const EnabledEndpointsWithServerCluster & end() const { return *this; } + + bool operator!=(const EnabledEndpointsWithServerCluster & other) const { return mEndpointIndex != mEndpointCount; } + + EnabledEndpointsWithServerCluster & operator++(); + + EndpointId operator*() const; + +private: + void EnsureMatchingEndpoint(); + + uint16_t mEndpointIndex = 0; + uint16_t mEndpointCount = 0; + ClusterId mClusterId; +}; + +/** + * @brief Sets the parent endpoint for a given endpoint + */ +CHIP_ERROR SetParentEndpointForEndpoint(EndpointId childEndpoint, EndpointId parentEndpoint); + +/** + * @brief Sets an Endpoint to use Flat Composition + */ +CHIP_ERROR SetFlatCompositionForEndpoint(EndpointId endpoint); + +/** + * @brief Sets an Endpoint to use Tree Composition + */ +CHIP_ERROR SetTreeCompositionForEndpoint(EndpointId endpoint); + +/** + * @brief Returns true is an Endpoint has flat composition + */ +bool IsFlatCompositionForEndpoint(EndpointId endpoint); + +/** + * @brief Returns true is an Endpoint has tree composition + */ +bool IsTreeCompositionForEndpoint(EndpointId endpoint); + +enum class EndpointComposition : uint8_t +{ + kFullFamily, + kTree, + kInvalid, +}; + +/** + * @brief Returns the composition for a given endpoint index + */ +EndpointComposition GetCompositionForEndpointIndex(uint16_t index); + +} // namespace app +} // namespace chip diff --git a/src/app/zap_cluster_list.json b/src/app/zap_cluster_list.json index 4de99f1b7aaf3d..2281ba5a4cfeb4 100644 --- a/src/app/zap_cluster_list.json +++ b/src/app/zap_cluster_list.json @@ -298,7 +298,7 @@ "THREAD_NETWORK_DIAGNOSTICS_CLUSTER": [ "thread-network-diagnostics-server" ], - "THREAD_NETWORK_DIRECTORY_CLUSTER": ["thread-network-directory-server"], + "THREAD_NETWORK_DIRECTORY_CLUSTER": ["thread-network-directory"], "TIME_CLUSTER": [], "TIME_FORMAT_LOCALIZATION_CLUSTER": ["time-format-localization-server"], "TIME_SYNCHRONIZATION_CLUSTER": ["time-synchronization-server"], @@ -318,7 +318,7 @@ "WEB_RTC_PROVIDER_CLUSTER": [], "WEBRTC_REQUESTOR_CLUSTER": [], "WIFI_NETWORK_DIAGNOSTICS_CLUSTER": ["wifi-network-diagnostics-server"], - "WIFI_NETWORK_MANAGEMENT_CLUSTER": ["wifi-network-management-server"], + "WIFI_NETWORK_MANAGEMENT_CLUSTER": ["wifi-network-management"], "WINDOW_COVERING_CLUSTER": ["window-covering-server"], "WATER_HEATER_MANAGEMENT_CLUSTER": ["water-heater-management-server"], "WATER_HEATER_MODE_CLUSTER": ["mode-base-server"], diff --git a/src/app/zap_cluster_list.py b/src/app/zap_cluster_list.py index 24c480ffebbf25..ec1818f2a89389 100755 --- a/src/app/zap_cluster_list.py +++ b/src/app/zap_cluster_list.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""Parses a ZAP input file and outputs directories to compile.""" +"""Parses a ZAP input file and outputs targets to compile.""" import argparse import json @@ -12,10 +12,10 @@ def get_cluster_sources(clusters: typing.Set[str], source_map: typing.Dict[str, typing.List[str]], side: str): - """Returns a list of cluster source directories for the given clusters. + """Returns a list of cluster targets for the given clusters. Returns: - The set of source directories to build. + The set of targets to build. """ cluster_sources: typing.Set[str] = set() @@ -25,7 +25,7 @@ def get_cluster_sources(clusters: typing.Set[str], raise ValueError("Unhandled %s cluster: %s" " (hint: add to src/app/zap_cluster_list.json)" % (side, cluster)) - cluster_sources.update(source_map[cluster]) + cluster_sources.update(["%s:%s" % (dir, side) for dir in source_map[cluster]]) return cluster_sources @@ -33,7 +33,7 @@ def get_cluster_sources(clusters: typing.Set[str], def dump_zapfile_clusters(zap_file_path: pathlib.Path, implementation_data_path: pathlib.Path, external_clusters: typing.List[str]): - """Prints all of the source directories to build for a given ZAP file. + """Prints all of the targets to build for a given ZAP file. Arguments: zap_file_path - Path to the ZAP input file.