From 11d77c13e4c0fb25e6866ca86c9e216ad0f4cfac Mon Sep 17 00:00:00 2001 From: chrisdecenzo Date: Fri, 1 Apr 2022 11:42:00 -0700 Subject: [PATCH 1/6] add attribute change callback hook for speaker endpoint --- examples/tv-app/linux/BUILD.gn | 1 + examples/tv-app/linux/ZclCallbacks.cpp | 70 +++++++++++++++++++ .../tv-app/zap-generated/af-gen-event.h | 29 ++++++++ 3 files changed, 100 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..4b494411c035cd 100644 --- a/examples/tv-app/linux/BUILD.gn +++ b/examples/tv-app/linux/BUILD.gn @@ -72,6 +72,7 @@ executable("chip-tv-app") { "include/wake-on-lan/WakeOnLanManager.cpp", "include/wake-on-lan/WakeOnLanManager.h", "main.cpp", + "ZclCallbacks.cpp", ] deps = [ diff --git a/examples/tv-app/linux/ZclCallbacks.cpp b/examples/tv-app/linux/ZclCallbacks.cpp new file mode 100644 index 00000000000000..27923224607c85 --- /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: %" PRIu16 ", length %" PRIu16, + ChipLogValueMEI(attributeId), type, *value, size); + } + else if (clusterId == LevelControl::Id) + { + ChipLogProgress(Zcl, "Level Control attribute ID: " ChipLogFormatMEI " Type: %u Value: %" PRIu16 ", 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 814d4aab6b8bec..bdf09fa06c746f 100644 --- a/zzz_generated/tv-app/zap-generated/af-gen-event.h +++ b/zzz_generated/tv-app/zap-generated/af-gen-event.h @@ -36,4 +36,33 @@ #ifndef __AF_GEN_EVENT__ #define __AF_GEN_EVENT__ +// Code used to configure the cluster event mechanism +#define EMBER_AF_GENERATED_EVENT_CODE \ + EmberEventControl emberAfLevelControlClusterServerTickCallbackControl1; \ + static void clusterTickWrapper(EmberEventControl * control, EmberAfTickFunction callback, uint8_t endpoint) \ + { \ + /* emberAfPushEndpointNetworkIndex(endpoint); */ \ + emberEventControlSetInactive(control); \ + (*callback)(endpoint); \ + /* emberAfPopNetworkIndex(); */ \ + } \ + void emberAfLevelControlClusterServerTickCallbackWrapperFunction1(void) \ + { \ + clusterTickWrapper(&emberAfLevelControlClusterServerTickCallbackControl1, emberAfLevelControlClusterServerTickCallback, \ + 2); \ + } + +// EmberEventData structs used to populate the EmberEventData table +#define EMBER_AF_GENERATED_EVENTS \ + { &emberAfLevelControlClusterServerTickCallbackControl1, emberAfLevelControlClusterServerTickCallbackWrapperFunction1 }, + +#define EMBER_AF_GENERATED_EVENT_STRINGS "Level Control Cluster Server EP 2", + +// The length of the event context table used to track and retrieve cluster events +#define EMBER_AF_EVENT_CONTEXT_LENGTH 1 + +// EmberAfEventContext structs used to populate the EmberAfEventContext table +#define EMBER_AF_GENERATED_EVENT_CONTEXT \ + { 0x2, 0x8, false, EMBER_AF_LONG_POLL, EMBER_AF_OK_TO_SLEEP, &emberAfLevelControlClusterServerTickCallbackControl1 }, + #endif // __AF_GEN_EVENT__ From 6935b181a8b2efbf008a71b71afd1923ce49f13a Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Mon, 4 Apr 2022 17:44:24 -0700 Subject: [PATCH 2/6] Update examples/tv-app/linux/ZclCallbacks.cpp Co-authored-by: Boris Zbarsky --- examples/tv-app/linux/ZclCallbacks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tv-app/linux/ZclCallbacks.cpp b/examples/tv-app/linux/ZclCallbacks.cpp index 27923224607c85..6a0eea76726f11 100644 --- a/examples/tv-app/linux/ZclCallbacks.cpp +++ b/examples/tv-app/linux/ZclCallbacks.cpp @@ -42,7 +42,7 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & } else if (clusterId == LevelControl::Id) { - ChipLogProgress(Zcl, "Level Control attribute ID: " ChipLogFormatMEI " Type: %u Value: %" PRIu16 ", length %" PRIu16, + ChipLogProgress(Zcl, "Level Control attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %" PRIu16, ChipLogValueMEI(attributeId), type, *value, size); // WIP Apply attribute change to Light From d09e524fe6a8d048ffedd205b1e31d67df47318a Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Mon, 4 Apr 2022 17:44:31 -0700 Subject: [PATCH 3/6] Update examples/tv-app/linux/ZclCallbacks.cpp Co-authored-by: Boris Zbarsky --- examples/tv-app/linux/ZclCallbacks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tv-app/linux/ZclCallbacks.cpp b/examples/tv-app/linux/ZclCallbacks.cpp index 6a0eea76726f11..b3fe026435340a 100644 --- a/examples/tv-app/linux/ZclCallbacks.cpp +++ b/examples/tv-app/linux/ZclCallbacks.cpp @@ -37,7 +37,7 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id) { - ChipLogProgress(Zcl, "OnOff attribute ID: " ChipLogFormatMEI " Type: %u Value: %" PRIu16 ", length %" PRIu16, + ChipLogProgress(Zcl, "OnOff attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %" PRIu16, ChipLogValueMEI(attributeId), type, *value, size); } else if (clusterId == LevelControl::Id) From d056256d16a687833a232d815d17152c48dce538 Mon Sep 17 00:00:00 2001 From: chrisdecenzo <61757564+chrisdecenzo@users.noreply.github.com> Date: Wed, 6 Apr 2022 08:16:45 -0700 Subject: [PATCH 4/6] Delete af-gen-event.h Revert change pending feedback on level control cluster on endpoint 1 --- .../tv-app/zap-generated/af-gen-event.h | 71 ------------------- 1 file changed, 71 deletions(-) delete mode 100644 zzz_generated/tv-app/zap-generated/af-gen-event.h diff --git a/zzz_generated/tv-app/zap-generated/af-gen-event.h b/zzz_generated/tv-app/zap-generated/af-gen-event.h deleted file mode 100644 index 17c37943a79118..00000000000000 --- a/zzz_generated/tv-app/zap-generated/af-gen-event.h +++ /dev/null @@ -1,71 +0,0 @@ -/** - * - * 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. - */ - -/** - * - * Copyright (c) 2020 Silicon Labs - * - * 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. - */ -// This file is generated by Simplicity Studio. Please do not edit manually. -// -// - -// Enclosing macro to prevent multiple inclusion -#ifndef __AF_GEN_EVENT__ -#define __AF_GEN_EVENT__ - -// Code used to configure the cluster event mechanism -#define EMBER_AF_GENERATED_EVENT_CODE \ - EmberEventControl emberAfLevelControlClusterServerTickCallbackControl1; \ - static void clusterTickWrapper(EmberEventControl * control, EmberAfTickFunction callback, uint8_t endpoint) \ - { \ - /* emberAfPushEndpointNetworkIndex(endpoint); */ \ - emberEventControlSetInactive(control); \ - (*callback)(endpoint); \ - /* emberAfPopNetworkIndex(); */ \ - } \ - void emberAfLevelControlClusterServerTickCallbackWrapperFunction1(void) \ - { \ - clusterTickWrapper(&emberAfLevelControlClusterServerTickCallbackControl1, emberAfLevelControlClusterServerTickCallback, \ - 2); \ - } - -// EmberEventData structs used to populate the EmberEventData table -#define EMBER_AF_GENERATED_EVENTS \ - { &emberAfLevelControlClusterServerTickCallbackControl1, emberAfLevelControlClusterServerTickCallbackWrapperFunction1 }, - -#define EMBER_AF_GENERATED_EVENT_STRINGS "Level Control Cluster Server EP 2", - -// The length of the event context table used to track and retrieve cluster events -#define EMBER_AF_EVENT_CONTEXT_LENGTH 1 - -// EmberAfEventContext structs used to populate the EmberAfEventContext table -#define EMBER_AF_GENERATED_EVENT_CONTEXT \ - { 0x2, 0x8, false, EMBER_AF_LONG_POLL, EMBER_AF_OK_TO_SLEEP, &emberAfLevelControlClusterServerTickCallbackControl1 }, - -#endif // __AF_GEN_EVENT__ From 9e81cc3bcf948269e01c7772de47398671bd3f7e Mon Sep 17 00:00:00 2001 From: chrisdecenzo Date: Wed, 6 Apr 2022 08:28:44 -0700 Subject: [PATCH 5/6] add back af-gen-events --- .../tv-app/zap-generated/af-gen-event.h | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 zzz_generated/tv-app/zap-generated/af-gen-event.h diff --git a/zzz_generated/tv-app/zap-generated/af-gen-event.h b/zzz_generated/tv-app/zap-generated/af-gen-event.h new file mode 100644 index 00000000000000..7ec2a044571b6b --- /dev/null +++ b/zzz_generated/tv-app/zap-generated/af-gen-event.h @@ -0,0 +1,82 @@ +/** + * + * 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. + */ + +/** + * + * Copyright (c) 2020 Silicon Labs + * + * 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. + */ +// This file is generated by Simplicity Studio. Please do not edit manually. +// +// + +// 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__ + +// Code used to configure the cluster event mechanism +#define EMBER_AF_GENERATED_EVENT_CODE \ + EmberEventControl emberAfLevelControlClusterServerTickCallbackControl1; \ + EmberEventControl emberAfLevelControlClusterServerTickCallbackControl2; \ + static void clusterTickWrapper(EmberEventControl * control, EmberAfTickFunction callback, uint8_t endpoint) \ + { \ + /* emberAfPushEndpointNetworkIndex(endpoint); */ \ + emberEventControlSetInactive(control); \ + (*callback)(endpoint); \ + /* emberAfPopNetworkIndex(); */ \ + } \ + void emberAfLevelControlClusterServerTickCallbackWrapperFunction1(void) \ + { \ + clusterTickWrapper(&emberAfLevelControlClusterServerTickCallbackControl1, emberAfLevelControlClusterServerTickCallback, \ + 1); \ + } \ + void emberAfLevelControlClusterServerTickCallbackWrapperFunction2(void) \ + { \ + clusterTickWrapper(&emberAfLevelControlClusterServerTickCallbackControl1, emberAfLevelControlClusterServerTickCallback, \ + 2); \ + } + +// EmberEventData structs used to populate the EmberEventData table +#define EMBER_AF_GENERATED_EVENTS \ + { &emberAfLevelControlClusterServerTickCallbackControl1, emberAfLevelControlClusterServerTickCallbackWrapperFunction1 }, \ + { &emberAfLevelControlClusterServerTickCallbackControl2, emberAfLevelControlClusterServerTickCallbackWrapperFunction2 }, + +#define EMBER_AF_GENERATED_EVENT_STRINGS "Level Server EP 1", "Level Server EP 2", + +// The length of the event context table used to track and retrieve cluster events +#define EMBER_AF_EVENT_CONTEXT_LENGTH 2 + +// EmberAfEventContext structs used to populate the EmberAfEventContext table +#define EMBER_AF_GENERATED_EVENT_CONTEXT \ + { 0x1, 0x8, false, EMBER_AF_LONG_POLL, EMBER_AF_OK_TO_SLEEP, &emberAfLevelControlClusterServerTickCallbackControl1 }, \ + { 0x2, 0x8, false, EMBER_AF_LONG_POLL, EMBER_AF_OK_TO_SLEEP, &emberAfLevelControlClusterServerTickCallbackControl2 }, + +#endif // __AF_GEN_EVENT__ + From 9383f24d14980d05df7439a7c4e9a53dcc9cbe86 Mon Sep 17 00:00:00 2001 From: "restyled-io[bot]" <32688539+restyled-io[bot]@users.noreply.github.com> Date: Wed, 6 Apr 2022 10:28:14 -0700 Subject: [PATCH 6/6] Restyle add attribute change callback hook for speaker endpoint (#16945) * Restyled by whitespace * Restyled by gn Co-authored-by: Restyled.io --- examples/tv-app/linux/BUILD.gn | 2 +- zzz_generated/tv-app/zap-generated/af-gen-event.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/tv-app/linux/BUILD.gn b/examples/tv-app/linux/BUILD.gn index 4b494411c035cd..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", @@ -72,7 +73,6 @@ executable("chip-tv-app") { "include/wake-on-lan/WakeOnLanManager.cpp", "include/wake-on-lan/WakeOnLanManager.h", "main.cpp", - "ZclCallbacks.cpp", ] deps = [ 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 7ec2a044571b6b..d82ed718c3efbd 100644 --- a/zzz_generated/tv-app/zap-generated/af-gen-event.h +++ b/zzz_generated/tv-app/zap-generated/af-gen-event.h @@ -79,4 +79,3 @@ { 0x2, 0x8, false, EMBER_AF_LONG_POLL, EMBER_AF_OK_TO_SLEEP, &emberAfLevelControlClusterServerTickCallbackControl2 }, #endif // __AF_GEN_EVENT__ -