return IOTCON_ERROR_NONE;
}
+API int iotcon_set_device_name(const char *device_name)
+{
+ int ret;
+
+ RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+ RETV_IF(NULL == device_name || '\0' == *device_name, IOTCON_ERROR_INVALID_PARAMETER);
+
+ ret = icl_ioty_set_device_info(device_name);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("icl_ioty_set_device_info() Fail(%d)", ret);
+ return ret;
+ }
+
+ return IOTCON_ERROR_NONE;
+}
+
API int iotcon_platform_info_get_property(iotcon_platform_info_h platform_info,
iotcon_platform_info_e property, char **value)
{
iotcon_resource_interfaces_h ifaces;
iotcon_resource_types_h types;
char host_addr[PATH_MAX] = {0};
+ char *device_name;
OCStringLL *node;
/* uri path */
_icl_ioty_free_resource_list(res_list, res_count);
return IOTCON_ERROR_OUT_OF_MEMORY;
}
+
+ if (payload->name)
+ device_name = strdup(payload->name);
+ else
+ device_name = strdup("");
+ if (NULL == device_name) {
+ ERR("strdup(device_name) Fail(%d)", errno);
+ _icl_ioty_free_resource_list(res_list, res_count);
+ return IOTCON_ERROR_OUT_OF_MEMORY;
+ }
+
+ res_list[i]->device_name = device_name;
+
iotcon_resource_interfaces_destroy(ifaces);
iotcon_resource_types_destroy(types);
}
return IOTCON_ERROR_OUT_OF_MEMORY;
}
- info->device_name = ic_utils_strdup(payload->deviceName);
+ if (payload->deviceName)
+ info->device_name = strdup(payload->deviceName);
+ else
+ info->device_name = strdup("");
+ if (NULL == info->device_name)
+ ERR("strdup(device_name) Fail(%d)", errno);
+
info->spec_ver = ic_utils_strdup(payload->specVersion);
info->data_model_ver = ic_utils_strdup(payload->dataModelVersion);
info->device_id = ic_utils_strdup(payload->sid);
#include "icl-ioty.h"
-/* The length of uri_path should be less than or equal to 36. */
+/* The length of uri_path should be less than 64. */
API int iotcon_lite_resource_create(const char *uri_path,
iotcon_resource_types_h res_types,
uint8_t policies,
free(resource->uri_path);
free(resource->host_address);
free(resource->device_id);
+ free(resource->device_name);
iotcon_resource_interfaces_destroy(resource->ifaces);
iotcon_resource_types_destroy(resource->types);
resource->host_address = ic_utils_strdup(src->host_address);
resource->connectivity_type = src->connectivity_type;
resource->device_id = ic_utils_strdup(src->device_id);
+ resource->device_name = ic_utils_strdup(src->device_name);
resource->policies = src->policies;
resource->ref_count = 1;
return IOTCON_ERROR_NONE;
}
+
+/* The content of the resource should not be freed by user. */
+API int iotcon_remote_resource_get_device_name(iotcon_remote_resource_h resource,
+ char **device_name)
+{
+ RETV_IF(false == ic_utils_check_oic_feature(), IOTCON_ERROR_NOT_SUPPORTED);
+ RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == device_name, IOTCON_ERROR_INVALID_PARAMETER);
+ RETVM_IF(NULL == resource->device_name, IOTCON_ERROR_NO_DATA,
+ "If you want to get device name, you should call iotcon_find_resource().");
+
+ *device_name = resource->device_name;
+
+ return IOTCON_ERROR_NONE;
+}
+
+
/* The content of the resource should not be freed by user. */
API int iotcon_remote_resource_get_types(iotcon_remote_resource_h resource,
iotcon_resource_types_h *types)
char *uri_path;
char *host_address;
char *device_id;
+ char *device_name;
uint8_t policies;
iotcon_options_h header_options;
iotcon_resource_types_h types;
}
-/* The length of uri_path should be less than or equal to 36. */
+/* The length of uri_path should be less than 64. */
API int iotcon_resource_create(const char *uri_path,
iotcon_resource_types_h res_types,
iotcon_resource_interfaces_h ifaces,
*
* @since_tizen 3.0
*/
-#define ICL_URI_PATH_LENGTH_MAX 36
+#define ICL_URI_PATH_LENGTH_MAX 64
struct icl_notify_msg {
char *iface;
* @pre iotcon_initialize() should be called to initialize.
* @post iotcon_device_info_cb() will be invoked.
*
+ * @see iotcon_set_device_name()
* @see iotcon_device_info_cb()
* @see iotcon_device_info_get_property()
* @see iotcon_set_timeout()
* @retval #IOTCON_ERROR_NOT_SUPPORTED Not supported
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
+ * @see iotcon_set_device_name()
* @see iotcon_device_info_cb()
* @see iotcon_find_device_info()
*/
* @privlevel public
* @privilege %http://tizen.org/privilege/internet
*
- * @remarks @a uri_path length must be less than or equal 36.\n
+ * @remarks @a uri_path length must be less than 64.\n
* You must destroy @a resource_handle by calling iotcon_lite_resource_destroy()
* if @a remote_handle is no longer needed.
*
* @see iotcon_remote_resource_get_host_address()
* @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_device_id()
+ * @see iotcon_remote_resource_get_device_name()
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_interfaces()
* @see iotcon_remote_resource_get_policies()
* @see iotcon_remote_resource_get_host_address()
* @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_device_id()
+ * @see iotcon_remote_resource_get_device_name()
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_interfaces()
* @see iotcon_remote_resource_get_policies()
* @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_uri_path()
* @see iotcon_remote_resource_get_device_id()
+ * @see iotcon_remote_resource_get_device_name()
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_interfaces()
* @see iotcon_remote_resource_get_policies()
* @retval #IOTCON_ERROR_NO_DATA No data available
*
* @see iotcon_remote_resource_get_uri_path()
+ * @see iotcon_remote_resource_get_device_name()
* @see iotcon_remote_resource_get_host_address()
* @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_types()
int iotcon_remote_resource_get_device_id(iotcon_remote_resource_h resource,
char **device_id);
+/**
+ * @brief Gets the device name of the remote resource.
+ *
+ * @since_tizen 3.0
+ *
+ * @remarks @a device_name must not be released using free().\n
+ * If @a resource is created by calling iotcon_remote_resource_create(), you cannot get
+ * @a device_name. In this case, the return value of this function is #IOTCON_ERROR_NO_DATA.
+ *
+ * @param[in] resource The handle of the remote resource
+ * @param[out] device_name The device name of the remote resource
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_NOT_SUPPORTED Not supported
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #IOTCON_ERROR_NO_DATA No data available
+ *
+ * @see iotcon_set_device_name()
+ * @see iotcon_remote_resource_get_uri_path()
+ * @see iotcon_remote_resource_get_device_id()
+ * @see iotcon_remote_resource_get_device_name()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_connectivity_type()
+ * @see iotcon_remote_resource_get_types()
+ * @see iotcon_remote_resource_get_interfaces()
+ * @see iotcon_remote_resource_get_properties()
+ * @see iotcon_remote_resource_set_options()
+ */
+int iotcon_remote_resource_get_device_name(iotcon_remote_resource_h resource,
+ char **device_name);
+
/**
* @brief Gets resource types of the remote resource.
*
* @see iotcon_remote_resource_get_host_address()
* @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_device_id()
+ * @see iotcon_remote_resource_get_device_name()
* @see iotcon_remote_resource_get_interfaces()
* @see iotcon_remote_resource_get_policies()
* @see iotcon_remote_resource_set_options()
* @see iotcon_remote_resource_get_host_address()
* @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_device_id()
+ * @see iotcon_remote_resource_get_device_name()
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_policies()
* @see iotcon_remote_resource_set_options()
* @see iotcon_remote_resource_get_host_address()
* @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_device_id()
+ * @see iotcon_remote_resource_get_device_name()
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_interfaces()
* @see iotcon_remote_resource_set_options()
* @see iotcon_remote_resource_get_host_address()
* @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_device_id()
+ * @see iotcon_remote_resource_get_device_name()
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_interfaces()
* @see iotcon_remote_resource_set_options()
* @see iotcon_remote_resource_get_host_address()
* @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_device_id()
+ * @see iotcon_remote_resource_get_device_name()
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_interfaces()
* @see iotcon_remote_resource_get_options()
* @privlevel public
* @privilege %http://tizen.org/privilege/internet
*
- * @remarks @a uri_path length must be less than or equal 36.\n
+ * @remarks @a uri_path length must be less than 64.\n
* You must destroy @a resource by calling iotcon_resource_destroy()
* if @a resource is no longer needed.
*
*/
int iotcon_stop_presence(void);
+/**
+ * @brief Sets the device name.
+ * @details The function sets the name of the local device (the device calling the function).
+ * If the device name is set, clients can get the name using iotcon_device_info_get_property()
+ * or iotcon_remote_resource_get_device_name().
+ *
+ * @since_tizen 3.0
+ *
+ * @remarks @a device_name may not be an empty string.
+ *
+ * @param[in] device_name The device name
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_NOT_SUPPORTED Not supported
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #IOTCON_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #IOTCON_ERROR_IOTIVITY Iotivity errors
+ *
+ * @see iotcon_get_device_info()
+ * @see iotcon_device_info_get_property()
+ * @see iotcon_remote_resource_get_device_name()
+ */
+int iotcon_set_device_name(const char *device_name);
/**
* @}
char *resource_host;
char *resource_uri_path;
char *resource_device_id;
+ char *resource_device_name;
iotcon_presence_h presence_handle;
iotcon_resource_types_h resource_types;
iotcon_resource_interfaces_h resource_interfaces;
}
DBG("[%s] resource device id : %s", resource_uri_path, resource_device_id);
+ ret = iotcon_remote_resource_get_device_name(resource, &resource_device_name);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_remote_resource_get_device_name() Fail(%d)", ret);
+ return;
+ }
+ DBG("[%s] resource device name : %s", resource_uri_path, resource_device_name);
+
node = g_list_find_custom(device_id_list, resource_device_id, _device_id_compare);
if (node && TEST_STR_EQUAL == strncmp(DOOR_RESOURCE_URI_PREFIX, resource_uri_path,
return -1;
}
+ /* set device name */
+ ret = iotcon_set_device_name("iotcon-test-basic-server");
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_set_device_name() Fail(%d)", ret);
+ iotcon_deinitialize();
+ return -1;
+ }
+
/* set local door resource */
ret = _set_door_resource(&my_door);
if (0 != ret) {
char *resource_host;
char *resource_uri_path;
char *resource_device_id;
+ char *resource_device_name;
iotcon_resource_interfaces_h resource_interfaces;
iotcon_resource_types_h resource_types;
iotcon_remote_resource_h cloned_resource;
}
DBG("[%s] resource device id : %s", resource_uri_path, resource_device_id);
+ ret = iotcon_remote_resource_get_device_name(resource, &resource_device_name);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_remote_resource_get_device_name() Fail(%d)", ret);
+ return;
+ }
+ DBG("[%s] resource device name : %s", resource_uri_path, resource_device_name);
+
node = g_list_find_custom(device_id_list, resource_device_id, _device_id_compare);
if (node && TEST_STR_EQUAL == strncmp(ROOM_RESOURCE_URI_PREFIX, resource_uri_path,
return -1;
}
+ /* set device name */
+ ret = iotcon_set_device_name("iotcon-test-iface-server");
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_set_device_name() Fail(%d)", ret);
+ iotcon_deinitialize();
+ return -1;
+ }
+
/* set resource */
ret = _set_room_resource(&room);
if (0 != ret) {