diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback.h b/examples/all-clusters-app/all-clusters-common/gen/callback.h index 96d14087b5e8ed..abb2c4fa3a9520 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback.h +++ b/examples/all-clusters-app/all-clusters-common/gen/callback.h @@ -2552,16 +2552,6 @@ bool emberAfScenesClusterViewSceneResponseCallback(uint8_t status, uint16_t grou /** @name On/off Cluster Callbacks */ // @{ -/** @brief On/off Cluster Level Control Effect - * - * This is called by the framework when the on/off cluster initiates a command - * that must effect a level control change. The implementation assumes that the - * client will handle any effect on the On/Off Cluster. - * - * @param endpoint Ver.: always - * @param newValue Ver.: always - */ -void emberAfOnOffClusterLevelControlEffectCallback(uint8_t endpoint, bool newValue); /** @brief On/off Cluster Client Attribute Changed * * Client Attribute Changed @@ -2774,16 +2764,6 @@ void emberAfOnOffClusterServerTickCallback(uint8_t endpoint); */ bool emberAfOnOffClusterToggleCallback(void); -/** @brief On/off Cluster Set Value - * - * This function is called when the on/off value needs to be set, either through - * normal channels or as a result of a level change. - * - * @param endpoint Ver.: always - * @param command Ver.: always - * @param initiatedByLevelChange Ver.: always - */ -EmberAfStatus emberAfOnOffClusterSetValueCallback(uint8_t endpoint, uint8_t command, bool initiatedByLevelChange); /** @brief On/off Cluster Server Post Init * * Following resolution of the On/Off state at startup for this endpoint, perform any diff --git a/examples/lighting-app/lighting-common/gen/callback-stub.cpp b/examples/lighting-app/lighting-common/gen/callback-stub.cpp index 6f82d3b02c3825..3025daa90d8ed3 100644 --- a/examples/lighting-app/lighting-common/gen/callback-stub.cpp +++ b/examples/lighting-app/lighting-common/gen/callback-stub.cpp @@ -830,17 +830,6 @@ bool emberAfKeyEstablishmentCallback(EmberAfKeyEstablishmentNotifyMessage status return true; } -/** @brief On/off Cluster Level Control Effect - * - * This is called by the framework when the on/off cluster initiates a command - * that must effect a level control change. The implementation assumes that the - * client will handle any effect on the On/Off Cluster. - * - * @param endpoint Ver.: always - * @param newValue Ver.: always - */ -void emberAfOnOffClusterLevelControlEffectCallback(uint8_t endpoint, bool newValue) {} - /** @brief Main Init * * This function is called from the application's main function. It gives the @@ -1481,24 +1470,6 @@ void emberAfSetSourceRouteOverheadCallback(EmberNodeId destination, uint8_t over */ void emberAfSetTimeCallback(uint32_t utcTime) {} -// Ifdef out emberAfOnOffClusterSetValueCallback, since it's implemented by -// on-off.c -#if 0 -/** @brief On/off Cluster Set Value - * - * This function is called when the on/off value needs to be set, either through - * normal channels or as a result of a level change. - * - * @param endpoint Ver.: always - * @param command Ver.: always - * @param initiatedByLevelChange Ver.: always - */ -EmberAfStatus emberAfOnOffClusterSetValueCallback(uint8_t endpoint, uint8_t command, bool initiatedByLevelChange) -{ - return EMBER_ZCL_STATUS_UNSUP_CLUSTER_COMMAND; -} -#endif - /** @brief Set Wake Timeout Bitmask * * This function is only useful to sleepy end devices. This function will set diff --git a/examples/lighting-app/lighting-common/gen/callback.h b/examples/lighting-app/lighting-common/gen/callback.h index 41af18f8a7e92d..3dc2dfb413cb84 100644 --- a/examples/lighting-app/lighting-common/gen/callback.h +++ b/examples/lighting-app/lighting-common/gen/callback.h @@ -2551,17 +2551,6 @@ bool emberAfScenesClusterViewSceneResponseCallback(uint8_t status, uint16_t grou /** @name On/off Cluster Callbacks */ // @{ - -/** @brief On/off Cluster Level Control Effect - * - * This is called by the framework when the on/off cluster initiates a command - * that must effect a level control change. The implementation assumes that the - * client will handle any effect on the On/Off Cluster. - * - * @param endpoint Ver.: always - * @param newValue Ver.: always - */ -void emberAfOnOffClusterLevelControlEffectCallback(uint8_t endpoint, bool newValue); /** @brief On/off Cluster Client Attribute Changed * * Client Attribute Changed @@ -2773,16 +2762,6 @@ void emberAfOnOffClusterServerTickCallback(uint8_t endpoint); * */ bool emberAfOnOffClusterToggleCallback(void); -/** @brief On/off Cluster Set Value - * - * This function is called when the on/off value needs to be set, either through - * normal channels or as a result of a level change. - * - * @param endpoint Ver.: always - * @param command Ver.: always - * @param initiatedByLevelChange Ver.: always - */ -EmberAfStatus emberAfOnOffClusterSetValueCallback(uint8_t endpoint, uint8_t command, bool initiatedByLevelChange); /** @brief On/off Cluster Server Post Init * * Following resolution of the On/Off state at startup for this endpoint, perform any diff --git a/examples/lock-app/lock-common/gen/callback-stub.cpp b/examples/lock-app/lock-common/gen/callback-stub.cpp index da4b5bbf881cc2..fc817347e342bf 100644 --- a/examples/lock-app/lock-common/gen/callback-stub.cpp +++ b/examples/lock-app/lock-common/gen/callback-stub.cpp @@ -831,17 +831,6 @@ bool emberAfKeyEstablishmentCallback(EmberAfKeyEstablishmentNotifyMessage status return true; } -/** @brief On/off Cluster Level Control Effect - * - * This is called by the framework when the on/off cluster initiates a command - * that must effect a level control change. The implementation assumes that the - * client will handle any effect on the On/Off Cluster. - * - * @param endpoint Ver.: always - * @param newValue Ver.: always - */ -void emberAfOnOffClusterLevelControlEffectCallback(uint8_t endpoint, bool newValue) {} - /** @brief Main Init * * This function is called from the application's main function. It gives the @@ -1482,24 +1471,6 @@ void emberAfSetSourceRouteOverheadCallback(EmberNodeId destination, uint8_t over */ void emberAfSetTimeCallback(uint32_t utcTime) {} -// Ifdef out emberAfOnOffClusterSetValueCallback, since it's implemented by -// on-off.c -#if 0 -/** @brief On/off Cluster Set Value - * - * This function is called when the on/off value needs to be set, either through - * normal channels or as a result of a level change. - * - * @param endpoint Ver.: always - * @param command Ver.: always - * @param initiatedByLevelChange Ver.: always - */ -EmberAfStatus emberAfOnOffClusterSetValueCallback(uint8_t endpoint, uint8_t command, bool initiatedByLevelChange) -{ - return EMBER_ZCL_STATUS_UNSUP_CLUSTER_COMMAND; -} -#endif - /** @brief Set Wake Timeout Bitmask * * This function is only useful to sleepy end devices. This function will set diff --git a/examples/lock-app/lock-common/gen/callback.h b/examples/lock-app/lock-common/gen/callback.h index 41af18f8a7e92d..a1536acce5cfc7 100644 --- a/examples/lock-app/lock-common/gen/callback.h +++ b/examples/lock-app/lock-common/gen/callback.h @@ -2552,16 +2552,6 @@ bool emberAfScenesClusterViewSceneResponseCallback(uint8_t status, uint16_t grou /** @name On/off Cluster Callbacks */ // @{ -/** @brief On/off Cluster Level Control Effect - * - * This is called by the framework when the on/off cluster initiates a command - * that must effect a level control change. The implementation assumes that the - * client will handle any effect on the On/Off Cluster. - * - * @param endpoint Ver.: always - * @param newValue Ver.: always - */ -void emberAfOnOffClusterLevelControlEffectCallback(uint8_t endpoint, bool newValue); /** @brief On/off Cluster Client Attribute Changed * * Client Attribute Changed @@ -2773,16 +2763,6 @@ void emberAfOnOffClusterServerTickCallback(uint8_t endpoint); * */ bool emberAfOnOffClusterToggleCallback(void); -/** @brief On/off Cluster Set Value - * - * This function is called when the on/off value needs to be set, either through - * normal channels or as a result of a level change. - * - * @param endpoint Ver.: always - * @param command Ver.: always - * @param initiatedByLevelChange Ver.: always - */ -EmberAfStatus emberAfOnOffClusterSetValueCallback(uint8_t endpoint, uint8_t command, bool initiatedByLevelChange); /** @brief On/off Cluster Server Post Init * * Following resolution of the On/Off state at startup for this endpoint, perform any diff --git a/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp b/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp index eddd3bb751d1dd..e9beb992dd376a 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp +++ b/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp @@ -823,17 +823,6 @@ bool emberAfKeyEstablishmentCallback(EmberAfKeyEstablishmentNotifyMessage status return true; } -/** @brief On/off Cluster Level Control Effect - * - * This is called by the framework when the on/off cluster initiates a command - * that must effect a level control change. The implementation assumes that the - * client will handle any effect on the On/Off Cluster. - * - * @param endpoint Ver.: always - * @param newValue Ver.: always - */ -void emberAfOnOffClusterLevelControlEffectCallback(uint8_t endpoint, bool newValue) {} - /** @brief Main Init * * This function is called from the application's main function. It gives the @@ -1486,20 +1475,6 @@ void emberAfSetSourceRouteOverheadCallback(EmberNodeId destination, uint8_t over */ void emberAfSetTimeCallback(uint32_t utcTime) {} -/** @brief On/off Cluster Set Value - * - * This function is called when the on/off value needs to be set, either through - * normal channels or as a result of a level change. - * - * @param endpoint Ver.: always - * @param command Ver.: always - * @param initiatedByLevelChange Ver.: always - */ -EmberAfStatus emberAfOnOffClusterSetValueCallback(uint8_t endpoint, uint8_t command, bool initiatedByLevelChange) -{ - return EMBER_ZCL_STATUS_UNSUP_CLUSTER_COMMAND; -} - /** @brief Set Wake Timeout Bitmask * * This function is only useful to sleepy end devices. This function will set diff --git a/examples/temperature-measurement-app/esp32/main/gen/callback.h b/examples/temperature-measurement-app/esp32/main/gen/callback.h index ba9c08fb78f478..aedb5bde80200e 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/callback.h +++ b/examples/temperature-measurement-app/esp32/main/gen/callback.h @@ -2537,16 +2537,6 @@ bool emberAfScenesClusterViewSceneResponseCallback(uint8_t status, uint16_t grou /** @name On/off Cluster Callbacks */ // @{ -/** @brief On/off Cluster Level Control Effect - * - * This is called by the framework when the on/off cluster initiates a command - * that must effect a level control change. The implementation assumes that the - * client will handle any effect on the On/Off Cluster. - * - * @param endpoint Ver.: always - * @param newValue Ver.: always - */ -void emberAfOnOffClusterLevelControlEffectCallback(uint8_t endpoint, bool newValue); /** @brief On/off Cluster Client Attribute Changed * * Client Attribute Changed @@ -2758,16 +2748,6 @@ void emberAfOnOffClusterServerTickCallback(uint8_t endpoint); * */ bool emberAfOnOffClusterToggleCallback(void); -/** @brief On/off Cluster Set Value - * - * This function is called when the on/off value needs to be set, either through - * normal channels or as a result of a level change. - * - * @param endpoint Ver.: always - * @param command Ver.: always - * @param initiatedByLevelChange Ver.: always - */ -EmberAfStatus emberAfOnOffClusterSetValueCallback(uint8_t endpoint, uint8_t command, bool initiatedByLevelChange); /** @} END On/off Cluster Callbacks */ diff --git a/src/app/clusters/level-control/level-control.cpp b/src/app/clusters/level-control/level-control.cpp index d00366965d9d64..a78d488fdcdb9d 100644 --- a/src/app/clusters/level-control/level-control.cpp +++ b/src/app/clusters/level-control/level-control.cpp @@ -52,6 +52,10 @@ #include #endif // EMBER_AF_PLUGIN_SCENES +#ifdef EMBER_AF_PLUGIN_ON_OFF +#include +#endif // EMBER_AF_PLUGIN_ON_OFF + #ifdef EMBER_AF_PLUGIN_ZLL_LEVEL_CONTROL_SERVER #include "app/framework/plugin/zll-level-control-server/zll-level-control-server.h" #endif // EMBER_AF_PLUGIN_ZLL_LEVEL_CONTROL_SERVER @@ -302,11 +306,13 @@ static void writeRemainingTime(EndpointId endpoint, uint16_t remainingTimeMs) static void setOnOffValue(EndpointId endpoint, bool onOff) { +#ifdef EMBER_AF_PLUGIN_ON_OFF if (emberAfContainsServer(endpoint, ZCL_ON_OFF_CLUSTER_ID)) { emberAfLevelControlClusterPrintln("Setting on/off to %p due to level change", onOff ? "ON" : "OFF"); emberAfOnOffClusterSetValueCallback(endpoint, (onOff ? ZCL_ON_COMMAND_ID : ZCL_OFF_COMMAND_ID), true); } +#endif // EMBER_AF_PLUGIN_ON_OFF } static bool shouldExecuteIfOff(EndpointId endpoint, uint8_t commandId, uint8_t optionMask, uint8_t optionOverride) diff --git a/src/app/clusters/on-off-server/on-off.cpp b/src/app/clusters/on-off-server/on-off.cpp index 73e97c23ebdfe2..db3f2e9438bdf5 100644 --- a/src/app/clusters/on-off-server/on-off.cpp +++ b/src/app/clusters/on-off-server/on-off.cpp @@ -38,6 +38,7 @@ *implements the On-Off server cluster. ******************************************************************************* ******************************************************************************/ +#include "on-off.h" #include "af.h" diff --git a/src/app/clusters/on-off-server/on-off.h b/src/app/clusters/on-off-server/on-off.h new file mode 100644 index 00000000000000..a1aa1d3b37fa47 --- /dev/null +++ b/src/app/clusters/on-off-server/on-off.h @@ -0,0 +1,43 @@ +/* + * + * 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. + */ + +#pragma once + +#include +#include + +/** @brief On/off Cluster Set Value + * + * This function is called when the on/off value needs to be set, either through + * normal channels or as a result of a level change. + * + * @param endpoint Ver.: always + * @param command Ver.: always + * @param initiatedByLevelChange Ver.: always + */ +EmberAfStatus emberAfOnOffClusterSetValueCallback(CHIPEndpointId endpoint, uint8_t command, bool initiatedByLevelChange); + +/** @brief On/off Cluster Level Control Effect + * + * This is called by the framework when the on/off cluster initiates a command + * that must effect a level control change. The implementation assumes that the + * client will handle any effect on the On/Off Cluster. + * + * @param endpoint Ver.: always + * @param newValue Ver.: always + */ +void emberAfOnOffClusterLevelControlEffectCallback(CHIPEndpointId endpoint, bool newValue);