return analog_discrete_thresholds[index+1];
}
-API int zb_get_data_size(unsigned char type)
+API int zb_get_data_size(zb_zcl_data_type_e type)
{
int i;
int count;
memcpy(h->value, v->val, len);
} else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) {
RETV_IF(NULL == v->str, ZIGBEE_ERROR_NO_DATA);
- h->value = calloc(v->str->n + sizeof(v->str->n), sizeof(char));
+ h->value = calloc(v->str->n + sizeof(char), 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);
+ memcpy(h->value + sizeof(char), v->str->v + sizeof(char), v->str->n);
} else if (ZB_ZCL_LONG_OCTAT_STRING == type || ZB_ZCL_LONG_CHRACTER_STRING == type) {
RETV_IF(NULL == v->wstr, ZIGBEE_ERROR_NO_DATA);
- h->value = calloc(v->wstr->n + sizeof(v->wstr->n), sizeof(char));
+ h->value = calloc(v->wstr->n + sizeof(short), 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);
+ memcpy(h->value + sizeof(short), v->wstr->v + sizeof(short), v->wstr->n);
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
*count = len;
} 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);
+ s = calloc(sizeof(char), h->str->n);
RETV_IF(NULL == s, ZIGBEE_ERROR_OUT_OF_MEMORY);
- memcpy(s, h->str->v+sizeof(h->str->n), h->str->n);
+ memcpy(s, h->str->v + sizeof(char), h->str->n);
*count = h->str->n;
} else if (ZB_ZCL_LONG_OCTAT_STRING == h->type || ZB_ZCL_LONG_CHRACTER_STRING == h->type) {
RETV_IF(NULL == h->wstr, ZIGBEE_ERROR_NO_DATA);
- s = calloc(sizeof(unsigned char), h->wstr->n);
+ s = calloc(sizeof(char), h->wstr->n);
RETV_IF(NULL == s, ZIGBEE_ERROR_OUT_OF_MEMORY);
- memcpy(s, h->wstr->v+sizeof(h->wstr->n), h->wstr->n);
+ memcpy(s, h->wstr->v + sizeof(short), h->wstr->n);
*count = h->wstr->n;
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
RETV_IF(NULL == v->str, ZIGBEE_ERROR_NO_DATA);
/* 1 byte string size exception case */
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));
+ h->value = calloc(v->str->n + sizeof(char), sizeof(char));
RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
/* The first 1 byte indicate invalid or length of string */
h->value[0] = v->str->n & 0xff;
- memcpy(h->value + sizeof(v->str->n),
- v->str->v + sizeof(v->str->n), v->str->n);
+ memcpy(h->value + sizeof(char), v->str->v + sizeof(char), 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 < v->wstr->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
- h->value = calloc(v->wstr->n + sizeof(v->wstr->n), sizeof(char));
+ h->value = calloc(v->wstr->n + sizeof(short), sizeof(char));
RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
/* The first 2 byte indicate invalid or length of string */
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);
+ memcpy(h->value + sizeof(short), v->wstr->v + sizeof(short), v->wstr->n);
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;
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));
+ h->value = calloc(v->str->n + sizeof(char), sizeof(char));
RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
/* The first 1 byte indicate invalid or length of string */
h->value[0] = v->str->n & 0xff;
- memcpy(h->value + sizeof(v->str->n),
- v->str->v + sizeof(v->str->n), v->str->n);
+ memcpy(h->value + sizeof(char), v->str->v + sizeof(char), 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));
+ h->value = calloc(v->wstr->n + sizeof(short), sizeof(char));
RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
/* The first 2 byte indicate invalid or length of string */
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);
+ memcpy(h->value + sizeof(short), v->wstr->v + sizeof(short), v->wstr->n);
} else
return ZIGBEE_ERROR_NOT_SUPPORTED;