3 * Copyright (c) 2020 Project CHIP Authors
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 * Copyright (c) 2020 Silicon Labs
22 * Licensed under the Apache License, Version 2.0 (the "License");
23 * you may not use this file except in compliance with the License.
24 * You may obtain a copy of the License at
26 * http://www.apache.org/licenses/LICENSE-2.0
28 * Unless required by applicable law or agreed to in writing, software
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
37 * @brief Routines for the ZLL Level Control Server plugin.
38 *******************************************************************************
40 * <b>Copyright 2018 Silicon Laboratories Inc.
42 *******************************************************************************
44 * The licensor of this software is Silicon
45 * Laboratories Inc. Your use of this software is
46 * governed by the terms of Silicon Labs Master
47 * Software License Agreement (MSLA) available at
48 * www.silabs.com/about-us/legal/master-software-license-agreement.
49 * This software is distributed to you in Source Code
50 * format and is governed by the sections of the MSLA
51 * applicable to Source Code.
53 ******************************************************************************/
55 #include "zll-level-control-server.h"
56 #include "../../include/af.h"
58 EmberAfStatus emberAfPluginZllLevelControlServerMoveToLevelWithOnOffZllExtensions(const EmberAfClusterCommand * cmd)
60 bool globalSceneControl = true;
61 EmberAfStatus status = emberAfWriteServerAttribute(cmd->apsFrame->destinationEndpoint, ZCL_ON_OFF_CLUSTER_ID,
62 ZCL_GLOBAL_SCENE_CONTROL_ATTRIBUTE_ID, (uint8_t *) &globalSceneControl,
63 ZCL_BOOLEAN_ATTRIBUTE_TYPE);
64 if (status != EMBER_ZCL_STATUS_SUCCESS)
66 emberAfLevelControlClusterPrintln("ERR: writing global scene control %x", status);
71 bool emberAfPluginZllLevelControlServerIgnoreMoveToLevelMoveStepStop(uint8_t endpoint, uint8_t commandId)
73 // If a MoveToLevel, Move, Step, or Stop command is received while the device
74 // is in its off state (i.e., the OnOff attribute of the On/Off cluster is
75 // equal to false), the command shall be ignored.
77 #ifdef ZCL_USING_ON_OFF_CLUSTER_SERVER
78 if ((commandId == ZCL_MOVE_TO_LEVEL_COMMAND_ID || commandId == ZCL_MOVE_COMMAND_ID || commandId == ZCL_STEP_COMMAND_ID ||
79 commandId == ZCL_STOP_COMMAND_ID) &&
80 emberAfContainsServer(endpoint, ZCL_ON_OFF_CLUSTER_ID))
82 EmberAfStatus status =
83 emberAfReadServerAttribute(endpoint, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &onOff, sizeof(onOff));
84 if (status != EMBER_ZCL_STATUS_SUCCESS)
86 emberAfLevelControlClusterPrintln("ERR: reading on/off %x", status);