af25e70502c4dbab6d907cd502a8d68780f5beb2
[platform/upstream/iotivity.git] / plugins / zigbee_wrapper / telegesis_wrapper / include / telegesis_wrapper.h
1 //******************************************************************
2 //
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 /**
22  * @file
23  *
24  * This API only works with:
25  *      Telegesis ETRX357
26  *      CICIE R310 B110615
27  *
28  */
29
30 #ifndef TELEGESISWRAPPER_H_
31 #define TELEGESISWRAPPER_H_
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif // __cplusplus
36
37 #include "octypes.h"
38 #include "twtypes.h"
39
40 #include <stdint.h>
41 #include <time.h>
42 #include <stdbool.h>
43
44 /**
45  *
46  * Defines a cluster id.
47  *
48  */
49 typedef struct
50 {
51     char clusterId[SIZE_CLUSTERID];
52 } TWClusterId;
53
54 /**
55  *
56  * Defines a list of ZigBee device's clusters.
57  *
58  */
59 typedef struct
60 {
61     TWClusterId* clusterIds;
62     int count;
63 } TWClusterList;
64
65 /**
66  *
67  * Defines an endpoint of a ZigBee device.
68  *
69  */
70 typedef struct
71 {
72     char endpointId[SIZE_ENDPOINTID];
73     TWClusterList* clusterList;
74 } TWEndpoint;
75
76 /**
77  *
78  * Defines a list of endpoints of a ZigBee device.
79  *
80  */
81 typedef struct
82 {
83     TWEndpoint* endpoints;
84     int count;
85 } TWEndpointList;
86
87 /**
88  *
89  * Defines a discovered ZigBee device.
90  *
91  */
92 typedef struct
93 {
94     char eui[SIZE_EUI];
95     char nodeId[SIZE_NODEID];
96     TWEndpoint* endpointOfInterest;
97 } TWDevice;
98
99 /**
100  *
101  * Defines a ZigBee device list.
102  *
103  */
104 typedef struct
105 {
106     TWDevice* deviceList;
107     int count;
108 } TWDeviceList;
109
110 /**
111  *
112  * Defines a ZigBee device update.
113  *
114  */
115 typedef struct
116 {
117     char nodeId[SIZE_NODEID];
118     char endpoint[SIZE_ENDPOINTID];
119     char status[SIZE_ZONESTATUS];
120     char extendedStatus[SIZE_ZONESTATUS_EXTENDED];
121     char zoneId[SIZE_ZONEID];               //optional
122     char delay[SIZE_UPDATE_DELAY_TIME];     //optional - amount of time in quarter of seconds
123 } TWUpdate;
124
125 typedef struct
126 {
127     char zoneId[SIZE_ZONEID];
128     char zoneType[SIZE_ZONETYPE];
129     char eui[SIZE_EUI];
130 } TWEnrollee;
131
132 typedef void (*TWDeviceFoundCallback)(TWDevice* device);
133 typedef void (*TWEnrollmentSucceedCallback)(TWEnrollee* enrollee);
134 typedef void (*TWDeviceStatusUpdateCallback)(TWUpdate* update);
135 typedef void (*TWDeviceNodeIdChangedCallback)(const char* eui, const char* nodeId);
136
137 /**
138  *
139  * Initializes the Telegesis module.
140  *
141  * @param[in] deviceDevPath The device path at which this Telegesis module exists.
142  *
143  */
144 OCStackResult TWInitialize(PIPlugin_Zigbee* plugin, const char* deviceDevPath);
145
146 /**
147  *
148  * Initiates necessary operations to find ZigBee devices.
149  * @param[in] plugin The plugin instance to operate with.
150  *
151  */
152 OCStackResult TWDiscover(PIPlugin_Zigbee* plugin);
153
154 /**
155  *
156  * Gets a value at the specified parameters.
157  *
158  * @param[in] extendedUniqueId The extended unique id of the device.
159  * @param[in] nodeId The node id of the device.
160  * @param[in] endpointId The endpoint id from which the attribute belongs.
161  * @param[in] clusterId The cluster id from which the attribute belongs.
162  * @param[in] attributeId The attribute id from which the attribute belongs.
163  * @param[out] outValue The value at the specified attribute.
164  * @param[out] outValueLength The length of the value.
165  * @param[in] plugin The plugin instance to operate with.
166  *
167  */
168 OCStackResult TWGetAttribute(char* extendedUniqueId, char* nodeId, char* endpointId,
169                              char* clusterId, char* attributeId,
170                              char** outValue, uint8_t* outValueLength,
171                              PIPlugin_Zigbee* plugin);
172
173 /**
174  *
175  * Sets a value at the specified parameters.
176  *
177  * @param[in] extendedUniqueId The extended unique id of the device.
178  * @param[in] nodeId The node id of the device.
179  * @param[in] endpointId The endpoint id from which the attribute belongs.
180  * @param[in] clusterId The cluster id from which the attribute belongs.
181  * @param[in] attributeId The attribute id from which the attribute belongs.
182  * @param[in] attributeType The attribute type of the attribute.
183  * @param[in] newValue The value to set at the specified attribute.
184  * @param[in] plugin The plugin instance to operate with.
185  *
186  */
187 OCStackResult TWSetAttribute(char* extendedUniqueId, char* nodeId, char* endpointId,
188                              char* clusterId, char* attributeId, char* attributeType,
189                              char* newValue, PIPlugin_Zigbee* plugin);
190
191 /**
192  *
193  * Switches a device to On/Off.
194  *
195  * @param[in] nodeId The node id of the device.
196  * @param[in] endpointId The endpoint id from which the attribute belongs.
197  * @param[in] newState Use "0" for OFF, "1" for ON, NULL for toggling.
198  * @param[in] plugin The plugin instance to operate with.
199  *
200  */
201 OCStackResult TWSwitchOnOff(char* nodeId, char* endpointId, char* newState,
202                             PIPlugin_Zigbee* plugin);
203
204 /**
205  *
206  * Move to a level. All parameters are null-terminated.
207  *
208  * @param[in] nodeId The node id of the device.
209  * @param[in] endpointId The endpoint id from which the attribute belongs.
210  * @param[in] onOfState A boolean type number represents if the command
211  *                      is used with On/Off. If it is set to 0, it means the command is
212  *                      implemented as Move to Level command. If it is set to 1, it
213  *                      means the command will be implemented Move to Level
214  *                      (with On/Off) command.
215  *
216  * @param[in] level The The meaning of ‘level’ is device dependent
217  *                  e.g. for a light it may mean brightness level.
218  *
219  * @param[in] transTime The time taken to move to the new level.
220  * @param[in] plugin The plugin instance to operate with.
221  *
222  */
223 OCStackResult TWMoveToLevel(char* nodeId, char* endpointId,
224                             char* onOffState, char* level, char* transTime,
225                             PIPlugin_Zigbee* plugin);
226
227 /**
228  *
229  * Switches door lock state.
230  *
231  * @param[in] nodeId The node id of the device.
232  * @param[in] endpointId The endpoint id from which the attribute belongs.
233  * @param[in] newState Use "0" to Unlock, "1" to Lock ON.
234  * @param[in] plugin The plugin instance to operate with.
235  *
236  */
237 OCStackResult TWSwitchDoorLockState(char* nodeId, char* endpointId, char* newState,
238                                     PIPlugin_Zigbee* plugin);
239
240 /**
241  *
242  * Move Color Temperature
243  *
244  * @param[in] nodeId The node id of the device.
245  * @param[in] endpointId The endpoint id from which the attribute belongs.
246  * @param[in] colorTemperature 16 bit hexadecimal number.
247  * @param[in] transTime The time taken to move to the new level.
248  * @param[in] plugin The plugin instance to operate with.
249  *
250  */
251 OCStackResult TWColorMoveToColorTemperature(char* nodeId, char* endpointId,
252                                             char* colorTemperature, char* transTime,
253                                             PIPlugin_Zigbee* plugin);
254
255 /**
256  *
257  * Sets discovery callback.
258  * This callback will be called when TWDiscover() discovers ZigBee device(s).
259  *
260  */
261 OCStackResult TWSetDiscoveryCallback(const TWDeviceFoundCallback callback,
262                                      PIPlugin_Zigbee* plugin);
263
264 /**
265  *
266  * Sets end device's nodeId changed callback.
267  * This callback will be called when there is a NodeId change for a remote ZigBee device.
268  *
269  */
270 OCStackResult TWSetEndDeviceNodeIdChangedCallback(TWDeviceNodeIdChangedCallback callback,
271                                                   PIPlugin_Zigbee* plugin);
272
273 /**
274  *
275  * Sets status update callback.
276  * This callback will be called when there is an update on remote ZigBee devices.
277  *
278  */
279 OCStackResult TWSetStatusUpdateCallback(TWDeviceStatusUpdateCallback callback,
280                                         PIPlugin_Zigbee* plugin);
281
282 /**
283  *
284  * Attempts to listen to status change updates of a remote zone device.
285  * A callback TWEnrollSucceedCallback will be invoked when this registration is fulfill.
286  * @param[in] nodeId The node id of the remote zone device.
287  * @param[in] endpointId The node id of the remote zone device.
288  * @param[in] plugin The plugin instance to operate with.
289  *
290  *
291  */
292 OCStackResult TWListenForStatusUpdates(char* nodeId, char* endpointId, PIPlugin_Zigbee* plugin);
293
294 /**
295  *
296  * Process TWEntry.
297  * @param[in] plugin The plugin instance to operate with.
298  *
299  */
300 OCStackResult TWProcess(PIPlugin_Zigbee* plugin);
301
302 /**
303  *
304  * Uninitializes the Telegesis module.
305  * @param[in] plugin The plugin instance to operate with.
306  *
307  */
308 OCStackResult TWUninitialize(PIPlugin_Zigbee* plugin);
309
310
311 #ifdef __cplusplus
312 }
313 #endif // __cplusplus
314
315 #endif /* TELEGESISWRAPPER_H_ */