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.
34 /****************************************************************************
36 * @brief Definitions for the Scenes plugin.
37 *******************************************************************************
38 ******************************************************************************/
42 #include <app/util/af-types.h>
45 EmberAfStatus emberAfScenesSetSceneCountAttribute(chip::EndpointId endpoint, uint8_t newCount);
46 EmberAfStatus emberAfScenesMakeValid(chip::EndpointId endpoint, uint8_t sceneId, chip::GroupId groupId);
49 #define emberAfScenesMakeInvalid emberAfScenesClusterMakeInvalidCallback
51 void emAfPluginScenesServerPrintInfo(void);
53 extern uint8_t emberAfPluginScenesServerEntriesInUse;
54 #if defined(EMBER_AF_PLUGIN_SCENES_USE_TOKENS) && !defined(EZSP_HOST)
55 // In this case, we use token storage
56 #define emberAfPluginScenesServerRetrieveSceneEntry(entry, i) halCommonGetIndexedToken(&entry, TOKEN_SCENES_TABLE, i)
57 #define emberAfPluginScenesServerSaveSceneEntry(entry, i) halCommonSetIndexedToken(TOKEN_SCENES_TABLE, i, &entry)
58 #define emberAfPluginScenesServerNumSceneEntriesInUse() \
59 (halCommonGetToken(&emberAfPluginScenesServerEntriesInUse, TOKEN_SCENES_NUM_ENTRIES), emberAfPluginScenesServerEntriesInUse)
60 #define emberAfPluginScenesServerSetNumSceneEntriesInUse(x) \
61 (emberAfPluginScenesServerEntriesInUse = (x), \
62 halCommonSetToken(TOKEN_SCENES_NUM_ENTRIES, &emberAfPluginScenesServerEntriesInUse))
63 #define emberAfPluginScenesServerIncrNumSceneEntriesInUse() \
64 ((halCommonGetToken(&emberAfPluginScenesServerEntriesInUse, TOKEN_SCENES_NUM_ENTRIES), \
65 ++emberAfPluginScenesServerEntriesInUse), \
66 halCommonSetToken(TOKEN_SCENES_NUM_ENTRIES, &emberAfPluginScenesServerEntriesInUse))
67 #define emberAfPluginScenesServerDecrNumSceneEntriesInUse() \
68 ((halCommonGetToken(&emberAfPluginScenesServerEntriesInUse, TOKEN_SCENES_NUM_ENTRIES), \
69 --emberAfPluginScenesServerEntriesInUse), \
70 halCommonSetToken(TOKEN_SCENES_NUM_ENTRIES, &emberAfPluginScenesServerEntriesInUse))
72 // Use normal RAM storage
73 extern EmberAfSceneTableEntry emberAfPluginScenesServerSceneTable[];
74 #define emberAfPluginScenesServerRetrieveSceneEntry(entry, i) (entry = emberAfPluginScenesServerSceneTable[i])
75 #define emberAfPluginScenesServerSaveSceneEntry(entry, i) (emberAfPluginScenesServerSceneTable[i] = entry)
76 #define emberAfPluginScenesServerNumSceneEntriesInUse() (emberAfPluginScenesServerEntriesInUse)
77 #define emberAfPluginScenesServerSetNumSceneEntriesInUse(x) (emberAfPluginScenesServerEntriesInUse = (x))
78 #define emberAfPluginScenesServerIncrNumSceneEntriesInUse() (++emberAfPluginScenesServerEntriesInUse)
79 #define emberAfPluginScenesServerDecrNumSceneEntriesInUse() (--emberAfPluginScenesServerEntriesInUse)
82 bool emberAfPluginScenesServerParseAddScene(const EmberAfClusterCommand * cmd, chip::GroupId groupId, uint8_t sceneId,
83 uint16_t transitionTime, uint8_t * sceneName, uint8_t * extensionFieldSets);
84 bool emberAfPluginScenesServerParseViewScene(const EmberAfClusterCommand * cmd, chip::GroupId groupId, uint8_t sceneId);
86 /** @brief Scenes Cluster Recall Saved Scene
88 * This function is called by the framework when the application should recall a
91 * @param endpoint The endpoint. Ver.: always
92 * @param groupId The group identifier. Ver.: always
93 * @param sceneId The scene identifier. Ver.: always
95 EmberAfStatus emberAfScenesClusterRecallSavedSceneCallback(chip::EndpointId endpoint, chip::GroupId groupId, uint8_t sceneId);
97 /** @brief Scenes Cluster Store Current Scene
99 * This function is called by the framework when the application should store
100 * the current scene. If an entry already exists in the scene table with the
101 * same scene and group ids, the application should update the entry with the
102 * current scene. Otherwise, a new entry should be adde to the scene table, if
105 * @param endpoint The endpoint. Ver.: always
106 * @param groupId The group identifier. Ver.: always
107 * @param sceneId The scene identifier. Ver.: always
109 EmberAfStatus emberAfScenesClusterStoreCurrentSceneCallback(chip::EndpointId endpoint, chip::GroupId groupId, uint8_t sceneId);
111 /** @brief Scenes Cluster Remove Scenes In Group
113 * This function removes the scenes from a specified group.
115 * @param endpoint Endpoint Ver.: always
116 * @param groupId Group ID Ver.: always
118 void emberAfScenesClusterRemoveScenesInGroupCallback(chip::EndpointId endpoint, chip::GroupId groupId);
120 /** @brief Scenes Cluster Make Invalid
122 * This function is called to invalidate the valid attribute in the Scenes
125 * @param endpoint Ver.: always
127 EmberAfStatus emberAfScenesClusterMakeInvalidCallback(chip::EndpointId endpoint);