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.
24 #include "zb-common.h"
26 #define ZB_GUARD_CHAR 1
27 #define ZB_ZCL_OCTET_SIZE 1
28 #define ZB_ZCL_LONG_OCTET_SIZE 2
30 API int zb_read_attr_status_record_create(
31 zb_zcl_read_attr_status_record_h *handle)
33 zb_zcl_read_attr_status_record_h simple = NULL;
35 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
36 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
37 CHECK_ZIGBEE_PRIVILEGE();
39 simple = calloc(1, sizeof(struct read_attribute_status_record_s));
40 RETVM_IF(NULL == simple, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
44 return ZIGBEE_ERROR_NONE;
47 API int zb_read_attr_status_record_clone(zb_zcl_read_attr_status_record_h src,
48 zb_zcl_read_attr_status_record_h *dst)
50 struct read_attribute_status_record_s *srcs = src;
51 struct read_attribute_status_record_s *desc = NULL;
53 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
54 RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER);
55 RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER);
57 desc = calloc(1, sizeof(struct read_attribute_status_record_s));
58 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
60 memcpy(desc, src, sizeof(struct read_attribute_status_record_s));
61 desc->value = calloc(1, zb_zcl_get_data_size(srcs->type));
62 RETVM_IF(NULL == desc->value, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
63 memcpy(desc->value, srcs->value, zb_zcl_get_data_size(srcs->type));
66 return ZIGBEE_ERROR_NONE;
70 API int zb_read_attr_status_record_destroy(
71 zb_zcl_read_attr_status_record_h handle)
73 struct read_attribute_status_record_s* h = handle;
75 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
76 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
82 return ZIGBEE_ERROR_NONE;
85 API int zb_read_attr_status_record_get_id(
86 zb_zcl_read_attr_status_record_h handle, unsigned short* id)
88 struct read_attribute_status_record_s* h = handle;
89 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
90 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
91 RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
94 return ZIGBEE_ERROR_NONE;
97 API int zb_read_attr_status_record_set_id(
98 zb_zcl_read_attr_status_record_h handle, unsigned short id)
100 struct read_attribute_status_record_s* h = handle;
101 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
102 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
105 return ZIGBEE_ERROR_NONE;
108 API int zb_read_attr_status_record_get_status(
109 zb_zcl_read_attr_status_record_h handle, zb_zcl_status_e* status)
111 struct read_attribute_status_record_s* h = handle;
112 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
113 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
114 RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER);
117 return ZIGBEE_ERROR_NONE;
120 API int zb_read_attr_status_record_set_status(
121 zb_zcl_read_attr_status_record_h handle, zb_zcl_status_e status)
123 struct read_attribute_status_record_s* h = handle;
124 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
125 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
128 return ZIGBEE_ERROR_NONE;
131 API int zb_read_attr_status_record_get_type(
132 zb_zcl_read_attr_status_record_h handle, zb_zcl_data_type_e *type)
134 struct read_attribute_status_record_s* h = handle;
135 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
136 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
137 RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
140 return ZIGBEE_ERROR_NONE;
143 API int zb_read_attr_status_record_set_type(
144 zb_zcl_read_attr_status_record_h handle, zb_zcl_data_type_e type)
146 struct read_attribute_status_record_s* h = handle;
147 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
148 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
149 RETV_IF(0 >= zb_zcl_get_data_size(type), ZIGBEE_ERROR_INVALID_PARAMETER);
152 return ZIGBEE_ERROR_NONE;
155 API int zb_read_attr_status_record_get_value(
156 zb_zcl_read_attr_status_record_h handle, zb_zcl_data_type_e* type,
157 unsigned char** value, int* count)
160 struct read_attribute_status_record_s* h = handle;
162 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
163 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
164 RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
165 RETV_IF(NULL == h->value, ZIGBEE_ERROR_NO_DATA);
167 len = zb_zcl_get_data_size(h->type);
170 *value = calloc(len + ZB_GUARD_CHAR, sizeof(char));
171 RETV_IF(NULL == *value, ZIGBEE_ERROR_OUT_OF_MEMORY);
172 memcpy(*value, h->value, len);
176 } else if (ZB_ZCL_OCTET_STRING == h->type || ZB_ZCL_CHARACTER_STRING == h->type) {
180 *value = calloc(len + ZB_GUARD_CHAR, sizeof(char));
181 RETV_IF(NULL == *value, ZIGBEE_ERROR_OUT_OF_MEMORY);
182 memcpy(*value, h->value + ZB_ZCL_OCTET_SIZE, len);
187 } else if (ZB_ZCL_LONG_OCTET_STRING == h->type || ZB_ZCL_LONG_CHARACTER_STRING == h->type) {
189 len = h->value[0] & 0xff;
190 len |= (h->value[1] << 8) & 0xff00 ;
192 *value = calloc(len + ZB_GUARD_CHAR, sizeof(char));
193 RETV_IF(NULL == *value, ZIGBEE_ERROR_OUT_OF_MEMORY);
194 memcpy(*value, h->value + ZB_ZCL_LONG_OCTET_SIZE, len);
200 return ZIGBEE_ERROR_NOT_SUPPORTED;
203 return ZIGBEE_ERROR_NONE;
206 API int zb_read_attr_status_record_set_value(
207 zb_zcl_read_attr_status_record_h handle, zb_zcl_data_type_e type,
208 unsigned char* value, int count)
211 struct read_attribute_status_record_s* h = handle;
213 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
214 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
215 RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
217 len = zb_zcl_get_data_size(type);
220 h->value = calloc(len + ZB_GUARD_CHAR, sizeof(char));
221 RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
222 memcpy(h->value, value, len);
225 } else if (ZB_ZCL_OCTET_STRING == type || ZB_ZCL_CHARACTER_STRING == type) {
227 h->value = calloc(count + ZB_ZCL_OCTET_SIZE + ZB_GUARD_CHAR, sizeof(char));
228 RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
231 memcpy(h->value + ZB_ZCL_OCTET_SIZE, value + ZB_ZCL_OCTET_SIZE, count);
233 } else if (ZB_ZCL_LONG_OCTET_STRING == type || ZB_ZCL_LONG_CHARACTER_STRING == type) {
235 h->value = calloc(count + ZB_ZCL_LONG_OCTET_SIZE + ZB_GUARD_CHAR, sizeof(char));
236 RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
238 h->value[0] = count & 0xff;
239 h->value[1] = (count >> 8) & 0xff ;
240 memcpy(h->value + ZB_ZCL_LONG_OCTET_SIZE, value, len);
243 return ZIGBEE_ERROR_NOT_SUPPORTED;
246 return ZIGBEE_ERROR_NONE;
249 API int zb_discover_attr_info_create(zb_zcl_discover_attr_info_record_h *handle)
251 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
253 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
254 zb_zcl_discover_attr_info_record_h simple = NULL;
256 CHECK_ZIGBEE_PRIVILEGE();
258 simple = calloc(1, sizeof(struct discover_attribute_info_record_s));
259 RETVM_IF(NULL == simple, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
261 return ZIGBEE_ERROR_NONE;
264 API int zb_discover_attr_info_clone(zb_zcl_discover_attr_info_record_h src,
265 zb_zcl_discover_attr_info_record_h *dst)
267 struct discover_attribute_info_record_s *srcs = src;
268 struct discover_attribute_info_record_s *desc = NULL;
270 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
271 RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER);
272 RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER);
274 desc = calloc(1, sizeof(struct discover_attribute_info_record_s));
275 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
277 memcpy(desc, srcs, sizeof(struct discover_attribute_info_record_s));
281 return ZIGBEE_ERROR_NONE;
284 API int zb_discover_attr_info_destroy(zb_zcl_discover_attr_info_record_h handle)
286 struct discover_attribute_info_record_s *h = handle;
288 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
289 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
293 return ZIGBEE_ERROR_NONE;
296 API int zb_discover_attr_info_get_id(
297 zb_zcl_discover_attr_info_record_h handle, unsigned short *id)
299 struct discover_attribute_info_record_s *h = handle;
300 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
301 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
302 RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
305 return ZIGBEE_ERROR_NONE;
308 API int zb_discover_attr_info_set_id(
309 zb_zcl_discover_attr_info_record_h handle, unsigned short id)
311 struct discover_attribute_info_record_s *h = handle;
312 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
313 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
316 return ZIGBEE_ERROR_NONE;
319 API int zb_discover_attr_info_get_type(
320 zb_zcl_discover_attr_info_record_h handle, zb_zcl_data_type_e *type)
322 struct discover_attribute_info_record_s *h = handle;
323 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
324 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
325 RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
328 return ZIGBEE_ERROR_NONE;
331 API int zb_discover_attr_info_set_type(
332 zb_zcl_discover_attr_info_record_h handle, zb_zcl_data_type_e type)
334 struct discover_attribute_info_record_s *h = handle;
335 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
336 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
337 RETV_IF(0 >= zb_zcl_get_data_size(type), ZIGBEE_ERROR_INVALID_PARAMETER);
340 return ZIGBEE_ERROR_NONE;
343 API int zb_write_attr_record_create(zb_zcl_write_attr_record_h *handle)
345 zb_zcl_write_attr_record_h t = NULL;
347 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
348 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
349 CHECK_ZIGBEE_PRIVILEGE();
351 t = calloc(1, sizeof(struct write_attribute_record_s));
352 RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
355 return ZIGBEE_ERROR_NONE;
358 API int zb_write_attr_record_clone(zb_zcl_write_attr_record_h src,
359 zb_zcl_write_attr_record_h *dst)
361 struct write_attribute_record_s *srcs = src;
362 struct write_attribute_record_s *desc = NULL;
364 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
365 RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER);
366 RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER);
368 desc = calloc(1, sizeof(struct write_attribute_record_s));
369 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
371 memcpy(desc, src, sizeof(struct write_attribute_record_s));
373 desc->value = calloc(1, zb_zcl_get_data_size(srcs->type));
374 RETVM_IF(NULL == desc->value, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
376 memcpy(desc->value, srcs->value, zb_zcl_get_data_size(srcs->type));
379 return ZIGBEE_ERROR_NONE;
382 API int zb_write_attr_record_destroy(zb_zcl_write_attr_record_h handle)
384 struct write_attribute_record_s* h = handle;
386 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
387 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
396 return ZIGBEE_ERROR_NONE;
399 API int zb_write_attr_record_set_id(zb_zcl_write_attr_record_h handle,
402 struct write_attribute_record_s* h = handle;
404 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
405 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
408 return ZIGBEE_ERROR_NONE;
411 API int zb_write_attr_record_set_type(zb_zcl_write_attr_record_h handle,
412 zb_zcl_data_type_e type)
414 struct write_attribute_record_s* h = handle;
416 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
417 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
418 RETV_IF(0 >= zb_zcl_get_data_size(type), ZIGBEE_ERROR_INVALID_PARAMETER);
421 return ZIGBEE_ERROR_NONE;
424 API int zb_write_attr_record_set_value(zb_zcl_write_attr_record_h handle,
425 zb_zcl_data_type_e type, unsigned char* value, int count)
429 struct write_attribute_record_s* h = handle;
431 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
432 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
433 RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
440 len = zb_zcl_get_data_size(type);
443 h->value = calloc(len + ZB_GUARD_CHAR , sizeof(char));
444 RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
445 memcpy(h->value, value, count);
448 } else if (ZB_ZCL_OCTET_STRING == type || ZB_ZCL_CHARACTER_STRING == type) {
450 h->value = calloc(count + ZB_ZCL_OCTET_SIZE + ZB_GUARD_CHAR, sizeof(char));
451 RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
452 /* The first 1 byte indicate invalid or length of string */
453 h->value[0] = value[0] & 0xff;
454 memcpy(h->value + ZB_ZCL_OCTET_SIZE, value, count);
456 } else if (ZB_ZCL_LONG_OCTET_STRING == type || ZB_ZCL_LONG_CHARACTER_STRING == type) {
458 h->value = calloc(count + ZB_ZCL_LONG_OCTET_SIZE + ZB_GUARD_CHAR, sizeof(char));
459 RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
461 /* The first 2 byte indicate invalid or length of string */
462 h->value[0] = count & 0xff;
463 h->value[1] = (count >> 8) & 0xff ;
465 memcpy(h->value + ZB_ZCL_LONG_OCTET_SIZE, value, count);
468 return ZIGBEE_ERROR_NOT_SUPPORTED;
471 return ZIGBEE_ERROR_NONE;
474 API int zb_write_attr_status_create(zb_zcl_write_attr_status_record_h *handle)
476 zb_zcl_write_attr_status_record_h simple = NULL;
478 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
479 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
480 CHECK_ZIGBEE_PRIVILEGE();
482 simple = calloc(1, sizeof(struct write_attribute_status_record_s));
483 RETVM_IF(NULL == simple, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
486 return ZIGBEE_ERROR_NONE;
489 API int zb_write_attr_status_clone(zb_zcl_write_attr_status_record_h src,
490 zb_zcl_write_attr_status_record_h *dst)
492 struct write_attribute_status_record_s *srcs = src;
493 struct write_attribute_status_record_s *desc = NULL;
495 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
496 RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER);
497 RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER);
499 desc = calloc(1, sizeof(struct write_attribute_status_record_s));
500 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
502 memcpy(desc, srcs, sizeof(struct write_attribute_status_record_s));
506 return ZIGBEE_ERROR_NONE;
509 API int zb_write_attr_status_destroy(zb_zcl_write_attr_status_record_h handle)
511 struct write_attribute_status_record_s *h = handle;
513 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
514 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
517 return ZIGBEE_ERROR_NONE;
520 API int zb_write_attr_status_get_status(
521 zb_zcl_write_attr_status_record_h handle, zb_zcl_status_e *status)
523 struct write_attribute_status_record_s *h = handle;
524 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
525 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
526 RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER);
529 return ZIGBEE_ERROR_NONE;
532 API int zb_write_attr_status_set_status(zb_zcl_write_attr_status_record_h handle,
533 zb_zcl_status_e status)
535 struct write_attribute_status_record_s *h = handle;
536 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
537 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
540 return ZIGBEE_ERROR_NONE;
543 API int zb_write_attr_status_get_id(zb_zcl_write_attr_status_record_h handle,
546 struct write_attribute_status_record_s *h = handle;
547 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
548 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
549 RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
552 return ZIGBEE_ERROR_NONE;
555 API int zb_write_attr_status_set_id(zb_zcl_write_attr_status_record_h handle,
558 struct write_attribute_status_record_s *h = handle;
559 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
560 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
563 return ZIGBEE_ERROR_NONE;
566 API int zb_report_config_record_create(zb_zcl_reporting_config_record_h *handle)
568 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
569 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
571 zb_zcl_reporting_config_record_h t = NULL;
573 CHECK_ZIGBEE_PRIVILEGE();
575 t = calloc(1, sizeof(struct reporting_configuration_record_s));
576 RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
578 return ZIGBEE_ERROR_NONE;
581 API int zb_report_config_record_clone(zb_zcl_reporting_config_record_h src,
582 zb_zcl_reporting_config_record_h *dst)
584 struct reporting_configuration_record_s *srcs = src;
585 struct reporting_configuration_record_s *desc = NULL;
587 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
588 RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER);
589 RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER);
591 desc = calloc(1, sizeof(struct reporting_configuration_record_s));
592 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
594 memcpy(desc, src, sizeof(struct reporting_configuration_record_s));
596 desc->change = calloc(1, zb_zcl_get_data_size(srcs->type));
597 RETVM_IF(NULL == desc->change, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
599 memcpy(desc->change, srcs->change, zb_zcl_get_data_size(srcs->type));
602 return ZIGBEE_ERROR_NONE;
605 API int zb_report_config_record_destroy(zb_zcl_reporting_config_record_h handle)
607 struct reporting_configuration_record_s *h = handle;
609 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
610 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
616 return ZIGBEE_ERROR_NONE;
619 API int zb_report_config_record_get_dir(zb_zcl_reporting_config_record_h handle,
620 zb_zcl_fc_direction_e *dir)
622 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
624 struct reporting_configuration_record_s *h = handle;
625 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
626 RETV_IF(NULL == dir, ZIGBEE_ERROR_INVALID_PARAMETER);
628 return ZIGBEE_ERROR_NONE;
631 API int zb_report_config_record_set_dir(zb_zcl_reporting_config_record_h handle,
632 zb_zcl_fc_direction_e dir)
634 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
636 struct reporting_configuration_record_s *h = handle;
637 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
638 if (dir == ZB_ZCL_CLIENT_TO_SERVER)
642 return ZIGBEE_ERROR_NONE;
645 API int zb_report_config_record_get_id(zb_zcl_reporting_config_record_h handle,
648 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
650 struct reporting_configuration_record_s *h = handle;
651 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
652 RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
654 return ZIGBEE_ERROR_NONE;
657 API int zb_report_config_record_set_id(zb_zcl_reporting_config_record_h handle,
660 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
662 struct reporting_configuration_record_s *h = handle;
663 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
665 return ZIGBEE_ERROR_NONE;
669 API int zb_report_config_record_get_type(
670 zb_zcl_reporting_config_record_h handle, zb_zcl_data_type_e *type)
672 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
674 struct reporting_configuration_record_s *h = handle;
675 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
676 RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
678 return ZIGBEE_ERROR_NONE;
681 API int zb_report_config_record_get_min_interval(
682 zb_zcl_reporting_config_record_h handle, unsigned short *min_i)
684 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
686 struct reporting_configuration_record_s *h = handle;
687 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
688 RETV_IF(NULL == min_i, ZIGBEE_ERROR_INVALID_PARAMETER);
690 return ZIGBEE_ERROR_NONE;
693 API int zb_report_config_record_set_min_interval(
694 zb_zcl_reporting_config_record_h handle, unsigned short min_i)
696 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
698 struct reporting_configuration_record_s *h = handle;
699 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
701 return ZIGBEE_ERROR_NONE;
704 API int zb_report_config_record_get_max_interval(
705 zb_zcl_reporting_config_record_h handle, unsigned short *max_i)
707 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
709 struct reporting_configuration_record_s *h = handle;
710 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
711 RETV_IF(NULL == max_i, ZIGBEE_ERROR_INVALID_PARAMETER);
713 return ZIGBEE_ERROR_NONE;
716 API int zb_report_config_record_set_max_interval(
717 zb_zcl_reporting_config_record_h handle, unsigned short max_i)
719 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
721 struct reporting_configuration_record_s *h = handle;
722 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
724 return ZIGBEE_ERROR_NONE;
727 API int zb_report_config_record_get_timeout(
728 zb_zcl_reporting_config_record_h handle, unsigned short *to)
730 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
732 struct reporting_configuration_record_s *h = handle;
733 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
734 RETV_IF(NULL == to, ZIGBEE_ERROR_INVALID_PARAMETER);
736 return ZIGBEE_ERROR_NONE;
739 API int zb_report_config_record_set_timeout(
740 zb_zcl_reporting_config_record_h handle, unsigned short to)
742 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
744 struct reporting_configuration_record_s *h = handle;
745 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
747 return ZIGBEE_ERROR_NONE;
750 API int zb_report_config_record_get_change(
751 zb_zcl_reporting_config_record_h handle, zb_zcl_data_type_e *type,
752 unsigned char **value, int *count)
754 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
757 unsigned char *temp = NULL;
758 int data_type = ZB_ZCL_DATA_TYPE_NONE;
760 struct reporting_configuration_record_s *h = handle;
764 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
765 RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
766 RETV_IF(NULL == h->change, ZIGBEE_ERROR_NO_DATA);
768 len = zb_zcl_get_data_size(h->type);
769 data_type = zb_zcl_get_analog_or_discret(h->type);
770 if (0 < len /* && ZB_ZCL_DATA_TYPE_ANALOG == data_type */) {
772 temp = calloc(len, sizeof(char));
773 RETV_IF(NULL == temp, ZIGBEE_ERROR_OUT_OF_MEMORY);
774 memcpy(value, h->change, len);
780 return ZIGBEE_ERROR_NOT_SUPPORTED;
783 return ZIGBEE_ERROR_NONE;
786 API int zb_report_config_record_set_change(
787 zb_zcl_reporting_config_record_h handle, zb_zcl_data_type_e type, unsigned char *value)
789 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
792 int data_type = ZB_ZCL_DATA_TYPE_NONE;
794 struct reporting_configuration_record_s *h = handle;
798 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
802 len = zb_zcl_get_data_size(type);
803 data_type = zb_zcl_get_analog_or_discret(type);
805 if (0 < len /* && ZB_ZCL_DATA_TYPE_ANALOG == data_type */) {
806 h->change = calloc(len + 1, sizeof(unsigned char));
807 RETV_IF(NULL == h->change, ZIGBEE_ERROR_OUT_OF_MEMORY);
808 memcpy(h->change, value, len);
811 return ZIGBEE_ERROR_NOT_SUPPORTED;
814 return ZIGBEE_ERROR_NONE;
817 API int zb_read_report_config_record_create(
818 zb_zcl_read_report_config_record_h *handle)
820 zb_zcl_read_report_config_record_h t = NULL;
822 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
823 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
824 CHECK_ZIGBEE_PRIVILEGE();
826 t = calloc(1, sizeof(struct read_reporting_configuration_record_s));
827 RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
830 return ZIGBEE_ERROR_NONE;
833 API int zb_read_report_config_record_clone(
834 zb_zcl_read_report_config_record_h src, zb_zcl_read_report_config_record_h *dst)
836 struct read_reporting_configuration_record_s *srcs = src;
837 struct read_reporting_configuration_record_s *desc = NULL;
839 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
840 RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER);
841 RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER);
843 desc = calloc(1, sizeof(struct read_reporting_configuration_record_s));
844 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
846 memcpy(desc, srcs, sizeof(struct read_reporting_configuration_record_s));
849 return ZIGBEE_ERROR_NONE;
852 API int zb_read_report_config_record_destroy(
853 zb_zcl_read_report_config_record_h handle)
855 struct read_reporting_configuration_record_s *h = handle;
857 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
858 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
862 return ZIGBEE_ERROR_NONE;
865 API int zb_read_report_config_record_set_dir(
866 zb_zcl_read_report_config_record_h handle, zb_zcl_fc_direction_e dir)
868 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
870 struct read_reporting_configuration_record_s *h = handle;
871 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
873 if (dir == ZB_ZCL_CLIENT_TO_SERVER)
877 return ZIGBEE_ERROR_NONE;
880 API int zb_read_report_config_record_get_dir(
881 zb_zcl_read_report_config_record_h handle, zb_zcl_fc_direction_e *dir)
883 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
885 struct read_reporting_configuration_record_s *h = handle;
886 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
889 return ZIGBEE_ERROR_NONE;
892 API int zb_read_report_config_record_set_id(
893 zb_zcl_read_report_config_record_h handle, unsigned short id)
895 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
897 struct read_reporting_configuration_record_s *h = handle;
898 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
901 return ZIGBEE_ERROR_NONE;
904 API int zb_read_report_config_record_get_id(
905 zb_zcl_read_report_config_record_h handle, unsigned short *id)
907 struct read_reporting_configuration_record_s *h = handle;
908 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
909 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
911 return ZIGBEE_ERROR_NONE;
914 API int zb_report_config_response_record_create(
915 zb_zcl_report_config_response_record_h *handle)
917 zb_zcl_report_config_response_record_h t = NULL;
919 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
920 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
921 CHECK_ZIGBEE_PRIVILEGE();
923 t = calloc(1, sizeof(struct reporting_configuration_response_record_s));
924 RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
927 return ZIGBEE_ERROR_NONE;
930 API int zb_report_config_response_record_clone(
931 zb_zcl_report_config_response_record_h src,
932 zb_zcl_report_config_response_record_h *dst)
934 struct reporting_configuration_response_record_s *srcs = src;
935 struct reporting_configuration_response_record_s *desc = NULL;
937 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
938 RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER);
939 RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER);
941 desc = calloc(1, sizeof(struct reporting_configuration_response_record_s));
942 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
944 memcpy(desc, srcs, sizeof(struct reporting_configuration_response_record_s));
947 return ZIGBEE_ERROR_NONE;
950 API int zb_report_config_response_record_destroy(
951 zb_zcl_report_config_response_record_h handle)
953 struct reporting_configuration_response_record_s *h = handle;
955 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
956 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
960 return ZIGBEE_ERROR_NONE;
963 API int zb_report_config_response_record_get_status(
964 zb_zcl_report_config_response_record_h handle, zb_zcl_status_e *status)
966 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
968 struct reporting_configuration_response_record_s *h = handle;
969 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
970 RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER);
973 return ZIGBEE_ERROR_NONE;
976 API int zb_report_config_response_record_set_status(
977 zb_zcl_report_config_response_record_h handle, zb_zcl_status_e status)
979 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
981 struct reporting_configuration_response_record_s *h = handle;
982 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
985 return ZIGBEE_ERROR_NONE;
988 API int zb_report_config_response_record_get_dir(
989 zb_zcl_report_config_response_record_h handle, zb_zcl_fc_direction_e *dir)
991 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
993 struct reporting_configuration_response_record_s *h = handle;
994 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
995 RETV_IF(NULL == dir, ZIGBEE_ERROR_INVALID_PARAMETER);
998 return ZIGBEE_ERROR_NONE;
1001 API int zb_report_config_response_record_set_dir(
1002 zb_zcl_report_config_response_record_h handle, zb_zcl_fc_direction_e dir)
1004 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1006 struct reporting_configuration_response_record_s *h = handle;
1007 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1010 return ZIGBEE_ERROR_NONE;
1013 API int zb_report_config_response_record_get_id(
1014 zb_zcl_report_config_response_record_h handle, unsigned short *id)
1016 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1018 struct reporting_configuration_response_record_s *h = handle;
1019 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1020 RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
1023 return ZIGBEE_ERROR_NONE;
1026 API int zb_report_config_response_record_set_id(
1027 zb_zcl_report_config_response_record_h handle, unsigned short id)
1029 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1031 struct reporting_configuration_response_record_s *h = handle;
1032 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1035 return ZIGBEE_ERROR_NONE;
1038 API int zb_attr_report_create(zb_zcl_attr_report_h *handle)
1040 zb_zcl_attr_report_h t = NULL;
1042 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1043 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
1044 CHECK_ZIGBEE_PRIVILEGE();
1046 t = calloc(1, sizeof(struct attribute_report_s));
1047 RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
1050 return ZIGBEE_ERROR_NONE;
1053 API int zb_attr_report_clone(zb_zcl_attr_report_h src, zb_zcl_attr_report_h *dst)
1055 struct attribute_report_s *srcs = src;
1056 struct attribute_report_s *desc = NULL;
1058 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1059 RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER);
1060 RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER);
1062 desc = calloc(1, sizeof(struct attribute_report_s));
1063 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
1065 memcpy(desc, srcs, sizeof(struct attribute_report_s));
1067 desc->value = calloc(1, zb_zcl_get_data_size(srcs->type));
1068 RETVM_IF(NULL == desc->value, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
1070 memcpy(desc->value, srcs->value, zb_zcl_get_data_size(srcs->type));
1073 return ZIGBEE_ERROR_NONE;
1076 API int zb_attr_report_destroy(zb_zcl_attr_report_h handle)
1078 struct attribute_report_s *h = handle;
1080 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1081 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1087 return ZIGBEE_ERROR_NONE;
1090 API int zb_attr_report_get_id(zb_zcl_attr_report_h handle, unsigned short *id)
1092 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1094 struct attribute_report_s *h = handle;
1095 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1096 RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
1099 return ZIGBEE_ERROR_NONE;
1102 API int zb_attr_report_set_id(zb_zcl_attr_report_h handle, unsigned short id)
1104 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1106 struct attribute_report_s *h = handle;
1107 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1110 return ZIGBEE_ERROR_NONE;
1113 API int zb_attr_report_get_type(zb_zcl_attr_report_h handle,
1114 zb_zcl_data_type_e *type)
1116 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1118 struct attribute_report_s *h = handle;
1119 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1120 RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
1123 return ZIGBEE_ERROR_NONE;
1126 API int zb_attr_report_set_type(zb_zcl_attr_report_h handle,
1127 zb_zcl_data_type_e type)
1129 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1131 struct attribute_report_s *h = handle;
1132 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1135 return ZIGBEE_ERROR_NONE;
1138 API int zb_attr_report_get_value(zb_zcl_attr_report_h handle,
1139 zb_zcl_data_type_e* type, unsigned char** value, int* count)
1141 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1144 unsigned char *temp = NULL;
1145 struct attribute_report_s *h = handle;
1147 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1148 RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
1149 RETV_IF(NULL == h->value, ZIGBEE_ERROR_NO_DATA);
1151 len = zb_zcl_get_data_size(h->type);
1154 temp = calloc(len, sizeof(unsigned char));
1155 RETV_IF(NULL == temp, ZIGBEE_ERROR_OUT_OF_MEMORY);
1156 memcpy(temp, h->value, len);
1161 } else if (ZB_ZCL_OCTET_STRING == h->type || ZB_ZCL_CHARACTER_STRING == h->type) {
1164 temp = calloc(len + ZB_GUARD_CHAR, sizeof(char));
1165 RETV_IF(NULL == temp, ZIGBEE_ERROR_OUT_OF_MEMORY);
1167 memcpy(temp, h->value + ZB_ZCL_OCTET_SIZE, len);
1172 } else if (ZB_ZCL_LONG_OCTET_STRING == h->type || ZB_ZCL_LONG_CHARACTER_STRING == h->type) {
1174 len = h->value[0] & 0xff;
1175 len |= (h->value[1] << 8) & 0xff00 ;
1177 temp = calloc(len + ZB_GUARD_CHAR, sizeof(char));
1178 RETV_IF(NULL == temp, ZIGBEE_ERROR_OUT_OF_MEMORY);
1179 memcpy(*value, h->value + ZB_ZCL_LONG_OCTET_SIZE, len);
1186 return ZIGBEE_ERROR_NOT_SUPPORTED;
1189 return ZIGBEE_ERROR_NONE;
1192 API int zb_attr_report_set_value(zb_zcl_attr_report_h handle,
1193 zb_zcl_data_type_e type, unsigned char* value, int count)
1195 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1198 struct attribute_report_s *h = handle;
1200 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1201 RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
1208 len = zb_zcl_get_data_size(type);
1211 h->value = calloc(len + ZB_GUARD_CHAR , sizeof(char));
1212 RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
1213 memcpy(h->value, value, count);
1216 } else if (ZB_ZCL_OCTET_STRING == type || ZB_ZCL_CHARACTER_STRING == type) {
1218 h->value = calloc(count + ZB_ZCL_OCTET_SIZE + ZB_GUARD_CHAR, sizeof(char));
1219 RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
1220 /* The first 1 byte indicate invalid or length of string */
1221 h->value[0] = value[0] & 0xff;
1222 memcpy(h->value + ZB_ZCL_OCTET_SIZE, value, count);
1224 } else if (ZB_ZCL_LONG_OCTET_STRING == type || ZB_ZCL_LONG_CHARACTER_STRING == type) {
1226 h->value = calloc(count + ZB_ZCL_LONG_OCTET_SIZE + ZB_GUARD_CHAR, sizeof(char));
1227 RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
1229 /* The first 2 byte indicate invalid or length of string */
1230 h->value[0] = count & 0xff;
1231 h->value[1] = (count >> 8) & 0xff ;
1233 memcpy(h->value + ZB_ZCL_LONG_OCTET_SIZE, value, count);
1236 return ZIGBEE_ERROR_NOT_SUPPORTED;
1239 return ZIGBEE_ERROR_NONE;
1244 * @brief Format of the Selector Field
1249 unsigned char indicator; /**< number of index */
1250 unsigned short *index; /**< index list */
1254 * @brief Stcuture for reading attribute
1258 struct read_structured_attribute_record_s {
1259 unsigned short id; /**< attribute identifier */
1260 struct selector_s *selector; /**< selector format */
1264 * @brief Format of the Write Attribute Record Field
1268 struct write_attribute_structured_status_record_s {
1269 unsigned char status; /**< status */
1270 unsigned short id; /**< identifier */
1271 struct selector_s selector; /**< selector */
1275 * @brief Format of the Write Attribute Record Field
1279 struct write_attribute_structured_record_s {
1280 unsigned short id; /**< attribute identifier */
1281 struct selector_s selector;
1282 unsigned char type; /**< attribute data type */
1283 unsigned char *value; /**< data value */; /**< attribute value */
1286 API int zb_extended_attr_info_create(zb_zcl_extended_attr_info_h *handle)
1288 zb_zcl_extended_attr_info_h t = NULL;
1290 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1291 RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
1292 CHECK_ZIGBEE_PRIVILEGE();
1294 t = calloc(1, sizeof(struct extended_attribute_infomation_s));
1295 RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
1298 return ZIGBEE_ERROR_NONE;
1301 API int zb_extended_attr_info_clone(zb_zcl_extended_attr_info_h src,
1302 zb_zcl_extended_attr_info_h *dst)
1304 struct extended_attribute_infomation_s *srcs = src;
1305 struct extended_attribute_infomation_s *desc = NULL;
1307 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1308 RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER);
1309 RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER);
1311 desc = calloc(1, sizeof(struct extended_attribute_infomation_s));
1312 RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
1314 memcpy(desc, srcs, sizeof(struct extended_attribute_infomation_s));
1318 return ZIGBEE_ERROR_NONE;
1321 API int zb_extended_attr_info_destroy(zb_zcl_extended_attr_info_h handle)
1323 struct extended_attribute_infomation_s *h = handle;
1325 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1326 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1330 return ZIGBEE_ERROR_NONE;
1333 API int zb_extended_attr_info_get_id(zb_zcl_extended_attr_info_h handle,
1336 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1338 struct extended_attribute_infomation_s *h = handle;
1339 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1340 RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
1343 return ZIGBEE_ERROR_NONE;
1346 API int zb_extended_attr_info_set_id(zb_zcl_extended_attr_info_h handle,
1349 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1351 struct extended_attribute_infomation_s *h = handle;
1352 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1355 return ZIGBEE_ERROR_NONE;
1358 API int zb_extended_attr_info_get_type(zb_zcl_extended_attr_info_h handle,
1359 zb_zcl_data_type_e *type)
1361 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1363 struct extended_attribute_infomation_s *h = handle;
1364 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1365 RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
1368 return ZIGBEE_ERROR_NONE;
1371 API int zb_extended_attr_info_set_type(zb_zcl_extended_attr_info_h handle,
1372 zb_zcl_data_type_e type)
1374 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1376 struct extended_attribute_infomation_s *h = handle;
1377 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1378 RETV_IF(0 >= zb_zcl_get_data_size(type), ZIGBEE_ERROR_INVALID_PARAMETER);
1381 return ZIGBEE_ERROR_NONE;
1384 API int zb_extended_attr_info_get_acl(zb_zcl_extended_attr_info_h handle,
1385 zb_zcl_acl_type_e *acl)
1387 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1389 struct extended_attribute_infomation_s *h = handle;
1390 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1391 RETV_IF(NULL == acl, ZIGBEE_ERROR_INVALID_PARAMETER);
1394 return ZIGBEE_ERROR_NONE;
1397 API int zb_extended_attr_info_set_acl(zb_zcl_extended_attr_info_h handle,
1398 zb_zcl_acl_type_e acl)
1400 CHECK_FEATURE_SUPPORTED(ZIGBEE_FEATURE);
1402 struct extended_attribute_infomation_s *h = handle;
1403 RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
1406 return ZIGBEE_ERROR_NONE;