07dcd2edd4d66a628a1dd36d09dc03f9617562b7
[platform/core/api/zigbee.git] / include / zigbee_private.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef __TIZEN_CAPI_NETWORK_ZIGBEE_PRIVATE_H__
17 #define __TIZEN_CAPI_NETWORK_ZIGBEE_PRIVATE_H__
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 #include <tizen_type.h>
24
25 #include <zigbee.h>
26 #include <zigbee-zdo_internal.h>
27 #include <zigbee-zcl_internal.h>
28
29 /**
30  * @file zigbee_private.h
31  */
32
33 /**
34  * @ingroup CAPI_NETWORK_ZIGBEE_MODULE
35  * @brief The events for zb_event_cb().
36  *
37  * @since_tizen 4.0
38  */
39 typedef enum {
40         ZB_ZDP_UPDATED_NETWORK_NOTIFICATION_EVENT = 0x06, /**< A device updated its network information */
41         ZB_ZDP_BIND_RSP_EVENT = 0x07, /**< Binding end-points result */
42         ZB_ZDP_UNBIND_RSP_EVENT = 0x08, /**< Unbinding end-points result */
43         ZB_ZCL_GLOBAL_ATTRIBUTE_REPORT_EVENT = 0x11, /**< This event is took place when report attribute command is received */
44         ZB_ZCL_ALARM_EVENT = 0x20, /**< Events related to alarm cluster */
45         ZB_ZCL_LEVEL_CONTROL_CURRENT_LEVEL_ATTRIBUTE_REPORT_EVENT = 0x30, /**< This event will be received after level control cluster attribute changed */
46         ZB_ZCL_COLOR_CONTROL_CURRENT_X_ATTRIBUTE_REPORT_EVENT = 0x31, /**< This event will be received after color control cluster X attribute changed */
47         ZB_ZCL_COLOR_CONTROL_CURRENT_Y_ATTRIBUTE_REPORT_EVENT = 0x32, /**< This event will be received after color control cluster Y attribute changed */
48         ZB_ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_REPORT_EVENT = 0x33, /**< This event will be received after color control cluster hue attribute changed */
49         ZB_ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_REPORT_EVENT = 0x34, /**< This event will be received after color control cluster saturation attribute changed */
50         ZB_ZCL_COLOR_CONTROL_CURRENT_TEMPERATURE_ATTRIBUTE_REPORT_EVENT = 0x35, /**< This event will be received after color control cluster temperature attribute changed */
51         ZB_ZCL_DOOR_LOCK_OPERATIONAL_NOTIFICATION_EVENT = 0x40, /**< This event is received when door-lock operation has been finished */
52         ZB_ZCL_DOOR_LOCK_PROGRAMING_NOTIFICATION_EVENT = 0x41, /**< This event is received when door-lock programming has been changed */
53         ZB_ZCL_SIMPLE_METERING_REMOVE_MIRROR_EVENT = 0x51, /**< This event is used to request the ESP to remove its mirror of Metering */
54         ZB_ZCL_SIMPLE_METERING_REQUEST_MIRROR_EVENT = 0x52, /**< This event is used to request the ESP to mirror Metering Device data */
55 } zb_event_ext_e;
56
57 /**
58  * @brief Called after getting end-device information.
59  *
60  * @since_tizen 4.0
61  *
62  * @remarks The @a child should not be released.
63  * The @a child can be used only in the callback. To use outside, make a copy
64  *
65  * @param[out] index nth child
66  * @param[out] child handle of a end-device
67  * @param[out] user_data user data
68  *
69  * @return #ZIGBEE_FUNC_CONTINUE to continue iteration, otherwise #ZIGBEE_FUNC_STOP to stop iteration.
70  * @retval #ZIGBEE_FUNC_CONTINUE Continue iteration
71  * @retval #ZIGBEE_FUNC_STOP Stop iteration
72  *
73  * @pre The callback must be registered when using zb_devices_info_foreach_end_device()
74  *
75  * @see zb_foreach_end_dev_info()
76  */
77 typedef bool (*zb_end_dev_info_cb)(int index, zb_end_dev_info_h child, void *user_data);
78
79 /**
80  * @brief Calls a function for each children end-point of parent.
81  *
82  * @since_tizen 4.0
83  * @privlevel public
84  * @privilege %http://tizen.org/privilege/zigbee
85  *
86  * @param[in] list handle of end-devices parent
87  * @param[in] cb zb_end_dev_info_cb()
88  * @param[in] user_data user data
89  *
90  * @return 0 on success, otherwise a negative error value.
91  * @retval #ZIGBEE_ERROR_NONE Successful
92  * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
93  * @retval #ZIGBEE_ERROR_PERMISSION_DENIED Permission denied
94  * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported
95  *
96  * @see zb_end_dev_info_cb()
97  */
98 int zb_foreach_end_dev_info(zb_end_dev_info_h *list,
99                 zb_end_dev_info_cb cb, void *user_data);
100
101
102 /**
103  * @brief Gets the records of the received global command.
104  * @since_tizen 4.0
105  *
106  * @remarks The returned records are managed by the platform and will be released when
107  * caller's stack is released
108  * @remarks The returned records is a variable or a set of variables that represent the
109  * functional state of the cluster. The records are characterized by a name, data type,
110  * range, access type (read/write), and report ability. Attributes are defined to be
111  * mandatory/ optional per cluster. (see more #zb_zcl_global_rec_data_s.)
112  *
113  * @param[in] ev Event data structure
114  * @param[out] records Set of attributes
115  * @param[out] count The number of attributes
116  *
117  * @return 0 on success, otherwise a negative error value.
118  * @retval #ZIGBEE_ERROR_NONE Successful
119  * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
120  * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported
121  *
122  */
123 int zb_ev_get_global_attr_report_records(zb_event_data_h ev,
124         zb_zcl_attr_report_h* records, unsigned char *count);
125
126 /**
127  * @brief Gets the alarm count.
128  * @since_tizen 4.0
129  *
130  * @param[in] ev Event data structure
131  * @param[out] count Alarm count
132  *
133  * @return 0 on success, otherwise a negative error value.
134  * @retval #ZIGBEE_ERROR_NONE Successful
135  * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
136  * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported
137  *
138  */
139 int zb_ev_get_alarm_count(zb_event_data_h ev, unsigned short* count);
140
141 /**
142  * @platform
143  * @internal
144  * @brief Resets chip for the zigbee transceiver.
145  * @details If the Zigbee transceiver works abnormally, this function do HW reset.
146  *
147  * @since_tizen 4.0
148  * @privlevel platform
149  * @privilege %http://tizen.org/privilege/zigbee.admin
150  *
151  * @param[in] handle The handle of zigbee
152  *
153  * @return 0 on success, otherwise a negative error value.
154  * @retval #ZIGBEE_ERROR_NONE Successful
155  * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
156  * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error
157  * @retval #ZIGBEE_ERROR_PERMISSION_DENIED Permission denied
158  * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported
159  *
160  */
161 int zb_hw_reset(zb_zigbee_h handle);
162
163 /**
164  * @platform
165  * @internal
166  * @brief Switches channel when an occupied channel is noisy.
167  * @details When noisy, do energy scan and active scan to switch operational channel.
168  *
169  * @since_tizen 4.0
170  * @privlevel platform
171  * @privilege %http://tizen.org/privilege/zigbee.admin
172  *
173  * @param[in] handle The handle of zigbee
174  * @param[in] channel target channel number to switch
175  *
176  * @return 0 on success, otherwise a negative error value.
177  * @retval #ZIGBEE_ERROR_NONE Successful
178  * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
179  * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error
180  * @retval #ZIGBEE_ERROR_PERMISSION_DENIED Permission denied
181  *
182  * @see zb_coex_stop()
183  *
184  */
185 int zb_coex_start(zb_zigbee_h handle, unsigned char channel);
186
187 /**
188  * @platform
189  * @internal
190  * @brief Stops channel switching operation.
191  * @details Halt current operation related to channel switching.
192  *
193  * @since_tizen 4.0
194  * @privlevel platform
195  * @privilege %http://tizen.org/privilege/zigbee.admin
196  *
197  * @param[in] handle The handle of zigbee
198  *
199  * @return 0 on success, otherwise a negative error value.
200  * @retval #ZIGBEE_ERROR_NONE Successful
201  * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
202  * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error
203  * @retval #ZIGBEE_ERROR_PERMISSION_DENIED Permission denied
204  *
205  * @see zb_coex_start()
206  *
207  */
208 int zb_coex_stop(zb_zigbee_h handle);
209
210 /**
211  * @platform
212  * @internal
213  * @brief Sets start-up attribute set.
214  * @details In order to ensure interoperability, all ZigBee HA devices should implement
215  * compatible Startup Attribute Sets (SAS). This does not mean that set must be
216  * modifiable through a commissioning cluster, but that the device must internally
217  * implement these stack settings to ensure compatibility and consistent user
218  * experience. The start up set parameters described by the Commissioning cluster
219  * provide a good basis to specify a HA startup set.
220  *
221  * @since_tizen 4.0
222  * @privlevel platform
223  * @privilege %http://tizen.org/privilege/zigbee.admin
224  *
225  * @param[in] handle The handle of zigbee
226  * @param[in] pan_id Short address
227  * @param[in] epan_id Usually 00-50-C2-77-10-00-00-00 is the global commissioning EPID
228  * @param[in] channel_mask Channel mask
229  * @param[in] start_control Start control
230  * @param[in] trust_center_addr Trust center addr
231  * @param[in] master_key Master key
232  * @param[in] master_key_len Master key length
233  * @param[in] network_key Network key
234  * @param[in] network_key_len Network key length
235  * @param[in] default_link_key_join Default link key join
236  *
237  * @return 0 on success, otherwise a negative error value.
238  * @retval #ZIGBEE_ERROR_NONE Successful
239  * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
240  * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error
241  * @retval #ZIGBEE_ERROR_PERMISSION_DENIED Permission denied
242  * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported
243  */
244 int zb_zdo_set_compatible_startup_parameters(
245                 zb_zigbee_h handle,
246                 zb_nwk_addr pan_id,
247                 zb_ieee_addr epan_id,
248                 unsigned int channel_mask,
249                 unsigned char start_control,
250                 zb_ieee_addr trust_center_addr,
251                 const unsigned char *master_key,
252                 unsigned char master_key_len,
253                 const unsigned char *network_key,
254                 unsigned char network_key_len,
255                 unsigned char default_link_key_join);
256
257
258 #ifdef __cplusplus
259 }
260 #endif
261
262 #endif /* __TIZEN_CAPI_NETWORK_ZIGBEE_PRIVATE_H__ */