2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "zb-common.h"
20 API int zb_zdo_nwk_addr_req(zb_zigbee_h handle, zb_ieee_addr addr64,
21 zb_zdp_req_type_e request_type, unsigned char start_idx, zb_zdo_addr_cb cb,
25 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
26 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
27 RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
28 RETV_IF(NULL == addr64, ZIGBEE_ERROR_INVALID_PARAMETER);
29 RETV_IF(0 != request_type && 1 != request_type, ZIGBEE_ERROR_INVALID_PARAMETER);
30 RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER);
31 ret = zbl_nwk_addr_req(handle, addr64, request_type, start_idx, cb,
36 API int zb_zdo_ieee_addr_req(zb_zigbee_h handle, zb_nwk_addr addr16, zb_zdo_addr_cb cb,
40 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
41 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
42 RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
43 RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER);
44 ret = zbl_ieee_addr_req(handle, addr16, cb, user_data);
48 API int zb_zdo_active_ep(zb_zigbee_h handle, zb_nwk_addr addr16, zb_zdo_active_ep_cb cb,
52 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
53 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
54 RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
55 RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER);
56 ret = zbl_active_ep(handle, addr16, cb, user_data);
60 API int zb_zdo_simple_desc_req(zb_zigbee_h handle, zb_nwk_addr addr16, unsigned char ep,
61 zb_zdo_simple_desc_cb cb, void *user_data)
64 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
65 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
66 RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
67 RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT);
68 RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER);
69 ret = zbl_simple_desc_req(handle, addr16, ep, cb, user_data);
73 API int zb_zdo_extended_simple_desc_req(zb_zigbee_h handle, zb_nwk_addr addr16,
74 unsigned char start_idx, zb_zdo_extended_simple_desc_cb cb, void *user_data)
76 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
77 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
78 RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
79 RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER);
80 return ZIGBEE_ERROR_NONE;
83 API int zb_zdo_match_desc_req(zb_zigbee_h handle, zb_nwk_addr addr16,
84 unsigned short profileid, unsigned char num_in_clusters,
85 unsigned short *in_clusters, unsigned char num_out_clusters,
86 unsigned short *out_clusters, zb_zdo_match_desc_cb cb, void *user_data)
89 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
90 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
91 RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
92 RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
93 RETV_IF(NULL == in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER);
94 RETV_IF(NULL == out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER);
95 RETV_IF(0 == num_in_clusters && 0 == num_out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER);
96 RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER);
97 ret = zbl_match_desc_req(handle, addr16, profileid, num_in_clusters,
98 in_clusters, num_out_clusters, out_clusters, cb, user_data);
102 API int zb_zdo_node_desc_req(zb_zigbee_h handle, zb_nwk_addr addr16,
103 zb_zdo_node_desc_cb cb, void *user_data)
106 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
107 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
108 RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
109 RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
110 RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER);
111 ret = zbl_node_desc_req(addr16, cb, user_data);
115 API int zb_zdo_power_desc_req(zb_zigbee_h handle, zb_nwk_addr addr16,
116 zb_zdo_power_desc_cb cb, void *user_data)
119 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
120 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
121 RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
122 RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
123 RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER);
124 ret = zbl_power_desc_req(addr16, cb, user_data);
128 API int zb_zdo_complex_desc_req(zb_zigbee_h handle, zb_nwk_addr addr16,
129 zb_zdo_complex_desc_cb cb, void *user_data)
132 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
133 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
134 RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
135 RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
136 RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER);
137 ret = zbl_complex_desc_req(addr16, cb, user_data);
141 API int zb_zdo_user_desc_req(zb_zigbee_h handle, zb_nwk_addr addr16,
142 zb_zdo_user_desc_cb cb, void *user_data)
145 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
146 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
147 RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
148 RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
149 RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER);
150 ret = zbl_user_desc_req(addr16, cb, user_data);
154 API int zb_zdo_user_desc_set(zb_zigbee_h handle, zb_nwk_addr addr16, unsigned char len,
155 unsigned char *user_desc, zb_zdo_user_desc_conf_cb cb, void *user_data)
158 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
159 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
160 RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
161 RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS);
162 RETV_IF(NULL == user_desc, ZIGBEE_ERROR_INVALID_PARAMETER);
163 ret = zbl_user_desc_set(handle, addr16, len, user_desc, cb, user_data);
167 API int zb_zdo_device_annce(zb_zigbee_h handle, zb_nwk_addr addr16, zb_ieee_addr addr64,
168 unsigned char capability)
171 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
172 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
173 RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR);
174 RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS);
175 ret = zbl_device_annce(handle, addr16, addr64, capability);
179 API int zb_simple_desc_create(zb_zdo_simple_desc_h *handle)
181 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
182 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
183 zb_zdo_simple_desc_h desc = NULL;
184 CHECK_ZIGBEE_PRIVILEGE();
186 desc = calloc(1, sizeof(struct zb_zdo_simple_desc_s));
187 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
189 return ZIGBEE_ERROR_NONE;
192 API int zb_simple_desc_clone(zb_zdo_simple_desc_h src, zb_zdo_simple_desc_h *dst)
194 zb_zdo_simple_desc_h desc = NULL;
196 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
197 RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER);
198 RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER);
200 desc = calloc(1, sizeof(struct zb_zdo_simple_desc_s));
201 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
203 memcpy(desc, src, sizeof(struct zb_zdo_simple_desc_s));
206 return ZIGBEE_ERROR_NONE;
209 API int zb_simple_desc_destroy(zb_zdo_simple_desc_h handle)
211 struct zb_zdo_simple_desc_s *h = handle;
212 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
213 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
216 return ZIGBEE_ERROR_NONE;
219 API int zb_simple_desc_get_ep(zb_zdo_simple_desc_h handle, unsigned char *ep)
221 struct zb_zdo_simple_desc_s *h = handle;
222 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
223 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
224 RETV_IF(NULL == ep, ZIGBEE_ERROR_INVALID_PARAMETER);
227 return ZIGBEE_ERROR_NONE;
230 API int zb_simple_desc_set_ep(zb_zdo_simple_desc_h handle, unsigned char ep)
232 struct zb_zdo_simple_desc_s *h = handle;
233 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
234 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
237 return ZIGBEE_ERROR_NONE;
240 API int zb_simple_desc_get_profile_id(zb_zdo_simple_desc_h handle,
241 unsigned short *profileid)
243 struct zb_zdo_simple_desc_s *h = handle;
244 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
245 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
246 RETV_IF(NULL == profileid, ZIGBEE_ERROR_INVALID_PARAMETER);
248 *profileid = h->profileid;
249 return ZIGBEE_ERROR_NONE;
252 API int zb_simple_desc_set_profile_id(zb_zdo_simple_desc_h handle,
253 unsigned short profileid)
255 struct zb_zdo_simple_desc_s *h = handle;
256 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
257 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
259 h->profileid = profileid;
260 return ZIGBEE_ERROR_NONE;
264 API int zb_simple_desc_get_device_id(zb_zdo_simple_desc_h handle,
265 unsigned short *deviceid)
267 struct zb_zdo_simple_desc_s *h = handle;
268 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
269 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
270 RETV_IF(NULL == deviceid, ZIGBEE_ERROR_INVALID_PARAMETER);
272 *deviceid = h->deviceid;
273 return ZIGBEE_ERROR_NONE;
276 API int zb_simple_desc_set_device_id(zb_zdo_simple_desc_h handle,
277 unsigned short deviceid)
279 struct zb_zdo_simple_desc_s *h = handle;
280 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
281 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
283 h->deviceid = deviceid;
284 return ZIGBEE_ERROR_NONE;
287 API int zb_simple_desc_get_device_ver(zb_zdo_simple_desc_h handle,
288 unsigned short *device_ver)
290 struct zb_zdo_simple_desc_s *h = handle;
291 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
292 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
293 RETV_IF(NULL == device_ver, ZIGBEE_ERROR_INVALID_PARAMETER);
295 *device_ver = h->device_ver;
296 return ZIGBEE_ERROR_NONE;
299 API int zb_simple_desc_set_device_ver(zb_zdo_simple_desc_h handle,
300 unsigned short device_ver)
302 struct zb_zdo_simple_desc_s *h = handle;
303 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
304 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
306 h->device_ver = device_ver;
307 return ZIGBEE_ERROR_NONE;
310 API int zb_simple_desc_get_num_of_in_clusters(zb_zdo_simple_desc_h handle,
311 unsigned char *num_of_in_clusters)
313 struct zb_zdo_simple_desc_s *h = handle;
314 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
315 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
316 RETV_IF(NULL == num_of_in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER);
318 *num_of_in_clusters = h->num_of_in_clusters;
319 return ZIGBEE_ERROR_NONE;
322 API int zb_simple_desc_set_num_of_in_clusters(zb_zdo_simple_desc_h handle,
323 unsigned char num_of_in_clusters)
325 struct zb_zdo_simple_desc_s *h = handle;
326 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
327 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
329 h->num_of_in_clusters = num_of_in_clusters;
330 return ZIGBEE_ERROR_NONE;
333 API int zb_simple_desc_get_num_of_out_clusters(zb_zdo_simple_desc_h handle,
334 unsigned char *num_of_out_clusters)
336 struct zb_zdo_simple_desc_s *h = handle;
337 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
338 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
339 RETV_IF(NULL == num_of_out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER);
341 *num_of_out_clusters = h->num_of_out_clusters;
342 return ZIGBEE_ERROR_NONE;
345 API int zb_simple_desc_set_num_of_out_clusters(zb_zdo_simple_desc_h handle,
346 unsigned char num_of_out_clusters)
348 struct zb_zdo_simple_desc_s *h = handle;
349 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
350 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
352 h->num_of_out_clusters = num_of_out_clusters;
353 return ZIGBEE_ERROR_NONE;
356 API int zb_simple_desc_get_in_clusters(zb_zdo_simple_desc_h handle,
357 unsigned short **in_clusters)
359 struct zb_zdo_simple_desc_s *h = handle;
360 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
361 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
362 RETV_IF(NULL == h->in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER);
363 RETV_IF(NULL == in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER);
365 *in_clusters = h->in_clusters;
366 return ZIGBEE_ERROR_NONE;
369 API int zb_simple_desc_set_in_clusters(zb_zdo_simple_desc_h handle,
370 unsigned short *in_clusters, int num)
372 struct zb_zdo_simple_desc_s *h = handle;
373 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
374 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
375 RETV_IF(NULL == in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER);
376 RETV_IF(num < 1 || num > MAX_ENDPOINT_CLUSTERS, ZIGBEE_ERROR_INVALID_PARAMETER);
378 memcpy(h->in_clusters, in_clusters, 2 * num);
379 return ZIGBEE_ERROR_NONE;
382 API int zb_simple_desc_get_out_clusters(zb_zdo_simple_desc_h handle,
383 unsigned short **out_clusters)
385 struct zb_zdo_simple_desc_s *h = handle;
386 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
387 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
388 RETV_IF(NULL == h->out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER);
389 RETV_IF(NULL == out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER);
391 *out_clusters = h->out_clusters;
392 return ZIGBEE_ERROR_NONE;
395 API int zb_simple_desc_set_out_clusters(zb_zdo_simple_desc_h handle,
396 unsigned short *out_clusters, int num)
398 struct zb_zdo_simple_desc_s *h = handle;
399 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
400 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
401 RETV_IF(NULL == out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER);
402 RETV_IF(num < 1 || num > MAX_ENDPOINT_CLUSTERS, ZIGBEE_ERROR_INVALID_PARAMETER);
404 memcpy(h->out_clusters, out_clusters, 2 * num);
405 return ZIGBEE_ERROR_NONE;
408 API int zb_node_power_desc_create(zb_zdo_node_power_descriptor_h *handle)
410 zb_zdo_node_power_descriptor_h desc = NULL;
412 CHECK_ZIGBEE_PRIVILEGE();
413 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
414 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
416 desc = calloc(1, sizeof(struct zb_zdo_node_power_descriptor_s));
417 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
420 return ZIGBEE_ERROR_NONE;
423 API int zb_node_power_desc_clone(zb_zdo_node_power_descriptor_h src,
424 zb_zdo_node_power_descriptor_h *dst)
426 zb_zdo_node_power_descriptor_h desc = NULL;
428 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
429 RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER);
430 RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER);
432 desc = calloc(1, sizeof(struct zb_zdo_node_power_descriptor_s));
433 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
435 memcpy(desc, src, sizeof(struct zb_zdo_node_power_descriptor_s));
438 return ZIGBEE_ERROR_NONE;
441 API int zb_node_power_desc_destroy(zb_zdo_node_power_descriptor_h handle)
443 struct zb_zdo_node_power_descriptor_s* h = handle;
444 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
445 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
448 return ZIGBEE_ERROR_NONE;
451 API int zb_node_power_desc_get_current_power_mode(
452 zb_zdo_node_power_descriptor_h handle, zb_zdp_cur_pwr_mode_e* current_power_mode)
454 struct zb_zdo_node_power_descriptor_s* h = handle;
455 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
456 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
457 RETV_IF(NULL == current_power_mode, ZIGBEE_ERROR_INVALID_PARAMETER);
459 *current_power_mode = h->current_power_mode;
460 return ZIGBEE_ERROR_NONE;
463 API int zb_node_power_desc_set_current_power_mode(
464 zb_zdo_node_power_descriptor_h handle, zb_zdp_cur_pwr_mode_e current_power_mode)
466 struct zb_zdo_node_power_descriptor_s* h = handle;
467 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
468 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
469 RETV_IF(0b11 < current_power_mode, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
471 h->current_power_mode = current_power_mode;
472 return ZIGBEE_ERROR_NONE;
475 API int zb_node_power_desc_get_available_power_sources(
476 zb_zdo_node_power_descriptor_h handle, zb_zdp_pwr_src_type_e* available_power_sources)
478 struct zb_zdo_node_power_descriptor_s* h = handle;
479 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
480 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
481 RETV_IF(NULL == available_power_sources, ZIGBEE_ERROR_INVALID_PARAMETER);
483 *available_power_sources = h->available_power_sources;
484 return ZIGBEE_ERROR_NONE;
487 API int zb_node_power_desc_set_available_power_sources(
488 zb_zdo_node_power_descriptor_h handle, zb_zdp_pwr_src_type_e available_power_sources)
490 struct zb_zdo_node_power_descriptor_s* h = handle;
491 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
492 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
493 RETV_IF(0b111 < available_power_sources, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
495 h->available_power_sources = available_power_sources;
496 return ZIGBEE_ERROR_NONE;
499 API int zb_node_power_desc_get_current_power_source(
500 zb_zdo_node_power_descriptor_h handle, zb_zdp_pwr_src_type_e* current_power_source)
502 struct zb_zdo_node_power_descriptor_s* h = handle;
503 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
504 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
505 RETV_IF(NULL == current_power_source, ZIGBEE_ERROR_INVALID_PARAMETER);
507 *current_power_source = h->current_power_source;
508 return ZIGBEE_ERROR_NONE;
511 API int zb_node_power_desc_set_current_power_source(
512 zb_zdo_node_power_descriptor_h handle, zb_zdp_pwr_src_type_e current_power_source)
514 struct zb_zdo_node_power_descriptor_s* h = handle;
515 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
516 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
517 RETV_IF(0b111 < current_power_source, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
519 h->current_power_source = current_power_source;
520 return ZIGBEE_ERROR_NONE;
523 API int zb_node_power_desc_get_current_power_source_level(
524 zb_zdo_node_power_descriptor_h handle, zb_zdp_pwr_src_level_e* current_power_source_level)
526 struct zb_zdo_node_power_descriptor_s* h = handle;
527 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
528 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
529 RETV_IF(NULL == current_power_source_level, ZIGBEE_ERROR_INVALID_PARAMETER);
531 *current_power_source_level = h->current_power_source_level;
532 return ZIGBEE_ERROR_NONE;
535 API int zb_node_power_desc_set_current_power_source_level(
536 zb_zdo_node_power_descriptor_h handle, zb_zdp_pwr_src_level_e current_power_source_level)
538 struct zb_zdo_node_power_descriptor_s* h = handle;
539 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
540 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
542 h->current_power_source_level = current_power_source_level;
543 return ZIGBEE_ERROR_NONE;
546 API int zb_node_desc_create(zb_zdo_node_descriptor_h *handle)
548 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
549 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
550 zb_zdo_node_descriptor_h desc = NULL;
552 CHECK_ZIGBEE_PRIVILEGE();
554 desc = calloc(1, sizeof(struct zb_zdo_node_descriptor_s));
555 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
557 return ZIGBEE_ERROR_NONE;
560 API int zb_node_desc_clone(zb_zdo_node_descriptor_h src,
561 zb_zdo_node_descriptor_h *dst)
563 struct zb_zdo_node_descriptor_s* desc = NULL;
565 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
566 RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER);
567 RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER);
569 desc = calloc(1, sizeof(struct zb_zdo_node_descriptor_s));
570 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
572 memcpy(desc, src, sizeof(struct zb_zdo_node_descriptor_s));
575 return ZIGBEE_ERROR_NONE;
578 API int zb_node_desc_destroy(zb_zdo_node_descriptor_h handle)
580 struct zb_zdo_node_descriptor_s* h = handle;
581 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
582 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
585 return ZIGBEE_ERROR_NONE;
588 API int zb_node_desc_get_logical_type(zb_zdo_node_descriptor_h handle,
589 unsigned char* logical_type)
591 struct zb_zdo_node_descriptor_s* h = handle;
592 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
593 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
594 RETV_IF(NULL == logical_type, ZIGBEE_ERROR_INVALID_PARAMETER);
596 *logical_type = h->logical_type;
597 return ZIGBEE_ERROR_NONE;
600 API int zb_node_desc_set_logical_type(zb_zdo_node_descriptor_h handle,
601 unsigned char logical_type)
603 struct zb_zdo_node_descriptor_s* h = handle;
604 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
605 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
606 RETV_IF(0b11 < logical_type, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
608 h->logical_type = logical_type;
609 return ZIGBEE_ERROR_NONE;
612 API int zb_node_desc_get_complex_desciptor_available(
613 zb_zdo_node_descriptor_h handle, unsigned char* complex_desciptor_available)
615 struct zb_zdo_node_descriptor_s* h = handle;
616 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
617 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
618 RETV_IF(NULL == complex_desciptor_available, ZIGBEE_ERROR_INVALID_PARAMETER);
620 *complex_desciptor_available = h->complex_desciptor_available;
621 return ZIGBEE_ERROR_NONE;
624 API int zb_node_desc_set_complex_descriptor_available(
625 zb_zdo_node_descriptor_h handle, unsigned char complex_desciptor_available)
627 struct zb_zdo_node_descriptor_s* h = handle;
628 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
629 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
630 RETV_IF(0x01 < complex_desciptor_available, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
632 h->complex_desciptor_available = complex_desciptor_available;
633 return ZIGBEE_ERROR_NONE;
636 API int zb_node_desc_get_user_descriptor_available(
637 zb_zdo_node_descriptor_h handle, unsigned char* user_descriptor_available)
639 struct zb_zdo_node_descriptor_s* h = handle;
640 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
641 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
642 RETV_IF(NULL == user_descriptor_available, ZIGBEE_ERROR_INVALID_PARAMETER);
644 *user_descriptor_available = h->user_descriptor_available;
645 return ZIGBEE_ERROR_NONE;
648 API int zb_node_desc_set_user_descriptor_available(
649 zb_zdo_node_descriptor_h handle, unsigned char user_descriptor_available)
651 struct zb_zdo_node_descriptor_s* h = handle;
652 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
653 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
654 RETV_IF(0x01 < user_descriptor_available, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
656 h->user_descriptor_available = user_descriptor_available;
657 return ZIGBEE_ERROR_NONE;
660 API int zb_node_desc_get_aps_flags(zb_zdo_node_descriptor_h handle,
661 unsigned char* aps_flags)
663 struct zb_zdo_node_descriptor_s* h = handle;
664 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
665 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
666 RETV_IF(NULL == aps_flags, ZIGBEE_ERROR_INVALID_PARAMETER);
668 *aps_flags = h->aps_flags;
669 return ZIGBEE_ERROR_NONE;
672 API int zb_node_desc_set_aps_flags(zb_zdo_node_descriptor_h handle,
673 unsigned char aps_flags)
675 struct zb_zdo_node_descriptor_s* h = handle;
676 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
677 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
678 RETV_IF(0b111 < aps_flags, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
680 h->aps_flags = aps_flags;
681 return ZIGBEE_ERROR_NONE;
684 API int zb_node_desc_get_frequency_band(zb_zdo_node_descriptor_h handle,
685 unsigned char* frequency_band)
687 struct zb_zdo_node_descriptor_s* h = handle;
688 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
689 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
690 RETV_IF(NULL == frequency_band, ZIGBEE_ERROR_INVALID_PARAMETER);
692 *frequency_band = h->frequency_band;
693 return ZIGBEE_ERROR_NONE;
696 API int zb_node_desc_set_frequency_band(zb_zdo_node_descriptor_h handle,
697 unsigned char frequency_band)
699 struct zb_zdo_node_descriptor_s* h = handle;
700 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
701 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
702 RETV_IF(0b1111 < frequency_band, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
704 h->frequency_band = frequency_band;
705 return ZIGBEE_ERROR_NONE;
709 API int zb_node_desc_get_mac_capability_flags(zb_zdo_node_descriptor_h handle,
710 unsigned char* mac_capability_flags)
712 struct zb_zdo_node_descriptor_s* h = handle;
713 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
714 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
715 RETV_IF(NULL == mac_capability_flags, ZIGBEE_ERROR_INVALID_PARAMETER);
717 *mac_capability_flags = h->mac_capability_flags;
718 return ZIGBEE_ERROR_NONE;
721 API int zb_node_desc_set_mac_capability_flags(zb_zdo_node_descriptor_h handle,
722 unsigned char mac_capability_flags)
724 struct zb_zdo_node_descriptor_s* h = handle;
725 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
726 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
728 h->mac_capability_flags = mac_capability_flags;
729 return ZIGBEE_ERROR_NONE;
732 API int zb_node_desc_get_manufacturer_code(zb_zdo_node_descriptor_h handle,
733 unsigned short* manufacturer_code)
735 struct zb_zdo_node_descriptor_s* h = handle;
736 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
737 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
738 RETV_IF(NULL == manufacturer_code, ZIGBEE_ERROR_INVALID_PARAMETER);
740 *manufacturer_code = h->manufacturer_code;
741 return ZIGBEE_ERROR_NONE;
744 API int zb_node_desc_set_manufacturer_code(zb_zdo_node_descriptor_h handle,
745 unsigned short manufacturer_code)
747 struct zb_zdo_node_descriptor_s* h = handle;
748 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
749 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
751 h->manufacturer_code = manufacturer_code;
752 return ZIGBEE_ERROR_NONE;
755 API int zb_node_desc_get_maximum_buffer_size(zb_zdo_node_descriptor_h handle,
756 unsigned char* maximum_buffer_size)
758 struct zb_zdo_node_descriptor_s* h = handle;
759 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
760 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
761 RETV_IF(NULL == maximum_buffer_size, ZIGBEE_ERROR_INVALID_PARAMETER);
763 *maximum_buffer_size = h->maximum_buffer_size;
764 return ZIGBEE_ERROR_NONE;
767 API int zb_node_desc_set_maximum_buffer_size(zb_zdo_node_descriptor_h handle,
768 unsigned char maximum_buffer_size)
770 struct zb_zdo_node_descriptor_s* h = handle;
771 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
772 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
773 RETV_IF(0x7f < maximum_buffer_size, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
775 h->maximum_buffer_size = maximum_buffer_size;
776 return ZIGBEE_ERROR_NONE;
779 API int zb_node_desc_get_maximum_incoming_transfer_size(
780 zb_zdo_node_descriptor_h handle, unsigned short* maximum_incoming_transfer_size)
782 struct zb_zdo_node_descriptor_s* h = handle;
783 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
784 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
785 RETV_IF(NULL == maximum_incoming_transfer_size, ZIGBEE_ERROR_INVALID_PARAMETER);
787 *maximum_incoming_transfer_size = h->maximum_incoming_transfer_size;
788 return ZIGBEE_ERROR_NONE;
791 API int zb_node_desc_set_maximum_incoming_transfer_size(
792 zb_zdo_node_descriptor_h handle, unsigned short maximum_incoming_transfer_size)
794 struct zb_zdo_node_descriptor_s* h = handle;
795 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
796 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
797 RETV_IF(0x7fff < maximum_incoming_transfer_size, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
799 h->maximum_incoming_transfer_size = maximum_incoming_transfer_size;
800 return ZIGBEE_ERROR_NONE;
803 API int zb_node_desc_get_server_mask(zb_zdo_node_descriptor_h handle,
804 unsigned short* server_mask)
806 struct zb_zdo_node_descriptor_s* h = handle;
807 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
808 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
809 RETV_IF(NULL == server_mask, ZIGBEE_ERROR_INVALID_PARAMETER);
811 *server_mask = h->server_mask;
812 return ZIGBEE_ERROR_NONE;
815 API int zb_node_desc_set_server_mask(zb_zdo_node_descriptor_h handle,
816 unsigned short server_mask)
818 struct zb_zdo_node_descriptor_s* h = handle;
819 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
820 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
821 RETV_IF(0x7f < server_mask, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
823 h->server_mask = server_mask;
824 return ZIGBEE_ERROR_NONE;
827 API int zb_node_desc_get_maximum_outgoing_transfer_size(
828 zb_zdo_node_descriptor_h handle, unsigned short* maximum_outgoing_transfer_size)
830 struct zb_zdo_node_descriptor_s* h = handle;
831 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
832 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
833 RETV_IF(NULL == maximum_outgoing_transfer_size, ZIGBEE_ERROR_INVALID_PARAMETER);
835 *maximum_outgoing_transfer_size = h->maximum_outgoing_transfer_size;
836 return ZIGBEE_ERROR_NONE;
839 API int zb_node_desc_set_maximum_outgoing_transfer_size(
840 zb_zdo_node_descriptor_h handle, unsigned short maximum_outgoing_transfer_size)
842 struct zb_zdo_node_descriptor_s* h = handle;
843 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
844 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
845 RETV_IF(0x7fff < maximum_outgoing_transfer_size, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
847 h->maximum_outgoing_transfer_size = maximum_outgoing_transfer_size;
848 return ZIGBEE_ERROR_NONE;
851 API int zb_node_desc_get_descriptor_capability_field(
852 zb_zdo_node_descriptor_h handle, unsigned short* descriptor_capability_field)
854 struct zb_zdo_node_descriptor_s* h = handle;
855 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
856 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
857 RETV_IF(NULL == descriptor_capability_field, ZIGBEE_ERROR_INVALID_PARAMETER);
859 *descriptor_capability_field = h->descriptor_capability_field;
860 return ZIGBEE_ERROR_NONE;
863 API int zb_node_desc_set_descriptor_capability_field(
864 zb_zdo_node_descriptor_h handle, unsigned short descriptor_capability_field)
866 struct zb_zdo_node_descriptor_s* h = handle;
867 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
868 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
869 RETV_IF(0x11 < descriptor_capability_field, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
871 h->descriptor_capability_field = descriptor_capability_field;
872 return ZIGBEE_ERROR_NONE;