for (i = 0; i < len; i++)
g_variant_builder_add(&builder, "s", arr->strArray[index + i]);
break;
+ case OCREP_PROP_BYTE_STRING:
+ for (i = 0; i < len; i++) {
+ var = g_variant_new_fixed_array(G_VARIANT_TYPE("y"),
+ arr->ocByteStrArray[index + i].bytes,
+ arr->ocByteStrArray[index + i].len,
+ sizeof(uint8_t));
+ g_variant_builder_add(&builder, "v", var);
+ }
+ break;
case OCREP_PROP_NULL:
for (i = 0; i < len; i++)
g_variant_builder_add(&builder, "s", IC_STR_NULL);
break;
case OCREP_PROP_OBJECT:
for (i = 0; i < len; i++) {
- GVariantBuilder *state_var = _icd_state_value_to_gvariant_builder(arr->objArray[index + i]);
+ GVariantBuilder *state_var
+ = _icd_state_value_to_gvariant_builder(arr->objArray[index + i]);
var = g_variant_builder_end(state_var);
g_variant_builder_add(&builder, "v", var);
}
case OCREP_PROP_STRING:
var = g_variant_new_string(val->str);
break;
+ case OCREP_PROP_BYTE_STRING:
+ var = g_variant_new_fixed_array(G_VARIANT_TYPE("y"), val->ocByteStr.bytes,
+ val->ocByteStr.len, sizeof(uint8_t));
+ break;
case OCREP_PROP_NULL:
var = g_variant_new_string(IC_STR_NULL);
break;
var = _icd_state_value_to_gvariant(val->obj);
break;
default:
- ERR("Invalid Type");
+ ERR("Invalid Type(%d)", val->type);
}
if (var) {
g_variant_builder_add(builder, "{sv}", val->name, var);
value_list->list = g_list_append(value_list->list, repr);
} while (g_variant_iter_loop(&iter, "v", &value));
+ } else if (g_variant_is_of_type(value, G_VARIANT_TYPE("ay"))) {
+ OCByteString *byte_str;
+ value_list->type = OCREP_PROP_BYTE_STRING;
+ do {
+ byte_str = calloc(1, sizeof(OCByteString));
+ if (NULL == byte_str) {
+ ERR("calloc() Fail(%d)", errno);
+ return;
+ }
+
+ byte_str->len = g_variant_get_size(value);
+ byte_str->bytes = calloc(byte_str->len, sizeof(uint8_t));
+ if (NULL == byte_str->bytes) {
+ ERR("calloc() Fail(%d)", errno);
+ free(byte_str);
+ return;
+ }
+ memcpy(byte_str->bytes, g_variant_get_data(value), byte_str->len);
+
+ value_list->list = g_list_append(value_list->list, byte_str);
+ } while (g_variant_iter_loop(&iter, "v", &value));
+
} else if (g_variant_is_of_type(value, G_VARIANT_TYPE_ARRAY)) {
do {
_icd_state_list_from_gvariant(value, value_list, depth + 1);
double *d_arr;
char **str_arr;
int64_t *i_arr;
+ OCByteString *byte_arr;
union icd_state_value_u *value;
struct OCRepPayload **state_arr;
str_arr[i] = strdup(node->data);
g_list_free_full(value_list->list, free);
OCRepPayloadSetStringArrayAsOwner(repr, key, str_arr, value_list->dimensions);
+ break;
+ case OCREP_PROP_BYTE_STRING:
+ byte_arr = calloc(len, sizeof(OCByteString));
+ if (NULL == byte_arr) {
+ ERR("calloc() Fail(%d)", errno);
+ return;
+ }
+ for (node = value_list->list, i = 0; node; node = node->next, i++) {
+ OCByteString *byte_str = node->data;
+ byte_arr[i].bytes = byte_str->bytes;
+ byte_arr[i].len = byte_str->len;
+ }
+ g_list_free(value_list->list);
+ OCRepPayloadSetByteStringArray(repr, key, byte_arr, value_list->dimensions);
+
break;
case OCREP_PROP_OBJECT:
state_arr = calloc(len, sizeof(struct OCRepPayload *));
else
OCRepPayloadSetPropString(repr, key, str_value);
+ } else if (g_variant_is_of_type(var, G_VARIANT_TYPE("ay"))) {
+ OCByteString byte_value;
+ byte_value.bytes = (uint8_t*)g_variant_get_data(var);
+ byte_value.len = g_variant_get_size(var);
+ OCRepPayloadSetPropByteString(repr, key, byte_value);
+
} else if (g_variant_is_of_type(var, G_VARIANT_TYPE("a{sv}"))) {
GVariantIter state_iter;
repr_value = OCRepPayloadCreate();
return 1;
}
break;
+ case OCREP_PROP_BYTE_STRING:
+ for (i = 0; i < len1; i++) {
+ if (IC_EQUAL != memcmp(arr1.ocByteStrArray[i].bytes,
+ arr2.ocByteStrArray[i].bytes, arr2.ocByteStrArray[i].len))
+ return 1;
+ }
+ break;
case OCREP_PROP_OBJECT:
for (i = 0; i < len1; i++) {
if (IC_EQUAL != icd_payload_representation_compare(arr1.objArray[i],
case OCREP_PROP_STRING:
ret = (IC_STR_EQUAL == g_strcmp0(value1->str, value2->str)) ? IC_EQUAL : 1;
break;
+ case OCREP_PROP_BYTE_STRING:
+ ret = (IC_EQUAL == memcmp(value1->ocByteStr.bytes, value2->ocByteStr.bytes,
+ value2->ocByteStr.len));
+ break;
case OCREP_PROP_OBJECT:
ret = icd_payload_representation_compare(value1->obj, value2->obj);
break;
}
+API int iotcon_list_add_byte_str(iotcon_list_h list, unsigned char *val, int len, int pos)
+{
+ iotcon_value_h value;
+
+ RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
+ RETVM_IF(IOTCON_TYPE_BYTE_STR != list->type, IOTCON_ERROR_INVALID_TYPE,
+ "Invalid Type(%d)", list->type);
+
+ value = icl_value_create_byte_str(val, len);
+ if (NULL == value) {
+ ERR("icl_value_create_str() Fail");
+ return IOTCON_ERROR_OUT_OF_MEMORY;
+ }
+
+ return icl_list_insert(list, value, pos);
+}
+
+
API int iotcon_list_add_list(iotcon_list_h list, iotcon_list_h val, int pos)
{
iotcon_value_h value;
}
+API int iotcon_list_get_nth_byte_str(iotcon_list_h list, int pos, unsigned char **val,
+ int *len)
+{
+ unsigned char *byte_val;
+ int ret, byte_len;
+ iotcon_value_h value;
+
+ RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == list->list, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == len, IOTCON_ERROR_INVALID_PARAMETER);
+
+ value = g_list_nth_data(list->list, pos);
+ if (NULL == value) {
+ ERR("g_list_nth_data() Fail");
+ return IOTCON_ERROR_NO_DATA;
+ }
+
+ ret = icl_value_get_byte_str(value, &byte_val, &byte_len);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("icl_value_get_byte_str() Fail(%d)", ret);
+ return IOTCON_ERROR_REPRESENTATION;
+ }
+
+ *val = byte_val;
+ *len = byte_len;
+
+ return IOTCON_ERROR_NONE;
+}
+
+
API int iotcon_list_get_nth_list(iotcon_list_h src, int pos, iotcon_list_h *dest)
{
int ret;
}
-static int _icl_list_remove_nth_value(iotcon_list_h list, int pos)
+API int iotcon_list_remove_nth(iotcon_list_h list, int pos)
{
iotcon_value_h value;
return IOTCON_ERROR_NO_DATA;
}
- if (IOTCON_TYPE_STR == value->type) {
- icl_basic_s *real = (icl_basic_s*)value;
- free(real->val.s);
- } else if (IOTCON_TYPE_LIST == value->type) {
- icl_val_list_s *real = (icl_val_list_s*)value;
- iotcon_list_destroy(real->list);
- } else if (IOTCON_TYPE_STATE == value->type) {
- icl_val_state_s *real = (icl_val_state_s*)value;
- iotcon_state_destroy(real->state);
- }
+ list->list = g_list_remove(list->list, value);
+
+ icl_value_destroy(value);
- icl_list_remove(list, value);
return IOTCON_ERROR_NONE;
}
-API int iotcon_list_remove_nth(iotcon_list_h list, int pos)
-{
- int ret;
-
- ret = _icl_list_remove_nth_value(list, pos);
- if (IOTCON_ERROR_NONE != ret)
- ERR("_icl_list_remove_nth_value() Fail(%d)", ret);
-
- return ret;
-}
-
API int iotcon_list_get_type(iotcon_list_h list, iotcon_type_e *type)
{
RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
}
-int icl_list_remove(iotcon_list_h list, iotcon_value_h val)
-{
- RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
-
- list->list = g_list_remove(list->list, val);
-
- return IOTCON_ERROR_NONE;
-}
-
-
int icl_list_insert(iotcon_list_h list, iotcon_value_h value, int pos)
{
RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
return IOTCON_ERROR_NONE;
}
+API int iotcon_list_foreach_byte_str(iotcon_list_h list, iotcon_list_byte_str_cb cb,
+ void *user_data)
+{
+ GList *cur;
+ int index = 0;
+ icl_val_byte_str_s *real = NULL;
+
+ RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+ RETVM_IF(IOTCON_TYPE_BYTE_STR != list->type, IOTCON_ERROR_INVALID_TYPE,
+ "Invalid Type(%d)", list->type);
+ RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+
+ cur = list->list;
+ while (cur) {
+ GList *next = cur->next;
+ real = cur->data;
+ if (IOTCON_FUNC_STOP == cb(index, real->s, real->len, user_data))
+ break;
+ index++;
+ cur = next;
+ }
+
+ return IOTCON_ERROR_NONE;
+}
+
API int iotcon_list_foreach_list(iotcon_list_h list, iotcon_list_list_cb cb,
void *user_data)
{
case IOTCON_TYPE_DOUBLE:
case IOTCON_TYPE_STR:
case IOTCON_TYPE_NULL:
+ case IOTCON_TYPE_BYTE_STR:
ret = _icl_list_clone_value(list, ret_list);
if (IOTCON_ERROR_NONE != ret) {
ERR("_icl_list_clone_value() Fail(%d)", ret);
g_variant_builder_add(&builder, "s", ((icl_basic_s*)state_value)->val.s);
}
break;
+ case IOTCON_TYPE_BYTE_STR:
+ for (node = list->list; node; node = node->next) {
+ state_value = node->data;
+ var = g_variant_new_fixed_array(G_VARIANT_TYPE("y"),
+ ((icl_val_byte_str_s*)state_value)->s,
+ ((icl_val_byte_str_s*)state_value)->len,
+ sizeof(unsigned char));
+ g_variant_builder_add(&builder, "v", var);
+ }
+ break;
case IOTCON_TYPE_LIST:
for (node = list->list; node; node = node->next) {
state_value = node->data;
case IOTCON_TYPE_NULL:
var = g_variant_new_string(IC_STR_NULL);
break;
+ case IOTCON_TYPE_BYTE_STR:
+ var = g_variant_new_fixed_array(G_VARIANT_TYPE("y"),
+ ((icl_val_byte_str_s*)state_value)->s,
+ ((icl_val_byte_str_s*)state_value)->len,
+ sizeof(unsigned char));
+ break;
case IOTCON_TYPE_LIST:
var = _icl_state_list_to_gvariant(((icl_val_list_s*)state_value)->list);
break;
g_variant_iter_init(&state_iter, var);
icl_state_from_gvariant(state_value, &state_iter);
value = icl_value_create_state(state_value);
+ } else if (g_variant_is_of_type(var, G_VARIANT_TYPE("ay"))) {
+ value = icl_value_create_byte_str(g_variant_get_data(var),
+ g_variant_get_size(var));
} else if (g_variant_is_of_type(var, G_VARIANT_TYPE_ARRAY)) {
list_value = _icl_state_list_from_gvariant(var);
value = icl_value_create_list(list_value);
g_variant_iter_init(&state_iter, variant);
icl_state_from_gvariant(state_value, &state_iter);
iotcon_list_add_state(list, state_value, -1);
+ } else if (g_variant_is_of_type(variant, G_VARIANT_TYPE("ay"))) {
+ unsigned char *byte_str;
+ if (NULL == list) {
+ ret = iotcon_list_create(IOTCON_TYPE_BYTE_STR, &list);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_list_create() Fail(%d)", ret);
+ return NULL;
+ }
+ }
+ byte_str = (unsigned char*)g_variant_get_data(variant);
+ iotcon_list_add_byte_str(list, byte_str, g_variant_get_size(variant), -1);
} else if (g_variant_is_of_type(variant, G_VARIANT_TYPE_ARRAY)) {
if (NULL == list) {
ret = iotcon_list_create(IOTCON_TYPE_LIST, &list);
}
-int icl_state_del_value(iotcon_state_h state, const char *key)
+API int iotcon_state_remove(iotcon_state_h state, const char *key)
{
gboolean ret = FALSE;
iotcon_value_h value = NULL;
return IOTCON_ERROR_NONE;
}
+
API int iotcon_state_get_int(iotcon_state_h state, const char *key, int *val)
{
iotcon_value_h value;
return IOTCON_ERROR_NONE;
}
-API int iotcon_state_remove(iotcon_state_h state, const char *key)
-{
- int ret;
-
- RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
-
- ret = icl_state_del_value(state, key);
- if (IOTCON_ERROR_NONE != ret)
- ERR("icl_state_del_value() Fail(%d)", ret);
-
- return ret;
-}
-
API int iotcon_state_get_bool(iotcon_state_h state, const char *key, bool *val)
{
icl_basic_s *real = NULL;
return IOTCON_ERROR_NONE;
}
+API int iotcon_state_get_byte_str(iotcon_state_h state, const char *key,
+ unsigned char **val, int *len)
+{
+ iotcon_value_h value = NULL;
+ icl_val_byte_str_s *real = NULL;
+
+ RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == len, IOTCON_ERROR_INVALID_PARAMETER);
+
+ value = g_hash_table_lookup(state->hash_table, key);
+ if (NULL == value) {
+ ERR("g_hash_table_lookup() Fail");
+ return IOTCON_ERROR_NO_DATA;
+ }
+
+ real = (icl_val_byte_str_s*)value;
+ if (IOTCON_TYPE_BYTE_STR != real->type) {
+ ERR("Invalid Type(%d)", real->type);
+ return IOTCON_ERROR_INVALID_TYPE;
+ }
+
+ *val = real->s;
+ *len = real->len;
+
+ return IOTCON_ERROR_NONE;
+}
+
+API int iotcon_state_add_byte_str(iotcon_state_h state, const char *key,
+ unsigned char *val, int len)
+{
+ iotcon_value_h value = NULL;
+
+ RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(len <= 0, IOTCON_ERROR_INVALID_PARAMETER);
+
+ value = icl_value_create_byte_str(val, len);
+ if (NULL == value) {
+ ERR("icl_value_create_byte_str() Fail");
+ return IOTCON_ERROR_OUT_OF_MEMORY;
+ }
+
+ g_hash_table_replace(state->hash_table, ic_utils_strdup(key), value);
+
+ return IOTCON_ERROR_NONE;
+}
+
API int iotcon_state_is_null(iotcon_state_h state, const char *key, bool *is_null)
{
icl_basic_s *real = NULL;
case IOTCON_TYPE_BOOL:
case IOTCON_TYPE_DOUBLE:
case IOTCON_TYPE_STR:
+ case IOTCON_TYPE_BYTE_STR:
case IOTCON_TYPE_NULL:
copied_val = icl_value_clone(src_val);
if (NULL == copied_val) {
#include "icl-value.h"
#include "icl-representation.h"
-int icl_state_del_value(iotcon_state_h state, const char *key);
-
int icl_state_set_value(iotcon_state_h state, const char *key, iotcon_value_h value);
void icl_state_clone_foreach(char *key, iotcon_value_h src_val,
case IOTCON_TYPE_NULL:
ret_val = calloc(1, sizeof(icl_basic_s));
break;
+ case IOTCON_TYPE_BYTE_STR:
+ ret_val = calloc(1, sizeof(icl_val_byte_str_s));
+ break;
case IOTCON_TYPE_LIST:
ret_val = calloc(1, sizeof(icl_val_list_s));
break;
}
+iotcon_value_h icl_value_create_byte_str(const unsigned char *val, int len)
+{
+ icl_val_byte_str_s *value;
+
+ RETV_IF(NULL == val, NULL);
+
+ value = (icl_val_byte_str_s*)_icl_value_create(IOTCON_TYPE_BYTE_STR);
+ if (NULL == value) {
+ ERR("_icl_value_create(BYTE STRING) Fail");
+ return NULL;
+ }
+
+ value->s = calloc(len, sizeof(unsigned char));
+ if (NULL == value->s) {
+ ERR("calloc() Fail(%d)", errno);
+ free(value);
+ return NULL;
+ }
+ memcpy(value->s, val, len);
+ value->len = len;
+
+ return (iotcon_value_h)value;
+}
+
+
iotcon_value_h icl_value_create_list(iotcon_list_h val)
{
icl_val_list_s *value;
}
+int icl_value_get_byte_str(iotcon_value_h value, unsigned char **val, int *len)
+{
+ icl_val_byte_str_s *real = (icl_val_byte_str_s*)value;
+
+ RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
+ RETVM_IF(IOTCON_TYPE_BYTE_STR != real->type, IOTCON_ERROR_INVALID_PARAMETER,
+ "Invalid Type(%d)", real->type);
+
+ *val = real->s;
+ *len = real->len;
+
+ return IOTCON_ERROR_NONE;
+}
+
+
int icl_value_get_list(iotcon_value_h value, iotcon_list_h *list)
{
icl_val_list_s *real = (icl_val_list_s*)value;
case IOTCON_TYPE_DOUBLE:
case IOTCON_TYPE_NULL:
break;
+ case IOTCON_TYPE_BYTE_STR:
+ free(((icl_val_byte_str_s*)value)->s);
+ break;
case IOTCON_TYPE_LIST:
- DBG("value is list");
ret = icl_value_get_list(value, &list);
if (IOTCON_ERROR_NONE != ret) {
ERR("icl_value_get_list() Fail(%d)", ret);
iotcon_list_destroy(list);
break;
case IOTCON_TYPE_STATE:
- DBG("value is Repr");
ret = icl_value_get_state(value, &state);
if (IOTCON_ERROR_NONE != ret) {
ERR("icl_value_get_state() Fail(%d)", ret);
dest = icl_value_create_double(real->val.d);
break;
case IOTCON_TYPE_STR:
- dest = icl_value_create_str(ic_utils_strdup(real->val.s));
+ dest = icl_value_create_str(real->val.s);
break;
case IOTCON_TYPE_NULL:
dest = icl_value_create_null();
break;
+ case IOTCON_TYPE_BYTE_STR:
+ dest = icl_value_create_byte_str(((icl_val_byte_str_s*)real)->s,
+ ((icl_val_byte_str_s*)real)->len);
+ break;
default:
ERR("Invalid type(%d)", src->type);
break;
} val;
} icl_basic_s;
+typedef struct {
+ int type;
+ unsigned char *s;
+ int len;
+} icl_val_byte_str_s;
+
typedef struct {
int type;
struct icl_list_s *list;
* #IOTCON_TYPE_DOUBLE\n
* #IOTCON_TYPE_STR\n
* #IOTCON_TYPE_NULL\n
+ * #IOTCON_TYPE_BYTE_STR\n
* #IOTCON_TYPE_LIST\n
* #IOTCON_TYPE_STATE
*
iotcon_value_h icl_value_create_bool(bool val);
iotcon_value_h icl_value_create_double(double val);
iotcon_value_h icl_value_create_str(const char *val);
+iotcon_value_h icl_value_create_byte_str(const unsigned char *val, int len);
iotcon_value_h icl_value_create_list(iotcon_list_h val);
iotcon_value_h icl_value_create_state(iotcon_state_h val);
int icl_value_get_bool(iotcon_value_h value, bool *val);
int icl_value_get_double(iotcon_value_h value, double *val);
int icl_value_get_str(iotcon_value_h value, char **val);
+int icl_value_get_byte_str(iotcon_value_h value, unsigned char **val, int *len);
int icl_value_get_list(iotcon_value_h value, iotcon_list_h *list);
int icl_value_get_state(iotcon_value_h value, iotcon_state_h *state);
IOTCON_TYPE_BOOL, /**< Indicates for representation that have bool type */
IOTCON_TYPE_DOUBLE, /**< Indicates for representation that have double type */
IOTCON_TYPE_STR, /**< Indicates for representation that have string type */
+ IOTCON_TYPE_BYTE_STR, /**< Indicates for representation that have byte string type */
IOTCON_TYPE_NULL, /**< Indicates for representation that have null type */
IOTCON_TYPE_LIST, /**< Indicates for representation that have list type */
IOTCON_TYPE_STATE, /**< Indicates for representation that have another representation type */
* \#include <iotcon.h>
*
* @section CAPI_IOT_CONNECTIVITY_COMMON_REPRESENTATION_STATE_LIST_MODULE_OVERVIEW Overview
- * The iotcon list API provides list of bool, integer, double, string, list and state handle.
+ * The iotcon list API provides list of bool, integer, double, string, byte string, list and state handle.
*
* Example :
* @code
*/
int iotcon_list_add_str(iotcon_list_h list, char *val, int pos);
+/**
+ * @brief Adds a new element byte string value into the list at the given position.
+ * @details If @a pos is negative, or is larger than the number of elements in the list,
+ * the new value is added on to the end of the list.
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] list The list handle
+ * @param[in] val The new byte string value
+ * @param[in] len The length of @a val
+ * @param[in] pos The position to insert value
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #IOTCON_ERROR_INVALID_TYPE Invalid type
+ */
+int iotcon_list_add_byte_str(iotcon_list_h list, unsigned char *val, int len, int pos);
+
/**
* @brief Adds a new element list into the list at the given position.
* @details If @a pos is negative, or is larger than the number of elements in the list,
*/
int iotcon_list_get_nth_str(iotcon_list_h list, int pos, char **val);
+/**
+ * @brief Gets the string value at the given position.
+ * @details Iterates over the list until it reaches the @a pos-1 position.
+ *
+ * @since_tizen 3.0
+ *
+ * @remarks @a val must not be released using free().
+ *
+ * @param[in] list The list handle
+ * @param[in] pos The position
+ * @param[out] val The byte string value to get
+ * @param[out] len The length of the @a val
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #IOTCON_ERROR_NO_DATA No data available
+ * @retval #IOTCON_ERROR_REPRESENTATION Representation errors
+ */
+int iotcon_list_get_nth_byte_str(iotcon_list_h list, int pos, unsigned char **val,
+ int *len);
+
/**
* @brief Gets the list value at the given position.
* @details Iterates over the list until it reaches the @a pos-1 position.
int iotcon_list_foreach_double(iotcon_list_h list, iotcon_list_double_cb cb,
void *user_data);
+/**
+ * @brief Specifies the type of function passed to iotcon_list_foreach_byte_str()
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] pos The number of the string value (0 being the first)
+ * @param[in] value The byte string value
+ * @param[in] len The length of @a value
+ * @param[in] user_data The user data to pass to the function
+ *
+ * @return true to continue with the next iteration of the loop,
+ * otherwise false to break out of the loop. #IOTCON_FUNC_CONTINUE and #IOTCON_FUNC_STOP
+ * are more friendly values for the return.
+ *
+ * @pre iotcon_list_foreach_byte_str() will invoke this callback function.
+ *
+ * @see iotcon_list_foreach_byte_str()
+ */
+typedef bool (*iotcon_list_byte_str_cb)(int pos, const unsigned char *value, int len,
+ void *user_data);
+
+/**
+ * @brief Gets all string values of the given list by invoking the callback function.
+ * @details iotcon_list_byte_str_cb() will be called for each child.
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] list The handle to the list
+ * @param[in] cb The callback function to get each string value
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @post iotcon_list_byte_str_cb() will be called for each item.
+ *
+ * @see iotcon_list_byte_str_cb()
+ */
+int iotcon_list_foreach_byte_str(iotcon_list_h list, iotcon_list_byte_str_cb cb,
+ void *user_data);
+
/**
* @brief Specifies the type of function passed to iotcon_list_foreach_str()
*
* The Iotcon Representation API provides data type of resp_repr handling.\n
* A resp_repr is a payload of a request or a response.\n
* It has uri_path, interface, list of resource types and its attributes.\n
- * Attributes have capabilties to store and retrieve integer, boolean, double, string, list, null,
- * resp_repr.\n
+ * Attributes have capabilties to store and retrieve integer, boolean, double, string,
+ * byte string, list, null, resp_repr.\n
* A list is a container that includes number of datas of same type.\n
- * It has capabilties to store and retrieve integer, boolean, double, string, list, null, resp_repr.
+ * It has capabilties to store and retrieve integer, boolean, double, string, byte string,
+ * list, null, resp_repr.
*
* Example :
*@code
int iotcon_state_clone(iotcon_state_h state, iotcon_state_h *state_clone);
/**
- * @brief Adds a new key and integer value into the representation.
+ * @brief Adds a new key and integer value into the state.
* @details If @a key is already exists, current value will be replaced with new @a val.
*
* @since_tizen 3.0
int iotcon_state_add_int(iotcon_state_h state, const char *key, int val);
/**
- * @brief Adds a new key and boolean value into the representation.
+ * @brief Adds a new key and boolean value into the state.
* @details If @a key is already exists, current value will be replaced with new @a val.
*
* @since_tizen 3.0
int iotcon_state_add_bool(iotcon_state_h state, const char *key, bool val);
/**
- * @brief Adds a new key and double value into the representation.
+ * @brief Adds a new key and double value into the state.
* @details If @a key is already exists, current value will be replaced with new @a val.
*
* @since_tizen 3.0
int iotcon_state_add_double(iotcon_state_h state, const char *key, double val);
/**
- * @brief Adds a new key and string value into the representation.
+ * @brief Adds a new key and string value into the state.
* @details If @a key is already exists, current value will be replaced with new @a val.
*
* @since_tizen 3.0
int iotcon_state_add_str(iotcon_state_h state, const char *key, char *val);
/**
- * @brief Adds a new key and list value into the representation.
+ * @brief Adds a new key and byte string value into the state.
+ * @details If @a key is already exists, current value will be replaced with new @a val.
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] state The state handle
+ * @param[in] key The key
+ * @param[in] val The value
+ * @param[in] len The length of @a val
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int iotcon_state_add_byte_str(iotcon_state_h state, const char *key, unsigned char *val,
+ int len);
+
+/**
+ * @brief Adds a new key and list value into the state.
* @details If @a key is already exists, current list will be replaced with new @a list.
*
* @since_tizen 3.0
int iotcon_state_add_list(iotcon_state_h state, const char *key, iotcon_list_h list);
/**
- * @brief Adds a new key and state value into the representation.
+ * @brief Adds a new key and state value into the state.
* @details If @a key is already exists, current state will be replaced with new @a src.
*
* @since_tizen 3.0
int iotcon_state_add_state(iotcon_state_h dest, const char *key, iotcon_state_h src);
/**
- * @brief Adds a new key with NULL value into the representation.
+ * @brief Adds a new key with NULL value into the state.
* @details If @a key is already exists, current value will be replaced with NULL
*
* @since_tizen 3.0
*/
int iotcon_state_get_str(iotcon_state_h state, const char *key, char **val);
+/**
+ * @brief Gets the byte string value from the given key.
+ *
+ * @since_tizen 3.0
+ *
+ * @remarks @a val must not be released using free().
+ *
+ * @param[in] state The state handle
+ * @param[in] key The key
+ * @param[out] val The byte string value
+ * @param[out] len The length of @a val
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #IOTCON_ERROR_NO_DATA No data available
+ * @retval #IOTCON_ERROR_INVALID_TYPE Invalid type
+ */
+int iotcon_state_get_byte_str(iotcon_state_h state, const char *key, unsigned char **val,
+ int *len);
+
/**
* @brief Gets the list value from the given key.
*