1 //******************************************************************
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 * This API only works with:
30 #ifndef TELEGESISWRAPPER_H_
31 #define TELEGESISWRAPPER_H_
46 * Defines a cluster id.
51 char clusterId[SIZE_CLUSTERID];
56 * Defines a list of ZigBee device's clusters.
61 TWClusterId* clusterIds;
67 * Defines an endpoint of a ZigBee device.
72 char endpointId[SIZE_ENDPOINTID];
73 TWClusterList* clusterList;
78 * Defines a list of endpoints of a ZigBee device.
83 TWEndpoint* endpoints;
89 * Defines a discovered ZigBee device.
95 char nodeId[SIZE_NODEID];
96 TWEndpoint* endpointOfInterest;
101 * Defines a ZigBee device list.
106 TWDevice* deviceList;
112 * Defines a ZigBee device update.
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
127 char zoneId[SIZE_ZONEID];
128 char zoneType[SIZE_ZONETYPE];
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);
139 * Initializes the Telegesis module.
141 * @param[in] deviceDevPath The device path at which this Telegesis module exists.
144 OCStackResult TWInitialize(const char* deviceDevPath);
148 * Initiates necessary operations to find ZigBee devices.
151 OCStackResult TWDiscover();
155 * Gets a value at the specified parameters.
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.
166 OCStackResult TWGetAttribute(char* extendedUniqueId, char* nodeId, char* endpointId,
167 char* clusterId, char* attributeId,
168 char** outValue, uint8_t* outValueLength);
172 * Sets a value at the specified parameters.
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.
183 OCStackResult TWSetAttribute(char* extendedUniqueId, char* nodeId, char* endpointId,
184 char* clusterId, char* attributeId, char* attributeType,
189 * Switches a device to On/Off.
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.
196 OCStackResult TWSwitchOnOff(char* nodeId, char* endpointId, char* newState);
200 * Move to a level. All parameters are null-terminated.
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.
210 * @param[in] level The The meaning of ‘level’ is device dependent
211 * e.g. for a light it may mean brightness level.
213 * @param[in] transTime The time taken to move to the new level
216 OCStackResult TWMoveToLevel(char* nodeId, char* endpointId,
217 char* onOffState, char* level, char* transTime);
221 * Switches door lock state.
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.
228 OCStackResult TWSwitchDoorLockState(char* nodeId, char* endpointId, char* newState);
232 * Move Color Temperature
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.
240 OCStackResult TWColorMoveToColorTemperature(char* nodeId, char* endpointId,
241 char* colorTemperature, char* transTime);
245 * Sets discovery callback.
246 * This callback will be called when TWDiscover() discovers ZigBee device(s).
249 OCStackResult TWSetDiscoveryCallback(const TWDeviceFoundCallback callback);
253 * Sets end device's nodeId changed callback.
254 * This callback will be called when there is a NodeId change for a remote ZigBee device.
257 OCStackResult TWSetEndDeviceNodeIdChangedCallback(TWDeviceNodeIdChangedCallback callback);
261 * Sets status update callback.
262 * This callback will be called when there is an update on remote ZigBee devices.
265 OCStackResult TWSetStatusUpdateCallback(TWDeviceStatusUpdateCallback callback);
269 * Attempts to listen to status change updates of a remote zone device.
270 * A callback TWEnrollSucceedCallback will be invoked when this registration is fulfill.
271 * @param[in] nodeId The node id of the remote zone device.
272 * @param[in] endpointId The node id of the remote zone device.
276 OCStackResult TWListenForStatusUpdates(char* nodeId, char* endpointId);
283 OCStackResult TWProcess();
287 * Uninitializes the Telegesis module.
290 OCStackResult TWUninitialize();
295 #endif // __cplusplus
297 #endif /* TELEGESISWRAPPER_H_ */