Fix custom cluster to meet zigbee-daemon GDbus interface
[platform/core/api/zigbee.git] / include / zb-custom.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_NETWORK_ZIGBEE_CUSTOM_H__
17 #define __TIZEN_NETWORK_ZIGBEE_CUSTOM_H__
18
19 /**
20  * @file zb-custom.h
21  */
22
23 /**
24  * @ingroup CAPI_NETWORK_ZIGBEE_MODULE
25  * @defgroup CAPI_NETWORK_ZIGBEE_CUSTOM_MODULE ZigBee Custom Commands
26  *
27  * @brief zigbee provides API for custom command.
28  *
29  * @section CAPI_NETWORK_ZIGBEE_CUSTOM_MODULE_HEADER Header
30  *  \#include <zigbee.h>
31  *
32  * @section CAPI_NETWORK_ZIGBEE_CUSTOM_MODULE_OVERVIEW Overview
33  * This API set consists of ZigBee custom command API
34  *
35  * @{
36  */
37
38 /**
39  * @brief The response of custom command function
40  *
41  * @since_tizen 3.0
42  *
43  * @param[out] addr16 Network address
44  * @param[out] src_ep source end-point (ex. 1)
45  * @param[out] dst_ep destination end-point (ex. 1)
46  * @param[out] cluster_id ZCL cluster id
47  * @param[out] profile_id Profile id
48  * @param[out] payload_len Length of payload
49  * @param[out] payload Payload data
50  * @param[out] user_data User data
51  *
52  * @see zb_aps_send()
53  */
54 typedef void (*zb_aps_send_rsp)(
55                 nwk_addr addr16,
56                 unsigned char src_ep,
57                 unsigned char dst_ep,
58                 unsigned short cluster_id,
59                 unsigned short profile_id,
60                 unsigned short payload_len,
61                 unsigned char *payload,
62                 void *user_data);
63
64 /**
65  * @brief The response of custom command function
66  *
67  * @since_tizen 3.0
68  *
69  * @param[out] addr16 Network address
70  * @param[out] src_ep source end-point (ex. 1)
71  * @param[out] dst_ep destination end-point (ex. 1)
72  * @param[out] cluster_id ZCL cluster id
73  * @param[out] profile_id Profile id
74  * @param[out] payload_len Length of payload
75  * @param[out] payload Payload data
76  * @param[out] user_data User data
77  *
78  * @see zb_zcl_send()
79  */
80 typedef void (*zb_zcl_send_rsp)(
81                 nwk_addr addr16,
82                 unsigned char src_ep,
83                 unsigned char dst_ep,
84                 unsigned short cluster_id,
85                 unsigned short profile_id,
86                 unsigned short payload_len,
87                 unsigned char *payload,
88                 void *user_data);
89
90 /**
91  * @brief The response of custom command function
92  *
93  * @since_tizen 3.0
94  *
95  * @param[out] length The length of data
96  * @param[out] data Received data
97  * @param[out] user_data User data
98  *
99  * @see zb_send_to_local()
100  */
101 typedef void (*zb_send_to_local_rsp)(
102                 unsigned short length,
103                 unsigned char *data,
104                 void *user_data);
105
106 /**
107  * @brief Send custom data
108  *
109  * @since_tizen 3.0
110  *
111  * @param[in] handle Handle of node descriptor
112  * @param[in] addr16 Network address
113  * @param[in] aps_frame_ctl APS Frame control bits. \n
114  *            - Delivery Mode : \n
115  *            #ZB_APS_DELIVERY_UNICAST \n
116  *            #ZB_APS_DELIVERY_INDIRECT \n
117  *            #ZB_APS_DELIVERY_BROADCAST \n
118  *            #ZB_APS_DELIVERY_MULTICAST \n
119  *            - ACK Request : \n
120  *            #ZB_APS_NO_ACK_REQUEST \n
121  *            #ZB_APS_ACK_REQUEST
122  * @param[in] src_ep source end-point (ex. 1)
123  * @param[in] dst_ep destination end-point (ex. 1)
124  * @param[in] cluster_id ZCL cluster id
125  * @param[in] profile_id Profile id
126  * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n
127  *            Only OR operation is allowed in ZCL header \n
128  *            - Frame Type : \n
129  *            #ZB_ZCL_FC_GLOBALLY_USED (default) \n
130  *            #ZB_APS_FC_CLUSTER_SPECIFIC \n
131  *            - Manufacturer Specific : \n
132  *            - Direction : \n
133  *            #ZB_ZCL_CLIENT_TO_SERVER (default) \n
134  *            #ZB_ZCL_SERVER_TO_CLIENT \n
135  *            - Disable Default Response : \n
136  *            #ZB_ZCL_LEAVE_WELL_ALONE (default) \n
137  *            #ZB_ZCL_DISABLE_DEFAULT_RESPONSE
138  * @param[in] mfg_code Manufacturer Code
139  * @param[in] cmd_id Command ID
140  * @param[in] payload_len Length of payload
141  * @param[in] payload Payload data
142  * @param[in] cb Callback function to get response.
143  * @param[in] user_data User data to be received from callback function.
144  *
145  * @return 0 on success, otherwise a negative error value.
146  * @retval #ZIGBEE_ERROR_NONE Successful
147  * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
148  * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error
149  *
150  * @see zb_aps_send_rsp()
151  */
152 int zb_aps_send(
153                 zigbee_h handle,
154                 nwk_addr addr16,
155                 unsigned char aps_frame_ctl,
156                 unsigned char src_ep,
157                 unsigned char dst_ep,
158                 unsigned short cluster_id,
159                 unsigned short profile_id,
160                 unsigned char zcl_frame_ctl,
161                 unsigned short mfg_code,
162                 unsigned char cmd_id,
163                 unsigned short payload_len,
164                 unsigned char *payload,
165                 zb_aps_send_rsp cb,
166                 void *user_data);
167
168 /**
169  * @brief Send custom data
170  *
171  * @since_tizen 3.0
172  *
173  * @param[in] handle Handle of node descriptor
174  * @param[in] addr16 Network address
175  * @param[in] src_ep source end-point (ex. 1)
176  * @param[in] dst_ep destination end-point (ex. 1)
177  * @param[in] cluster_id ZCL cluster id
178  * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n
179  *            Only OR operation is allowed in ZCL header \n
180  *            - Frame Type : \n
181  *            #ZB_ZCL_FC_GLOBALLY_USED (default) \n
182  *            #ZB_APS_FC_CLUSTER_SPECIFIC \n
183  *            - Manufacturer Specific : \n
184  *            - Direction : \n
185  *            #ZB_ZCL_CLIENT_TO_SERVER (default) \n
186  *            #ZB_ZCL_SERVER_TO_CLIENT \n
187  *            - Disable Default Response : \n
188  *            #ZB_ZCL_LEAVE_WELL_ALONE (default) \n
189  *            #ZB_ZCL_DISABLE_DEFAULT_RESPONSE
190  * @param[in] cmd APL Command
191  * @param[in] payload_len Length of payload
192  * @param[in] payload Payload data
193  * @param[in] cb Callback function to get response.
194  * @param[in] user_data User data to be received from callback function.
195  *
196  * @return 0 on success, otherwise a negative error value.
197  * @retval #ZIGBEE_ERROR_NONE Successful
198  * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
199  * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error
200  *
201  * @see zb_zcl_send_rsp()
202  */
203 int zb_zcl_send(
204                 zigbee_h handle,
205                 nwk_addr addr16,
206                 unsigned char src_ep,
207                 unsigned char dst_ep,
208                 unsigned short cluster_id,
209                 unsigned char zcl_frame_ctl,
210                 unsigned char cmd,
211                 unsigned short payload_len,
212                 unsigned char *payload,
213                 zb_zcl_send_rsp cb,
214                 void *user_data);
215
216 /**
217  * @brief Send custom data
218  *
219  * @since_tizen 3.0
220  *
221  * @param[in] handle handle of node descriptor
222  * @param[in] length The length of data
223  * @param[in] data Data to send
224  * @param[in] cb Callback function to get response.
225  * @param[in] user_data User data to be received from callback function.
226  *
227  * @return 0 on success, otherwise a negative error value.
228  * @retval #ZIGBEE_ERROR_NONE Successful
229  * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter
230  * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error
231  *
232  * @see zb_send_to_local_rsp()
233  */
234 int zb_send_to_local(
235                 zigbee_h handle,
236                 unsigned short length,
237                 unsigned char *data,
238                 zb_send_to_local_rsp cb,
239                 void *user_data);
240
241 /**
242  * @}
243  */
244
245 #endif /* __TIZEN_NETWORK_ZIGBEE_CUSTOM_H__ */