Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / app / clusters / scenes / scenes.h
1 /**
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *
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
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 /**
19  *
20  *    Copyright (c) 2020 Silicon Labs
21  *
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
25  *
26  *        http://www.apache.org/licenses/LICENSE-2.0
27  *
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.
33  */
34 /****************************************************************************
35  * @file
36  * @brief Definitions for the Scenes plugin.
37  *******************************************************************************
38  ******************************************************************************/
39
40 #pragma once
41
42 #include <app/util/af-types.h>
43 #include <stdint.h>
44
45 EmberAfStatus emberAfScenesSetSceneCountAttribute(chip::EndpointId endpoint, uint8_t newCount);
46 EmberAfStatus emberAfScenesMakeValid(chip::EndpointId endpoint, uint8_t sceneId, chip::GroupId groupId);
47
48 // DEPRECATED.
49 #define emberAfScenesMakeInvalid emberAfScenesClusterMakeInvalidCallback
50
51 void emAfPluginScenesServerPrintInfo(void);
52
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))
71 #else
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)
80 #endif // Use tokens
81
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);
85
86 /** @brief Scenes Cluster Recall Saved Scene
87  *
88  * This function is called by the framework when the application should recall a
89  * saved scene.
90  *
91  * @param endpoint The endpoint.  Ver.: always
92  * @param groupId The group identifier.  Ver.: always
93  * @param sceneId The scene identifier.  Ver.: always
94  */
95 EmberAfStatus emberAfScenesClusterRecallSavedSceneCallback(chip::EndpointId endpoint, chip::GroupId groupId, uint8_t sceneId);
96
97 /** @brief Scenes Cluster Store Current Scene
98  *
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
103  * possible.
104  *
105  * @param endpoint The endpoint.  Ver.: always
106  * @param groupId The group identifier.  Ver.: always
107  * @param sceneId The scene identifier.  Ver.: always
108  */
109 EmberAfStatus emberAfScenesClusterStoreCurrentSceneCallback(chip::EndpointId endpoint, chip::GroupId groupId, uint8_t sceneId);
110
111 /** @brief Scenes Cluster Remove Scenes In Group
112  *
113  * This function removes the scenes from a specified group.
114  *
115  * @param endpoint Endpoint  Ver.: always
116  * @param groupId Group ID  Ver.: always
117  */
118 void emberAfScenesClusterRemoveScenesInGroupCallback(chip::EndpointId endpoint, chip::GroupId groupId);
119
120 /** @brief Scenes Cluster Make Invalid
121  *
122  * This function is called to invalidate the valid attribute in the Scenes
123  * cluster.
124  *
125  * @param endpoint   Ver.: always
126  */
127 EmberAfStatus emberAfScenesClusterMakeInvalidCallback(chip::EndpointId endpoint);