Imported Upstream version 1.0.0
[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 (*TWInitCompleteCallback)(bool status);
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(const char* deviceDevPath);
145
146 /**
147  *
148  * Initiates necessary operations to find ZigBee devices.
149  *
150  */
151 OCStackResult TWDiscover();
152
153 /**
154  *
155  * Gets a value at the specified parameters.
156  *
157  * @param[in] extendedUniqueId The extended unique id of the device.
158  * @param[in] nodeId The node id of the device.
159  * @param[in] endpointId The endpoint id from which the attribute belongs.
160  * @param[in] clusterId The cluster id from which the attribute belongs.
161  * @param[in] attributeId The attribute id from which the attribute belongs.
162  * @param[out] outValue The value at the specified attribute.
163  * @param[out] outValueLength The length of the value.
164  *
165  */
166 OCStackResult TWGetAttribute(char* extendedUniqueId, char* nodeId, char* endpointId,
167                              char* clusterId, char* attributeId,
168                              char** outValue, uint8_t* outValueLength);
169
170 /**
171  *
172  * Sets a value at the specified parameters.
173  *
174  * @param[in] extendedUniqueId The extended unique id of the device.
175  * @param[in] nodeId The node id of the device.
176  * @param[in] endpointId The endpoint id from which the attribute belongs.
177  * @param[in] clusterId The cluster id from which the attribute belongs.
178  * @param[in] attributeId The attribute id from which the attribute belongs.
179  * @param[in] attributeType The attribute type of the attribute.
180  * @param[in] newValue The value to set at the specified attribute.
181  *
182  */
183 OCStackResult TWSetAttribute(char* extendedUniqueId, char* nodeId, char* endpointId,
184                              char* clusterId, char* attributeId, char* attributeType,
185                              char* newValue);
186
187 /**
188  *
189  * Switches a device to On/Off.
190  *
191  * @param[in] nodeId The node id of the device.
192  * @param[in] endpointId The endpoint id from which the attribute belongs.
193  * @param[in] newState Use "0" for OFF, "1" for ON, NULL for toggling.
194  *
195  */
196 OCStackResult TWSwitchOnOff(char* nodeId, char* endpointId, char* newState);
197
198 /**
199  *
200  * Move to a level. All parameters are null-terminated.
201  *
202  * @param[in] nodeId The node id of the device.
203  * @param[in] endpointId The endpoint id from which the attribute belongs.
204  * @param[in] onOfState A boolean type number represents if the command
205  *                      is used with On/Off. If it is set to 0, it means the command is
206  *                      implemented as Move to Level command. If it is set to 1, it
207  *                      means the command will be implemented Move to Level
208  *                      (with On/Off) command.
209  *
210  * @param[in] level The The meaning of ‘level’ is device dependent
211  *                  e.g. for a light it may mean brightness level.
212  *
213  * @param[in] transTime The time taken to move to the new level
214  *
215  */
216 OCStackResult TWMoveToLevel(char* nodeId, char* endpointId,
217                             char* onOffState, char* level, char* transTime);
218
219 /**
220  *
221  * Switches door lock state.
222  *
223  * @param[in] nodeId The node id of the device.
224  * @param[in] endpointId The endpoint id from which the attribute belongs.
225  * @param[in] newState Use "0" to Unlock, "1" to Lock ON.
226  *
227  */
228 OCStackResult TWSwitchDoorLockState(char* nodeId, char* endpointId, char* newState);
229
230 /**
231  *
232  * Move Color Temperature
233  *
234  * @param[in] nodeId The node id of the device.
235  * @param[in] endpointId The endpoint id from which the attribute belongs.
236  * @param[in] colorTemperature 16 bit hexadecimal number.
237  * @param[in] transTime The time taken to move to the new level.
238  *
239  */
240 OCStackResult TWColorMoveToColorTemperature(char* nodeId, char* endpointId,
241                                             char* colorTemperature, char* transTime);
242
243 /**
244  *
245  * Sets discovery callback.
246  * This callback will be called when TWDiscover() discovers ZigBee device(s).
247  *
248  */
249 OCStackResult TWSetDiscoveryCallback(const TWDeviceFoundCallback callback);
250 /**
251  *
252  * Sets status update callback.
253  * This callback will be called when there is an update on remote ZigBee devices.
254  *
255  */
256 OCStackResult TWSetStatusUpdateCallback(TWDeviceStatusUpdateCallback callback);
257
258 /**
259  *
260  * Attempts to listen to status change updates of a remote zone device.
261  * A callback TWEnrollSucceedCallback will be invoked when this registration is fulfill.
262  * @param[in] nodeId The node id of the remote zone device.
263  * @param[in] endpointId The node id of the remote zone device.
264  *
265  *
266  */
267 OCStackResult TWListenForStatusUpdates(char* nodeId, char* endpointId);
268
269 /**
270  *
271  * Process TWEntry.
272  *
273  */
274 OCStackResult TWProcess();
275
276 /**
277  *
278  * Uninitializes the Telegesis module.
279  *
280  */
281 OCStackResult TWUninitialize();
282
283
284 #ifdef __cplusplus
285 }
286 #endif // __cplusplus
287
288 #endif /* TELEGESISWRAPPER_H_ */