From 1062052f1f37cf2c08803fa23f5cd761c809cad8 Mon Sep 17 00:00:00 2001 From: Doug Ferraz Date: Fri, 10 Feb 2023 19:34:38 +0000 Subject: [PATCH] chg: misc fixed addressing comments --- .../all-clusters-app/app-templates/endpoint_config.h | 4 ++-- .../color-control-server/color-control-server.cpp | 3 ++- .../clusters/color-control-server/color-control-server.h | 3 ++- src/app/clusters/level-control/level-control.cpp | 2 +- src/app/clusters/on-off-server/on-off-server.cpp | 3 ++- src/app/common/templates/config-data.yaml | 7 +++++++ src/app/util/af-types.h | 8 ++++++++ src/app/util/attribute-storage.cpp | 5 ++--- src/app/zap-templates/templates/app/att-storage.zapt | 2 +- 9 files changed, 27 insertions(+), 10 deletions(-) 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 a51fe4565a9689..17f281af45fa29 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 @@ -1603,8 +1603,8 @@ }; \ const EmberAfGenericClusterFunction chipFuncArrayDoorLockServer[] = { \ (EmberAfGenericClusterFunction) MatterDoorLockClusterServerAttributeChangedCallback, \ - (EmberAfGenericClusterFunction) MatterDoorLockClusterServerPreAttributeChangedCallback, \ (EmberAfGenericClusterFunction) MatterDoorLockClusterServerShutdownCallback, \ + (EmberAfGenericClusterFunction) MatterDoorLockClusterServerPreAttributeChangedCallback, \ }; \ const EmberAfGenericClusterFunction chipFuncArrayWindowCoveringServer[] = { \ (EmberAfGenericClusterFunction) MatterWindowCoveringClusterServerAttributeChangedCallback, \ @@ -2559,7 +2559,7 @@ .attributes = ZAP_ATTRIBUTE_INDEX(324), \ .attributeCount = 33, \ .clusterSize = 55, \ - .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION) | ZAP_CLUSTER_MASK(PRE_ATTRIBUTE_CHANGED_FUNCTION) | ZAP_CLUSTER_MASK(SHUTDOWN_FUNCTION), \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION) | ZAP_CLUSTER_MASK(SHUTDOWN_FUNCTION) | ZAP_CLUSTER_MASK(PRE_ATTRIBUTE_CHANGED_FUNCTION), \ .functions = chipFuncArrayDoorLockServer, \ .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 127 ) ,\ .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 142 ) ,\ diff --git a/src/app/clusters/color-control-server/color-control-server.cpp b/src/app/clusters/color-control-server/color-control-server.cpp index c4a96a0bb4d6b3..4c5c8e0b3f3aa0 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -66,7 +66,8 @@ void ColorControlServer::cancelEndpointTimerCallback(EmberEventControl * control void ColorControlServer::cancelEndpointTimerCallback(EndpointId endpoint) { auto control = ColorControlServer::getEventControl(endpoint); - if (control) { + if (control) + { cancelEndpointTimerCallback(control); } } diff --git a/src/app/clusters/color-control-server/color-control-server.h b/src/app/clusters/color-control-server/color-control-server.h index 4321397350b2b1..6a524269b52291 100644 --- a/src/app/clusters/color-control-server/color-control-server.h +++ b/src/app/clusters/color-control-server/color-control-server.h @@ -247,7 +247,8 @@ class ColorControlServer Color16uTransitionState colorTempTransitionStates[EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT]; #endif // EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP - EmberEventControl eventControls[EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT]; + EmberEventControl + eventControls[EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT + CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT]; }; /********************************************************** diff --git a/src/app/clusters/level-control/level-control.cpp b/src/app/clusters/level-control/level-control.cpp index e8f3a6819d462a..b58e668dfa335d 100644 --- a/src/app/clusters/level-control/level-control.cpp +++ b/src/app/clusters/level-control/level-control.cpp @@ -1295,7 +1295,7 @@ void emberAfLevelControlClusterServerInitCallback(EndpointId endpoint) void MatterLevelControlClusterServerShutdownCallback(EndpointId endpoint) { emberAfOnOffClusterPrintln("Shuting down level control server cluster on endpoint %d", endpoint); - DeviceLayer::SystemLayer().CancelTimer(timerCallback, reinterpret_cast(static_cast(endpoint))); + cancelEndpointTimerCallback(endpoint); } #ifndef IGNORE_LEVEL_CONTROL_CLUSTER_START_UP_CURRENT_LEVEL diff --git a/src/app/clusters/on-off-server/on-off-server.cpp b/src/app/clusters/on-off-server/on-off-server.cpp index 11334affe85053..341b4f27773937 100644 --- a/src/app/clusters/on-off-server/on-off-server.cpp +++ b/src/app/clusters/on-off-server/on-off-server.cpp @@ -88,7 +88,8 @@ void OnOffServer::cancelEndpointTimerCallback(EmberEventControl * control) void OnOffServer::cancelEndpointTimerCallback(EndpointId endpoint) { auto control = OnOffServer::getEventControl(endpoint); - if (control) { + if (control) + { cancelEndpointTimerCallback(control); } } diff --git a/src/app/common/templates/config-data.yaml b/src/app/common/templates/config-data.yaml index 063eadbb48e800..024b287b5a68cf 100644 --- a/src/app/common/templates/config-data.yaml +++ b/src/app/common/templates/config-data.yaml @@ -66,6 +66,13 @@ ClustersWithAttributeChangedFunctions: - Window Covering - Fan Control +ClustersWithShutdownFunctions: + - Barrier Control + - On/Off + - Door Lock + - Level Control + - Color Control + ClustersWithPreAttributeChangeFunctions: - Door Lock - Pump Configuration and Control diff --git a/src/app/util/af-types.h b/src/app/util/af-types.h index d284d93961dd0d..9569a7ea4afc41 100644 --- a/src/app/util/af-types.h +++ b/src/app/util/af-types.h @@ -1002,6 +1002,14 @@ typedef void (*EmberAfTickFunction)(chip::EndpointId endpoint); */ typedef void (*EmberAfInitFunction)(chip::EndpointId endpoint); +/** + * @brief Type for referring to the shutdown callback for cluster. + * + * Init function is called when the cluster is shut down, for example + * when an endpoint is disabled + */ +typedef void (*EmberAfShutdownFunction)(chip::EndpointId endpoint); + /** * @brief Type for referring to the attribute changed callback function. * diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 3306dbf65c303f..70c9d6390c0d99 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -371,11 +371,10 @@ static void shutdownEndpoint(EmberAfDefinedEndpoint * definedEndpoint) for (clusterIndex = 0; clusterIndex < epType->clusterCount; clusterIndex++) { const EmberAfCluster * cluster = &(epType->cluster[clusterIndex]); - EmberAfGenericClusterFunction f; - f = emberAfFindClusterFunction(cluster, CLUSTER_MASK_SHUTDOWN_FUNCTION); + EmberAfGenericClusterFunction f = emberAfFindClusterFunction(cluster, CLUSTER_MASK_SHUTDOWN_FUNCTION); if (f != nullptr) { - ((EmberAfInitFunction) f)(definedEndpoint->endpoint); + ((EmberAfShutdownFunction) f)(definedEndpoint->endpoint); } } diff --git a/src/app/zap-templates/templates/app/att-storage.zapt b/src/app/zap-templates/templates/app/att-storage.zapt index 52b2ae752cdae2..d76a89be323409 100644 --- a/src/app/zap-templates/templates/app/att-storage.zapt +++ b/src/app/zap-templates/templates/app/att-storage.zapt @@ -20,4 +20,4 @@ // Cluster is a server #define CLUSTER_MASK_SERVER (0x40) // Cluster is a client -#define CLUSTER_MASK_CLIENT (0x80) \ No newline at end of file +#define CLUSTER_MASK_CLIENT (0x80)