API void zb_destroy_read_attr_status_record(read_attr_status_record_h handle)
{
- RET_IF(NULL == handle);
- if (handle->value)
- free(handle->value);
- free(handle);
+ struct read_attribute_status_record_s* h = handle;
+ RET_IF(NULL == h);
+ if (h->value)
+ free(h->value);
+ free(h);
}
API int zb_get_id_from_read_attr_status_record(read_attr_status_record_h handle,
unsigned short* id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct read_attribute_status_record_s* h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
- *id = handle->id;
+ *id = h->id;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_id_to_read_attr_status_record(read_attr_status_record_h handle,
unsigned short id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->id = id;
+ struct read_attribute_status_record_s* h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->id = id;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_status_from_read_attr_status_record(read_attr_status_record_h handle,
unsigned char* status)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct read_attribute_status_record_s* h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER);
- *status = handle->status;
+ *status = h->status;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_status_to_read_attr_status_record(read_attr_status_record_h handle,
unsigned char status)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->status = status;
+ struct read_attribute_status_record_s* h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->status = status;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_type_from_read_attr_status_record(read_attr_status_record_h handle,
unsigned char *type)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct read_attribute_status_record_s* h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
- *type = handle->type;
+ *type = h->type;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_type_to_read_attr_status_record(read_attr_status_record_h handle,
unsigned char type)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->type = type;
+ struct read_attribute_status_record_s* h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->type = type;
return ZIGBEE_ERROR_NONE;
}
unsigned char type, zb_value_h value)
{
int len = -1;
+ struct zb_value_s *v = value;
+ struct read_attribute_status_record_s* h = handle;
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_NO_DATA);
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_NO_DATA);
len = zb_get_data_size(type);
if (0 < len) {
- memcpy(value->val, handle->value, len);
- value->size = len;
- value->type = type;
+ memcpy(v->val, h->value, len);
+ v->size = len;
+ v->type = type;
} else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) {
- if (value->str) {
- if (value->str->v)
- free(value->str->v);
- free(value->str);
+ if (v->str) {
+ if (v->str->v)
+ free(v->str->v);
+ free(v->str);
}
- value->str = calloc(1, sizeof(struct attribute_str_s));
- RETV_IF(NULL == value->str, ZIGBEE_ERROR_OUT_OF_MEMORY);
- value->str->n = *handle->value;
+ v->str = calloc(1, sizeof(struct attribute_str_s));
+ RETV_IF(NULL == v->str, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ v->str->n = *h->value;
/* The first 1 byte indicate invalid or length of string */
- if (0xff == value->str->n) {
- free(value->str);
+ if (0xff == v->str->n) {
+ free(v->str);
return ZIGBEE_ERROR_NO_DATA;
}
- value->str->v = calloc(value->str->n+1, 1);
- if (NULL == value->str->v) {
- free(value->str);
+ v->str->v = calloc(v->str->n+1, 1);
+ if (NULL == v->str->v) {
+ free(v->str);
return ZIGBEE_ERROR_OUT_OF_MEMORY;
}
- memcpy(value->str->v, handle->value+sizeof(value->str->n), value->str->n);
+ memcpy(v->str->v, h->value+sizeof(v->str->n), v->str->n);
- value->type = type;
- value->size = value->str->n;
+ v->type = type;
+ v->size = v->str->n;
} else if (ZB_ZCL_LONG_OCTAT_STRING == type || ZB_ZCL_LONG_CHRACTER_STRING == type) {
- if (value->wstr) {
- if (value->wstr->v)
- free(value->wstr->v);
- free(value->wstr);
+ if (v->wstr) {
+ if (v->wstr->v)
+ free(v->wstr->v);
+ free(v->wstr);
}
- value->wstr = calloc(1, sizeof(struct attribute_wstr_s));
- RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY);
- value->wstr->n = *(handle->value+1) << 8 | *handle->value;
+ v->wstr = calloc(1, sizeof(struct attribute_wstr_s));
+ RETV_IF(NULL == v->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ v->wstr->n = *(h->value+1) << 8 | *h->value;
/* The first 2 byte indicate invalid or length of string */
- if (0xffff == value->wstr->n) {
- free(value->wstr);
+ if (0xffff == v->wstr->n) {
+ free(v->wstr);
return ZIGBEE_ERROR_NO_DATA;
}
- value->wstr->v = calloc(value->wstr->n+1, 1);
- if (NULL == value->wstr->v) {
- free(value->wstr);
+ v->wstr->v = calloc(v->wstr->n+1, 1);
+ if (NULL == v->wstr->v) {
+ free(v->wstr);
return ZIGBEE_ERROR_OUT_OF_MEMORY;
}
- memcpy(value->wstr->v, handle->value+sizeof(value->wstr->n), value->wstr->n);
+ memcpy(v->wstr->v, h->value+sizeof(v->wstr->n), v->wstr->n);
- value->type = type;
- value->size = value->wstr->n;
+ v->type = type;
+ v->size = v->wstr->n;
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
unsigned char type, zb_value_h value)
{
int len = -1;
+ struct zb_value_s *v = value;
+ struct read_attribute_status_record_s* h = handle;
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
- if (handle->value)
- free(handle->value);
+ if (h->value)
+ free(h->value);
len = zb_get_data_size(type);
if (0 < len) {
- handle->value = calloc(len, sizeof(char));
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
- memcpy(handle->value, value->val, len);
+ h->value = calloc(len, sizeof(char));
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ memcpy(h->value, v->val, len);
} else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) {
- RETV_IF(NULL == value->str, ZIGBEE_ERROR_NO_DATA);
- handle->value = calloc(value->str->n + sizeof(value->str->n), sizeof(char));
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
- handle->value[0] = value->str->n;
- memcpy(handle->value + sizeof(value->str->n),
- value->str->v+sizeof(value->str->n), value->str->n);
+ RETV_IF(NULL == v->str, ZIGBEE_ERROR_NO_DATA);
+ h->value = calloc(v->str->n + sizeof(v->str->n), sizeof(char));
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ h->value[0] = v->str->n;
+ memcpy(h->value + sizeof(v->str->n),
+ v->str->v+sizeof(v->str->n), v->str->n);
} else if (ZB_ZCL_LONG_OCTAT_STRING == type || ZB_ZCL_LONG_CHRACTER_STRING == type) {
- RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_NO_DATA);
- handle->value = calloc(value->wstr->n + sizeof(value->wstr->n), sizeof(char));
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
- handle->value[0] = value->wstr->n & 0xff;
- handle->value[1] = (value->wstr->n >> 8) & 0xff ;
- memcpy(handle->value + sizeof(value->wstr->n),
- value->wstr->v+sizeof(value->wstr->n), value->wstr->n);
+ RETV_IF(NULL == v->wstr, ZIGBEE_ERROR_NO_DATA);
+ h->value = calloc(v->wstr->n + sizeof(v->wstr->n), sizeof(char));
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ h->value[0] = v->wstr->n & 0xff;
+ h->value[1] = (v->wstr->n >> 8) & 0xff ;
+ memcpy(h->value + sizeof(v->wstr->n),
+ v->wstr->v+sizeof(v->wstr->n), v->wstr->n);
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
API void zb_destroy_value(zb_value_h handle)
{
- RET_IF(NULL == handle);
- if (handle->str) {
- if (handle->str->v)
- free(handle->str->v);
- free(handle->str);
+ struct zb_value_s* h = handle;
+
+ RET_IF(NULL == h);
+ if (h->str) {
+ if (h->str->v)
+ free(h->str->v);
+ free(h->str);
}
- if (handle->wstr) {
- if (handle->wstr->v)
- free(handle->wstr->v);
- free(handle->wstr);
+ if (h->wstr) {
+ if (h->wstr->v)
+ free(h->wstr->v);
+ free(h->wstr);
}
- free(handle);
+ free(h);
}
API int zb_set_value(zb_value_h handle, unsigned char type, unsigned char *value,
int count)
{
int len = -1;
+ struct zb_value_s* h = handle;
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
len = zb_get_data_size(type);
if (0 < len) {
- memcpy(handle->val, value, len);
- handle->size = len;
- handle->type = type;
+ memcpy(h->val, value, len);
+ h->size = len;
+ h->type = type;
} else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) {
- if (handle->str) {
- if (handle->str->v)
- free(handle->str->v);
- free(handle->str);
+ if (h->str) {
+ if (h->str->v)
+ free(h->str->v);
+ free(h->str);
}
/* string size exception case */
- RETV_IF(0xff - 1 < handle->str->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
- handle->str = malloc(sizeof(struct attribute_str_s));
- RETV_IF(NULL == handle->str, ZIGBEE_ERROR_OUT_OF_MEMORY);
- handle->str->n = count;
+ RETV_IF(0xff - 1 < h->str->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
+ h->str = malloc(sizeof(struct attribute_str_s));
+ RETV_IF(NULL == h->str, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ h->str->n = count;
/* The first 1 byte indicate invalid or length of string */
- handle->str->v = calloc(sizeof(unsigned char), handle->str->n + sizeof(handle->str->n));
- RETV_IF(NULL == handle->str->v, ZIGBEE_ERROR_OUT_OF_MEMORY);
- memcpy(handle->str->v, value+sizeof(handle->str->n), handle->str->n);
+ h->str->v = calloc(sizeof(unsigned char), h->str->n + sizeof(h->str->n));
+ RETV_IF(NULL == h->str->v, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ memcpy(h->str->v, value+sizeof(h->str->n), h->str->n);
- handle->type = type;
- handle->size = count;
+ h->type = type;
+ h->size = count;
} else if (ZB_ZCL_LONG_OCTAT_STRING == type || ZB_ZCL_LONG_CHRACTER_STRING == type) {
- if (handle->wstr) {
- if (handle->wstr->v)
- free(handle->wstr->v);
- free(handle->wstr);
+ if (h->wstr) {
+ if (h->wstr->v)
+ free(h->wstr->v);
+ free(h->wstr);
}
/* 2 byte string size exception case */
- RETV_IF(0xffff - 1 < handle->wstr->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
- handle->wstr = malloc(sizeof(struct attribute_wstr_s));
- RETV_IF(NULL == handle->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY);
- handle->wstr->n = count;
+ RETV_IF(0xffff - 1 < h->wstr->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
+ h->wstr = malloc(sizeof(struct attribute_wstr_s));
+ RETV_IF(NULL == h->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ h->wstr->n = count;
/* The first 2 byte indicate invalid or length of string */
- handle->wstr->v = calloc(sizeof(unsigned char), handle->wstr->n + sizeof(handle->wstr->n));
- RETV_IF(NULL == handle->wstr->v, ZIGBEE_ERROR_OUT_OF_MEMORY);
- memcpy(handle->wstr->v, value+sizeof(handle->wstr->n), handle->wstr->n);
+ h->wstr->v = calloc(sizeof(unsigned char), h->wstr->n + sizeof(h->wstr->n));
+ RETV_IF(NULL == h->wstr->v, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ memcpy(h->wstr->v, value+sizeof(h->wstr->n), h->wstr->n);
- handle->type = type;
- handle->size = count;
+ h->type = type;
+ h->size = count;
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
{
int len = -1;
unsigned char *s = NULL;
+ struct zb_value_s* h = handle;
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
- len = zb_get_data_size(handle->type);
+ len = zb_get_data_size(h->type);
if (0 < len) {
- s = calloc(handle->size + 1 , sizeof(char));
- memcpy(s, handle->val, len);
+ s = calloc(h->size + 1 , sizeof(char));
+ memcpy(s, h->val, len);
*count = len;
- } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) {
- RETV_IF(NULL == handle->str, ZIGBEE_ERROR_NO_DATA);
- s = calloc(sizeof(unsigned char), handle->str->n);
+ } else if (ZB_ZCL_OCTAT_STRING == h->type || ZB_ZCL_CHRACTER_STRING == h->type) {
+ RETV_IF(NULL == h->str, ZIGBEE_ERROR_NO_DATA);
+ s = calloc(sizeof(unsigned char), h->str->n);
RETV_IF(NULL == s, ZIGBEE_ERROR_OUT_OF_MEMORY);
- memcpy(s, handle->str->v+sizeof(handle->str->n), handle->str->n);
- *count = handle->str->n;
- } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) {
- RETV_IF(NULL == handle->wstr, ZIGBEE_ERROR_NO_DATA);
- s = calloc(sizeof(unsigned char), handle->wstr->n);
+ memcpy(s, h->str->v+sizeof(h->str->n), h->str->n);
+ *count = h->str->n;
+ } else if (ZB_ZCL_OCTAT_STRING == h->type || ZB_ZCL_CHRACTER_STRING == h->type) {
+ RETV_IF(NULL == h->wstr, ZIGBEE_ERROR_NO_DATA);
+ s = calloc(sizeof(unsigned char), h->wstr->n);
RETV_IF(NULL == s, ZIGBEE_ERROR_OUT_OF_MEMORY);
- memcpy(s, handle->wstr->v+sizeof(handle->wstr->n), handle->wstr->n);
- *count = handle->wstr->n;
+ memcpy(s, h->wstr->v+sizeof(h->wstr->n), h->wstr->n);
+ *count = h->wstr->n;
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
- *type = handle->type;
+ *type = h->type;
*value = s;
return ZIGBEE_ERROR_NONE;
API void zb_destroy_discover_attr_info(discover_attr_info_record_h handle)
{
- free(handle);
+ struct discover_attribute_info_record_s *h = handle;
+ free(h);
}
API int zb_get_id_from_discover_attr_info(
discover_attr_info_record_h handle,
unsigned short *id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct discover_attribute_info_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
- *id = handle->id;
+ *id = h->id;
return ZIGBEE_ERROR_NONE;
}
discover_attr_info_record_h handle,
unsigned short id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->id = id;
+ struct discover_attribute_info_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->id = id;
return ZIGBEE_ERROR_NONE;
}
discover_attr_info_record_h handle,
unsigned char *type)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct discover_attribute_info_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
- *type = handle->type;
+ *type = h->type;
return ZIGBEE_ERROR_NONE;
}
discover_attr_info_record_h handle,
unsigned char type)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->type = type;
+ struct discover_attribute_info_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->type = type;
return ZIGBEE_ERROR_NONE;
}
API void zb_destroy_write_attr_record(write_attr_record_h handle)
{
- RET_IF(NULL == handle);
- if (handle->value)
- free(handle->value);
- free(handle);
+ struct write_attribute_record_s* h = handle;
+ RET_IF(NULL == h);
+ if (h->value)
+ free(h->value);
+ free(h);
}
API int zb_set_id_to_write_attr_record(write_attr_record_h handle,
unsigned short id)
{
+ struct write_attribute_record_s* h = handle;
RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->id = id;
+ h->id = id;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_type_to_write_attr_record(write_attr_record_h handle,
unsigned char type)
{
+ struct write_attribute_record_s* h = handle;
RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->type = type;
+ h->type = type;
return ZIGBEE_ERROR_NONE;
}
unsigned char type, unsigned char *value, int count)
{
int len = -1;
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct write_attribute_record_s* h = handle;
+
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
- if (handle->value)
- free(handle->value);
+ if (h->value)
+ free(h->value);
len = zb_get_data_size(type);
if (0 < len) {
- handle->value = calloc(count + 1 , sizeof(char));
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
- memcpy(handle->value, value, count);
+ h->value = calloc(count + 1 , sizeof(char));
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ memcpy(h->value, value, count);
} else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) {
- handle->value = calloc(count + sizeof(unsigned char) + 1, sizeof(char));
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ h->value = calloc(count + sizeof(unsigned char) + 1, sizeof(char));
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
/* The first 1 byte indicate invalid or length of string */
- handle->value[0] = count & 0xff;
- memcpy(handle->value + sizeof(unsigned char), value + sizeof(unsigned char), count);
- } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) {
- handle->value = calloc(count + sizeof(unsigned short) + 1, sizeof(char));
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ h->value[0] = count & 0xff;
+ memcpy(h->value + sizeof(unsigned char), value + sizeof(unsigned char), count);
+ } else if (ZB_ZCL_LONG_OCTAT_STRING == h->type || ZB_ZCL_LONG_CHRACTER_STRING == h->type) {
+ h->value = calloc(count + sizeof(unsigned short) + 1, sizeof(char));
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
/* The first 2 byte indicate invalid or length of string */
- handle->value[0] = count & 0xff;
- handle->value[1] = (count >> 8) & 0xff ;
- memcpy(handle->value + sizeof(unsigned short), value + sizeof(unsigned short), count);
+ h->value[0] = count & 0xff;
+ h->value[1] = (count >> 8) & 0xff ;
+ memcpy(h->value + sizeof(unsigned short), value + sizeof(unsigned short), count);
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
{
int len = -1;
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct zb_value_s *v = value;
+ struct write_attribute_record_s* h = handle;
+
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
- if (handle->value)
- free(handle->value);
+ if (h->value)
+ free(h->value);
- len = zb_get_data_size(value->type);
+ len = zb_get_data_size(v->type);
if (0 < len) {
- handle->value = calloc(value->size + 1 , sizeof(char));
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
- memcpy(handle->value, value->val, value->size);
- handle->type = value->type;
- } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) {
- RETV_IF(NULL == value->str, ZIGBEE_ERROR_NO_DATA);
+ h->value = calloc(v->size + 1 , sizeof(char));
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ memcpy(h->value, v->val, v->size);
+ h->type = v->type;
+ } else if (ZB_ZCL_OCTAT_STRING == h->type || ZB_ZCL_CHRACTER_STRING == h->type) {
+ RETV_IF(NULL == v->str, ZIGBEE_ERROR_NO_DATA);
/* 1 byte string size exception case */
- RETV_IF(0xff - 1 < value->str->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
- handle->value = calloc(value->str->n + sizeof(value->str->n), sizeof(char));
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ RETV_IF(0xff - 1 < v->str->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
+ h->value = calloc(v->str->n + sizeof(v->str->n), sizeof(char));
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
/* The first 1 byte indicate invalid or length of string */
- handle->value[0] = value->str->n & 0xff;
- memcpy(handle->value + sizeof(value->str->n),
- value->str->v + sizeof(value->str->n), value->str->n);
- } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) {
- RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_NO_DATA);
+ h->value[0] = v->str->n & 0xff;
+ memcpy(h->value + sizeof(v->str->n),
+ v->str->v + sizeof(v->str->n), v->str->n);
+ } else if (ZB_ZCL_LONG_OCTAT_STRING == h->type || ZB_ZCL_LONG_CHRACTER_STRING == h->type) {
+ RETV_IF(NULL == v->wstr, ZIGBEE_ERROR_NO_DATA);
/* 2 byte string size exception case */
- RETV_IF(0xffff - 1 < value->wstr->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
- handle->value = calloc(value->wstr->n + sizeof(value->wstr->n), sizeof(char));
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ RETV_IF(0xffff - 1 < v->wstr->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
+ h->value = calloc(v->wstr->n + sizeof(v->wstr->n), sizeof(char));
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
/* The first 2 byte indicate invalid or length of string */
- handle->value[0] = value->wstr->n & 0xff;
- handle->value[1] = (value->wstr->n >> 8) & 0xff ;
- memcpy(handle->value + sizeof(value->wstr->n),
- value->wstr->v + sizeof(value->wstr->n), value->wstr->n);
+ h->value[0] = v->wstr->n & 0xff;
+ h->value[1] = (v->wstr->n >> 8) & 0xff ;
+ memcpy(h->value + sizeof(v->wstr->n),
+ v->wstr->v + sizeof(v->wstr->n), v->wstr->n);
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
API void zb_destroy_write_attr_status(write_attr_status_record_h handle)
{
- free(handle);
+ struct write_attribute_status_record_s *h = handle;
+ free(h);
}
API int zb_get_status_from_write_attr_status(write_attr_status_record_h handle,
unsigned char *status)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct write_attribute_status_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER);
- *status = handle->status;
+ *status = h->status;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_status_to_write_attr_status(write_attr_status_record_h handle,
unsigned char status)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->status = status;
+ struct write_attribute_status_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->status = status;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_id_from_write_attr_status(write_attr_status_record_h handle,
unsigned short *id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct write_attribute_status_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
- *id = handle->id;
+ *id = h->id;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_id_to_write_attr_status(write_attr_status_record_h handle,
unsigned short id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->id = id;
+ struct write_attribute_status_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->id = id;
return ZIGBEE_ERROR_NONE;
}
API void zb_destroy_report_config_record(report_config_record_h handle)
{
- RET_IF(NULL == handle);
- if (handle->change)
- free(handle->change);
- free(handle);
+ struct reporting_configuration_record_s *h = handle;
+ RET_IF(NULL == h);
+ if (h->change)
+ free(h->change);
+ free(h);
}
API int zb_get_dir_from_report_config_record(report_config_record_h handle,
unsigned char *dir)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == dir, ZIGBEE_ERROR_INVALID_PARAMETER);
- *dir = handle->dir;
+ *dir = h->dir;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_dir_to_report_config_record(report_config_record_h handle,
unsigned char dir)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
if (dir == ZB_ZCL_CLIENT_TO_SERVER)
- handle->dir = 0x00 ;
+ h->dir = 0x00 ;
else
- handle->dir = 0x01;
+ h->dir = 0x01;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_id_from_report_config_record(report_config_record_h handle,
unsigned short *id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
- *id = handle->id;
+ *id = h->id;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_id_to_report_config_record(report_config_record_h handle,
unsigned short id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->id = id ;
+ struct reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->id = id ;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_type_from_report_config_record(report_config_record_h handle,
unsigned char *type)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
- *type = handle->type;
+ *type = h->type;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_type_to_report_config_record(report_config_record_h handle,
unsigned char type)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->type = type;
+ struct reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->type = type;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_min_i_from_report_config_record(report_config_record_h handle,
unsigned short *min_i)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == min_i, ZIGBEE_ERROR_INVALID_PARAMETER);
- *min_i = handle->min_i;
+ *min_i = h->min_i;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_min_i_to_report_config_record(report_config_record_h handle,
unsigned short min_i)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->min_i = min_i;
+ struct reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->min_i = min_i;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_max_i_from_report_config_record(report_config_record_h handle,
unsigned short *max_i)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == max_i, ZIGBEE_ERROR_INVALID_PARAMETER);
- *max_i = handle->max_i;
+ *max_i = h->max_i;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_max_i_to_report_config_record(report_config_record_h handle,
unsigned short max_i)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->max_i = max_i;
+ struct reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->max_i = max_i;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_timeout_from_report_config_record(report_config_record_h handle,
unsigned short *to)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == to, ZIGBEE_ERROR_INVALID_PARAMETER);
- *to = handle->to;
+ *to = h->to;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_timeout_to_report_config_record(report_config_record_h handle,
unsigned short to)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->to = to;
+ struct reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->to = to;
return ZIGBEE_ERROR_NONE;
}
{
int len = -1;
int data_type = DATA_TYPE_NONE;
+ struct zb_value_s *v = value;
+ struct reporting_configuration_record_s *h = handle;
NOT_USED(data_type);
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == handle->change, ZIGBEE_ERROR_NO_DATA);
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == h->change, ZIGBEE_ERROR_NO_DATA);
- len = zb_get_data_size(handle->type);
- data_type = zb_get_analog_or_discret(handle->type);
+ len = zb_get_data_size(h->type);
+ data_type = zb_get_analog_or_discret(h->type);
if (0 < len /* && DATA_TYPE_ANALOG == data_type */) {
- memcpy(value->val, handle->change, len);
- value->type = handle->type;
- value->size = len;
+ memcpy(v->val, h->change, len);
+ v->type = h->type;
+ v->size = len;
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
int len = -1;
int data_type = DATA_TYPE_NONE;
+ struct zb_value_s *v = value;
+ struct reporting_configuration_record_s *h = handle;
+
NOT_USED(data_type);
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
- if (handle->change)
- free(handle->change);
+ if (h->change)
+ free(h->change);
- len = zb_get_data_size(value->type);
- data_type = zb_get_analog_or_discret(value->type);
+ len = zb_get_data_size(v->type);
+ data_type = zb_get_analog_or_discret(v->type);
if (0 < len /* && DATA_TYPE_ANALOG == data_type */) {
- handle->change = calloc(len + 1, sizeof(char));
- RETVM_IF(NULL == handle->change, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
- memcpy(handle->change, value->val, len);
- handle->type = value->type;
+ h->change = calloc(len + 1, sizeof(char));
+ RETVM_IF(NULL == h->change, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
+ memcpy(h->change, v->val, len);
+ h->type = v->type;
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
int data_type = DATA_TYPE_NONE;
unsigned char *t = NULL;
+ struct reporting_configuration_record_s *h = handle;
+
NOT_USED(data_type);
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == handle->change, ZIGBEE_ERROR_NO_DATA);
+ RETV_IF(NULL == h->change, ZIGBEE_ERROR_NO_DATA);
- len = zb_get_data_size(handle->type);
- data_type = zb_get_analog_or_discret(handle->type);
+ len = zb_get_data_size(h->type);
+ data_type = zb_get_analog_or_discret(h->type);
if (0 < len /* && DATA_TYPE_ANALOG == data_type */) {
t = calloc(len + 1, sizeof(char));
RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
- memcpy(t, handle->change, len);
+ memcpy(t, h->change, len);
*value = t;
- *type = handle->type;
+ *type = h->type;
*size = len;
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
int len = -1;
int data_type = DATA_TYPE_NONE;
+ struct reporting_configuration_record_s *h = handle;
+
NOT_USED(data_type);
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- if (handle->change)
- free(handle->change);
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ if (h->change)
+ free(h->change);
len = zb_get_data_size(type);
data_type = zb_get_analog_or_discret(type);
if (0 < len /* && DATA_TYPE_ANALOG == data_type */) {
- handle->change = calloc(len + 1, sizeof(unsigned char));
- RETVM_IF(NULL == handle->change, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
- memcpy(handle->change, value, len);
- handle->type = type;
+ h->change = calloc(len + 1, sizeof(unsigned char));
+ RETVM_IF(NULL == h->change, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
+ memcpy(h->change, value, len);
+ h->type = type;
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
int len = -1;
int data_type = DATA_TYPE_NONE;
+ struct reporting_configuration_record_s *h = handle;
+
NOT_USED(data_type);
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == handle->change, ZIGBEE_ERROR_NO_DATA);
+ RETV_IF(NULL == h->change, ZIGBEE_ERROR_NO_DATA);
- len = zb_get_data_size(handle->type);
- data_type = zb_get_analog_or_discret(handle->type);
+ len = zb_get_data_size(h->type);
+ data_type = zb_get_analog_or_discret(h->type);
if (0 < len /* && DATA_TYPE_ANALOG == data_type */) {
- memcpy(value, handle->change, len);
- *type = handle->type;
+ memcpy(value, h->change, len);
+ *type = h->type;
*size = len;
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
API void zb_destroy_read_report_config_record(read_report_config_record_h handle)
{
- free(handle);
+ struct read_reporting_configuration_record_s *h = handle;
+ free(h);
}
API int zb_set_dir_to_read_report_config_record(read_report_config_record_h handle,
unsigned char dir)
{
+ struct read_reporting_configuration_record_s *h = handle;
RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
if (dir == ZB_ZCL_CLIENT_TO_SERVER)
- handle->dir = 0x00;
+ h->dir = 0x00;
else
- handle->dir = 0x01;
+ h->dir = 0x01;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_dir_from_read_report_config_record(read_report_config_record_h handle,
unsigned char *dir)
{
+ struct read_reporting_configuration_record_s *h = handle;
RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- *dir = handle->dir;
+ *dir = h->dir;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_id_to_read_report_config_record(read_report_config_record_h handle,
unsigned short id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->id = id;
+ struct read_reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->id = id;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_id_from_read_report_config_record(read_report_config_record_h handle,
unsigned short *id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- *id = handle->id;
+ struct read_reporting_configuration_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ *id = h->id;
return ZIGBEE_ERROR_NONE;
}
API void zb_destroy_report_config_response_record(
report_config_response_record_h handle)
{
- free(handle);
+ struct reporting_configuration_response_record_s *h = handle;
+ free(h);
}
API int zb_get_status_from_report_config_response_record(
report_config_response_record_h handle, unsigned char *status)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct reporting_configuration_response_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER);
- *status = handle->status;
+ *status = h->status;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_status_to_report_config_response_record(
report_config_response_record_h handle, unsigned char status)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->status = status;
+ struct reporting_configuration_response_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->status = status;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_dir_from_report_config_response_record(
report_config_response_record_h handle, unsigned char *dir)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct reporting_configuration_response_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == dir, ZIGBEE_ERROR_INVALID_PARAMETER);
- *dir = handle->dir;
+ *dir = h->dir;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_dir_to_report_config_response_record(
report_config_response_record_h handle, unsigned char dir)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->dir = handle->dir;
+ struct reporting_configuration_response_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->dir = dir;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_id_from_report_config_response_record(
report_config_response_record_h handle, unsigned short *id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct reporting_configuration_response_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
- *id = handle->id;
+ *id = h->id;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_id_to_report_config_response_record(
report_config_response_record_h handle, unsigned short id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->id = id;
+ struct reporting_configuration_response_record_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->id = id;
return ZIGBEE_ERROR_NONE;
}
API void zb_destroy_attr_report(attr_report_h handle)
{
- if (handle) {
- if (handle->value)
- free(handle->value);
- free(handle);
+ struct attribute_report_s *h = handle;
+ if (h) {
+ if (h->value)
+ free(h->value);
+ free(h);
}
}
API int zb_get_id_from_attr_report(attr_report_h handle, unsigned short *id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct attribute_report_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
- *id = handle->id;
+ *id = h->id;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_id_to_attr_report(attr_report_h handle, unsigned short id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->id = id;
+ struct attribute_report_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->id = id;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_type_from_attr_report(attr_report_h handle, unsigned char *type)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct attribute_report_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
- *type = handle->type;
+ *type = h->type;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_type_to_attr_report(attr_report_h handle, unsigned char type)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->type = type;
+ struct attribute_report_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->type = type;
return ZIGBEE_ERROR_NONE;
}
{
int len = -1;
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_NO_DATA);
+ struct zb_value_s *v = value;
+ struct attribute_report_s *h = handle;
+
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_NO_DATA);
- len = zb_get_data_size(handle->type);
+ len = zb_get_data_size(h->type);
if (0 < len) {
- memcpy(value->val, handle->value, len);
- value->size = len;
- value->type = handle->type;
- } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) {
- if (value->str) {
- if (value->str->v)
- free(value->str->v);
- free(value->str);
+ memcpy(v->val, h->value, len);
+ v->size = len;
+ v->type = h->type;
+ } else if (ZB_ZCL_OCTAT_STRING == h->type || ZB_ZCL_CHRACTER_STRING == h->type) {
+ if (v->str) {
+ if (v->str->v)
+ free(v->str->v);
+ free(v->str);
}
- value->str = calloc(1, sizeof(struct attribute_str_s));
- RETV_IF(NULL == value->str, ZIGBEE_ERROR_OUT_OF_MEMORY);
- value->str->n = *handle->value;
+ v->str = calloc(1, sizeof(struct attribute_str_s));
+ RETV_IF(NULL == v->str, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ v->str->n = *h->value;
/* The first 1 byte indicate invalid or length of string */
- if (0xff == value->str->n) {
- free(value->str);
+ if (0xff == v->str->n) {
+ free(v->str);
return ZIGBEE_ERROR_NO_DATA;
}
- value->str->v = calloc(value->str->n+1, 1);
- if (NULL == value->str->v) {
- free(value->str);
+ v->str->v = calloc(v->str->n+1, 1);
+ if (NULL == v->str->v) {
+ free(v->str);
return ZIGBEE_ERROR_OUT_OF_MEMORY;
}
- memcpy(value->str->v, handle->value+sizeof(value->str->n), value->str->n);
-
- value->type = handle->type;
- value->size = value->str->n;
- } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) {
- if (value->wstr) {
- if (value->wstr->v)
- free(value->wstr->v);
- free(value->wstr);
+ memcpy(v->str->v, h->value+sizeof(v->str->n), v->str->n);
+
+ v->type = h->type;
+ v->size = v->str->n;
+ } else if (ZB_ZCL_LONG_OCTAT_STRING == h->type || ZB_ZCL_LONG_CHRACTER_STRING == h->type) {
+ if (v->wstr) {
+ if (v->wstr->v)
+ free(v->wstr->v);
+ free(v->wstr);
}
- value->wstr = calloc(1, sizeof(struct attribute_wstr_s));
- RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY);
- value->wstr->n = *(handle->value+1) << 8 | *handle->value;
+ v->wstr = calloc(1, sizeof(struct attribute_wstr_s));
+ RETV_IF(NULL == v->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ v->wstr->n = *(h->value+1) << 8 | *h->value;
/* The first 2 byte indicate invalid or length of string */
- if (0xffff == value->wstr->n) {
- free(value->wstr);
+ if (0xffff == v->wstr->n) {
+ free(v->wstr);
return ZIGBEE_ERROR_NO_DATA;
}
- value->wstr->v = calloc(value->wstr->n+1, 1);
- if (NULL == value->wstr->v) {
- free(value->wstr);
+ v->wstr->v = calloc(v->wstr->n+1, 1);
+ if (NULL == v->wstr->v) {
+ free(v->wstr);
return ZIGBEE_ERROR_OUT_OF_MEMORY;
}
- memcpy(value->wstr->v, handle->value+sizeof(value->wstr->n), value->wstr->n);
+ memcpy(v->wstr->v, h->value+sizeof(v->wstr->n), v->wstr->n);
- value->type = handle->type;
- value->size = value->wstr->n;
+ v->type = h->type;
+ v->size = v->wstr->n;
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
{
int len = -1;
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct zb_value_s *v = value;
+ struct attribute_report_s *h = handle;
+
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
- if (handle->value)
- free(handle->value);
+ if (h->value)
+ free(h->value);
- len = zb_get_data_size(value->type);
+ len = zb_get_data_size(v->type);
if (0 < len) {
- handle->value = calloc(value->size + 1 , sizeof(char));
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
- memcpy(handle->value, value->val, value->size);
- handle->type = value->type;
- } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) {
- RETV_IF(NULL == value->str, ZIGBEE_ERROR_NO_DATA);
- handle->value = calloc(value->str->n + sizeof(value->str->n), sizeof(char));
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ h->value = calloc(v->size + 1 , sizeof(char));
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ memcpy(h->value, v->val, v->size);
+ h->type = v->type;
+ } else if (ZB_ZCL_OCTAT_STRING == h->type || ZB_ZCL_CHRACTER_STRING == h->type) {
+ RETV_IF(NULL == v->str, ZIGBEE_ERROR_NO_DATA);
+ h->value = calloc(v->str->n + sizeof(v->str->n), sizeof(char));
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
/* The first 1 byte indicate invalid or length of string */
- handle->value[0] = value->str->n & 0xff;
- memcpy(handle->value + sizeof(value->str->n),
- value->str->v + sizeof(value->str->n), value->str->n);
- } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) {
- RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_NO_DATA);
- handle->value = calloc(value->wstr->n + sizeof(value->wstr->n), sizeof(char));
- RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+ h->value[0] = v->str->n & 0xff;
+ memcpy(h->value + sizeof(v->str->n),
+ v->str->v + sizeof(v->str->n), v->str->n);
+ } else if (ZB_ZCL_LONG_OCTAT_STRING == h->type || ZB_ZCL_LONG_CHRACTER_STRING == h->type) {
+ RETV_IF(NULL == v->wstr, ZIGBEE_ERROR_NO_DATA);
+ h->value = calloc(v->wstr->n + sizeof(v->wstr->n), sizeof(char));
+ RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
/* The first 2 byte indicate invalid or length of string */
- handle->value[0] = value->wstr->n & 0xff;
- handle->value[1] = (value->wstr->n >> 8) & 0xff ;
- memcpy(handle->value + sizeof(value->wstr->n),
- value->wstr->v + sizeof(value->wstr->n), value->wstr->n);
+ h->value[0] = v->wstr->n & 0xff;
+ h->value[1] = (v->wstr->n >> 8) & 0xff ;
+ memcpy(h->value + sizeof(v->wstr->n),
+ v->wstr->v + sizeof(v->wstr->n), v->wstr->n);
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
API void zb_destroy_extended_attr_info(extended_attr_info_h handle)
{
- free(handle);
+ struct extended_attribute_infomation_s *h = handle;
+ free(h);
}
API int zb_get_id_from_extended_attr_info(extended_attr_info_h handle,
unsigned short *id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct extended_attribute_infomation_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
- *id = handle->id;
+ *id = h->id;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_id_to_extended_attr_info(extended_attr_info_h handle,
unsigned short id)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->id = id;
+ struct extended_attribute_infomation_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->id = id;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_type_from_extended_attr_info(extended_attr_info_h handle,
unsigned char *type)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct extended_attribute_infomation_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
- *type = handle->type;
+ *type = h->type;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_type_to_extended_attr_info(extended_attr_info_h handle,
unsigned char type)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->type = type;
+ struct extended_attribute_infomation_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->type = type;
return ZIGBEE_ERROR_NONE;
}
API int zb_get_acl_from_extended_attr_info(extended_attr_info_h handle,
unsigned char *acl)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+ struct extended_attribute_infomation_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == acl, ZIGBEE_ERROR_INVALID_PARAMETER);
- *acl = handle->acl;
+ *acl = h->acl;
return ZIGBEE_ERROR_NONE;
}
API int zb_set_acl_to_extended_attr_info(extended_attr_info_h handle,
unsigned char acl)
{
- RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
- handle->acl = acl;
+ struct extended_attribute_infomation_s *h = handle;
+ RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+ h->acl = acl;
return ZIGBEE_ERROR_NONE;
}