From f7b39db28ff27df1ba6b25a72500d1f8c8d610b0 Mon Sep 17 00:00:00 2001 From: chrisdecenzo <61757564+chrisdecenzo@users.noreply.github.com> Date: Wed, 6 Apr 2022 14:18:39 -0700 Subject: [PATCH] add attribute change callback hook for speaker endpoint (#16944) * add attribute change callback hook for speaker endpoint * Update examples/tv-app/linux/ZclCallbacks.cpp Co-authored-by: Boris Zbarsky * Update examples/tv-app/linux/ZclCallbacks.cpp Co-authored-by: Boris Zbarsky * Delete af-gen-event.h Revert change pending feedback on level control cluster on endpoint 1 * add back af-gen-events * Restyle add attribute change callback hook for speaker endpoint (#16945) * Restyled by whitespace * Restyled by gn Co-authored-by: Restyled.io Co-authored-by: Justin Wood Co-authored-by: Boris Zbarsky Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com> Co-authored-by: Restyled.io --- examples/tv-app/linux/BUILD.gn | 1 + examples/tv-app/linux/ZclCallbacks.cpp | 70 +++++++++++++++++++ .../tv-app/zap-generated/af-gen-event.h | 2 + 3 files changed, 73 insertions(+) create mode 100644 examples/tv-app/linux/ZclCallbacks.cpp diff --git a/examples/tv-app/linux/BUILD.gn b/examples/tv-app/linux/BUILD.gn index 58c0a2773f2350..e492d26d0a59e4 100644 --- a/examples/tv-app/linux/BUILD.gn +++ b/examples/tv-app/linux/BUILD.gn @@ -43,6 +43,7 @@ executable("chip-tv-app") { "AppImpl.cpp", "AppImpl.h", "AppPlatformShellCommands.cpp", + "ZclCallbacks.cpp", "include/account-login/AccountLoginManager.cpp", "include/account-login/AccountLoginManager.h", "include/application-basic/ApplicationBasicManager.cpp", diff --git a/examples/tv-app/linux/ZclCallbacks.cpp b/examples/tv-app/linux/ZclCallbacks.cpp new file mode 100644 index 00000000000000..b3fe026435340a --- /dev/null +++ b/examples/tv-app/linux/ZclCallbacks.cpp @@ -0,0 +1,70 @@ +/* + * + * Copyright (c) 2020 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. + */ + +/** + * @file + * This file implements the handler for data model messages. + */ + +#include +#include +#include +#include + +using namespace ::chip; +using namespace ::chip::app::Clusters; + +void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t mask, uint8_t type, + uint16_t size, uint8_t * value) +{ + ClusterId clusterId = attributePath.mClusterId; + AttributeId attributeId = attributePath.mAttributeId; + ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId)); + + if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id) + { + ChipLogProgress(Zcl, "OnOff attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %" PRIu16, + ChipLogValueMEI(attributeId), type, *value, size); + } + else if (clusterId == LevelControl::Id) + { + ChipLogProgress(Zcl, "Level Control attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %" PRIu16, + ChipLogValueMEI(attributeId), type, *value, size); + + // WIP Apply attribute change to Light + } +} + +/** @brief OnOff Cluster Init + * + * This function is called when a specific cluster is initialized. It gives the + * application an opportunity to take care of cluster initialization procedures. + * It is called exactly once for each endpoint where cluster is present. + * + * @param endpoint Ver.: always + * + * TODO Issue #3841 + * emberAfOnOffClusterInitCallback happens before the stack initialize the cluster + * attributes to the default value. + * The logic here expects something similar to the deprecated Plugins callback + * emberAfPluginOnOffClusterServerPostInitCallback. + * + */ +void emberAfOnOffClusterInitCallback(EndpointId endpoint) +{ + // TODO: implement any additional Cluster Server init actions +} diff --git a/zzz_generated/tv-app/zap-generated/af-gen-event.h b/zzz_generated/tv-app/zap-generated/af-gen-event.h index ae3ba4abd7b336..d82ed718c3efbd 100644 --- a/zzz_generated/tv-app/zap-generated/af-gen-event.h +++ b/zzz_generated/tv-app/zap-generated/af-gen-event.h @@ -35,6 +35,8 @@ // // +// NOTE: currently, level server cluster is not declared on endpoint 1 + // Enclosing macro to prevent multiple inclusion #ifndef __AF_GEN_EVENT__ #define __AF_GEN_EVENT__