Skip to content

Commit

Permalink
Move OnOff Cluster Specific callbacks from gen/callback* to src/app/o…
Browse files Browse the repository at this point in the history
…n-off-server (#3803)
  • Loading branch information
vivien-apple authored and pull[bot] committed Nov 24, 2020
1 parent 4bfe7fc commit 1587500
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 164 deletions.
20 changes: 0 additions & 20 deletions examples/all-clusters-app/all-clusters-common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
29 changes: 0 additions & 29 deletions examples/lighting-app/lighting-common/gen/callback-stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
21 changes: 0 additions & 21 deletions examples/lighting-app/lighting-common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
29 changes: 0 additions & 29 deletions examples/lock-app/lock-common/gen/callback-stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 0 additions & 20 deletions examples/lock-app/lock-common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 0 additions & 20 deletions examples/temperature-measurement-app/esp32/main/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */

Expand Down
6 changes: 6 additions & 0 deletions src/app/clusters/level-control/level-control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
#include <app/clusters/scenes/scenes.h>
#endif // EMBER_AF_PLUGIN_SCENES

#ifdef EMBER_AF_PLUGIN_ON_OFF
#include <app/clusters/on-off-server/on-off.h>
#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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/app/clusters/on-off-server/on-off.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*implements the On-Off server cluster.
*******************************************************************************
******************************************************************************/
#include "on-off.h"

#include "af.h"

Expand Down
43 changes: 43 additions & 0 deletions src/app/clusters/on-off-server/on-off.h
Original file line number Diff line number Diff line change
@@ -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 <app/util/af-types.h>
#include <app/util/basic-types.h>

/** @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);

0 comments on commit 1587500

Please sign in to comment.