Modify terms related to signal
[platform/core/iot/iotcon.git] / daemon / icd-ioty.c
index 2111f9c..1627704 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h> /* for uint8_t etc */
-#include <stdbool.h>
 #include <errno.h>
 #include <glib.h>
+#include <tizen_type.h>
+#include <system_info.h>
+#include <system_settings.h>
 
 #include <octypes.h>
 #include <ocstack.h>
 #include "icd-ioty-type.h"
 #include "icd-ioty-ocprocess.h"
 
+#define ICD_UUID_LENGTH 37
+
+static const char *ICD_SYSTEM_INFO_TIZEN_ID = "http://tizen.org/system/tizenid";
+static const char *ICD_SYSTEM_INFO_PLATFORM_NAME = "http://tizen.org/system/platform.name";
+static const char *ICD_SYSTEM_INFO_PLATFORM_VERSION = "http://tizen.org/feature/platform.version";
+static const char *ICD_SYSTEM_INFO_MANUF_NAME = "http://tizen.org/system/manufacturer";
+static const char *ICD_SYSTEM_INFO_MODEL_NAME = "http://tizen.org/system/model_name";
+static const char *ICD_SYSTEM_INFO_BUILD_STRING = "http://tizen.org/system/build.string";
+
+typedef struct {
+       char *device_name;
+       char *tizen_device_id;
+} icd_tizen_info_s;
+
+static icd_tizen_info_s icd_tizen_info = {0};
+
 static GMutex icd_csdk_mutex;
 
 void icd_ioty_csdk_lock()
@@ -86,9 +104,36 @@ void icd_ioty_deinit(GThread *thread)
                ERR("OCStop() Fail(%d)", result);
 }
 
+static int _ioty_properties_to_oic_properties(int properties)
+{
+       int prop = OC_RES_PROP_NONE;
+
+       if (IOTCON_DISCOVERABLE & properties)
+               prop |= OC_DISCOVERABLE;
+
+       if (IOTCON_OBSERVABLE & properties)
+               prop |= OC_OBSERVABLE;
+
+       if (IOTCON_ACTIVE & properties)
+               prop |= OC_ACTIVE;
+
+       if (IOTCON_SLOW & properties)
+               prop |= OC_SLOW;
+
+       if (IOTCON_SECURE & properties)
+               prop |= OC_SECURE;
+
+       if (IOTCON_EXPLICIT_DISCOVERABLE & properties)
+               prop |= OC_EXPLICIT_DISCOVERABLE;
+
+       /* TODO: Secure option is not supported yet. */
+       properties = (properties & OC_SECURE)? (properties ^ OC_SECURE):properties;
+
+       return prop;
+}
 
 OCResourceHandle icd_ioty_register_resource(const char *uri_path,
-               const char* const* res_types, int ifaces, uint8_t properties)
+               const char* const* res_types, int ifaces, int properties)
 {
        FN_CALL;
        int i;
@@ -113,8 +158,7 @@ OCResourceHandle icd_ioty_register_resource(const char *uri_path,
                return NULL;
        }
 
-       /* Secure option is not supported yet. */
-       properties = (properties & OC_SECURE)? (properties ^ OC_SECURE):properties;
+       properties = _ioty_properties_to_oic_properties(properties);
 
        icd_ioty_csdk_lock();
        ret = OCCreateResource(&handle, res_types[0], res_iface, uri_path,
@@ -148,9 +192,10 @@ int icd_ioty_unregister_resource(OCResourceHandle handle)
        icd_ioty_csdk_lock();
        ret = OCDeleteResource(handle);
        icd_ioty_csdk_unlock();
+
        if (OC_STACK_OK != ret) {
                ERR("OCDeleteResource() Fail(%d)", ret);
-               return IOTCON_ERROR_IOTIVITY;
+               return icd_ioty_convert_error(ret);
        }
 
        return IOTCON_ERROR_NONE;
@@ -172,9 +217,10 @@ int icd_ioty_bind_interface(OCResourceHandle handle, iotcon_interface_e iface)
        icd_ioty_csdk_lock();
        result = OCBindResourceInterfaceToResource(handle, resource_interface);
        icd_ioty_csdk_unlock();
+
        if (OC_STACK_OK != result) {
                ERR("OCBindResourceInterfaceToResource() Fail(%d)", result);
-               return IOTCON_ERROR_IOTIVITY;
+               return icd_ioty_convert_error(result);
        }
 
        return IOTCON_ERROR_NONE;
@@ -188,9 +234,10 @@ int icd_ioty_bind_type(OCResourceHandle handle, const char *resource_type)
        icd_ioty_csdk_lock();
        ret = OCBindResourceTypeToResource(handle, resource_type);
        icd_ioty_csdk_unlock();
+
        if (OC_STACK_OK != ret) {
                ERR("OCBindResourceTypeToResource() Fail(%d)", ret);
-               return IOTCON_ERROR_IOTIVITY;
+               return icd_ioty_convert_error(ret);
        }
 
        return IOTCON_ERROR_NONE;
@@ -204,9 +251,10 @@ int icd_ioty_bind_resource(OCResourceHandle parent, OCResourceHandle child)
        icd_ioty_csdk_lock();
        ret = OCBindResource(parent, child);
        icd_ioty_csdk_unlock();
+
        if (OC_STACK_OK != ret) {
                ERR("OCBindResource() Fail(%d)", ret);
-               return IOTCON_ERROR_IOTIVITY;
+               return icd_ioty_convert_error(ret);
        }
 
        return IOTCON_ERROR_NONE;
@@ -220,19 +268,18 @@ int icd_ioty_unbind_resource(OCResourceHandle parent, OCResourceHandle child)
        icd_ioty_csdk_lock();
        ret = OCUnBindResource(parent, child);
        icd_ioty_csdk_unlock();
+
        if (OC_STACK_OK != ret) {
                ERR("OCUnBindResource() Fail(%d)", ret);
-               return IOTCON_ERROR_IOTIVITY;
+               return icd_ioty_convert_error(ret);
        }
 
        return IOTCON_ERROR_NONE;
 }
 
-
-int icd_ioty_notify_list_of_observers(OCResourceHandle handle, GVariant *msg,
-               GVariant *observers)
+int icd_ioty_notify(OCResourceHandle handle, GVariant *msg, GVariant *observers)
 {
-       int i, error_code, obs_length;
+       int i, obs_length, msg_length;
        GVariant *repr_gvar;
        GVariantIter obs_iter, msg_iter;
        OCStackResult ret;
@@ -248,43 +295,28 @@ int icd_ioty_notify_list_of_observers(OCResourceHandle handle, GVariant *msg,
                g_variant_iter_loop(&obs_iter, "i", &obs_ids[i]);
 
        g_variant_iter_init(&msg_iter, msg);
-       g_variant_iter_loop(&msg_iter, "(iv)", &error_code, &repr_gvar);
-       /* TODO : How to use error_code. */
-
-       payload = icd_payload_representation_from_gvariant(repr_gvar);
-
-       icd_ioty_csdk_lock();
-       /* TODO : QoS is come from lib. */
-       ret = OCNotifyListOfObservers(handle, obs_ids, obs_length, payload, OC_LOW_QOS);
-       icd_ioty_csdk_unlock();
-
-       if (OC_STACK_NO_OBSERVERS == ret) {
-               WARN("No Observers. Stop Notifying");
-               return IOTCON_ERROR_NONE;
-       } else if (OC_STACK_OK != ret) {
-               ERR("OCNotifyListOfObservers() Fail(%d)", ret);
-               return IOTCON_ERROR_IOTIVITY;
+       msg_length = g_variant_iter_n_children(&msg_iter);
+       if (msg_length) {
+               g_variant_iter_loop(&msg_iter, "v", &repr_gvar);
+               /* TODO : How to use error_code. */
+               payload = icd_payload_representation_from_gvariant(repr_gvar);
        }
 
-       return IOTCON_ERROR_NONE;
-}
-
-
-int icd_ioty_notify_all(OCResourceHandle handle)
-{
-       OCStackResult ret;
-
        icd_ioty_csdk_lock();
        /* TODO : QoS is come from lib. */
-       ret = OCNotifyAllObservers(handle, OC_LOW_QOS);
+       if (msg_length) {
+               ret = OCNotifyListOfObservers(handle, obs_ids, obs_length, payload, OC_LOW_QOS);
+       } else {
+               ret = OCNotifyAllObservers(handle, OC_LOW_QOS);
+       }
        icd_ioty_csdk_unlock();
 
        if (OC_STACK_NO_OBSERVERS == ret) {
                WARN("No Observers. Stop Notifying");
                return IOTCON_ERROR_NONE;
        } else if (OC_STACK_OK != ret) {
-               ERR("OCNotifyAllObservers() Fail(%d)", ret);
-               return IOTCON_ERROR_IOTIVITY;
+               ERR("OCNotifyListOfObservers() Fail(%d)", ret);
+               return icd_ioty_convert_error(ret);
        }
 
        return IOTCON_ERROR_NONE;
@@ -319,17 +351,14 @@ static int _ioty_get_header_options(GVariantIter *src, int src_size,
 
 int icd_ioty_send_response(GVariant *resp)
 {
-       char *new_uri_path;
        GVariant *repr_gvar;
        GVariantIter *options;
        OCStackResult ret;
        OCEntityHandlerResponse response = {0};
-       int result, error_code, options_size;
+       int result, options_size;
        int64_t request_handle, resource_handle;
 
-       g_variant_get(resp, "(&sia(qs)ivxx)",
-                       &new_uri_path,
-                       &error_code,
+       g_variant_get(resp, "(a(qs)ivxx)",
                        &options,
                        &result,
                        &repr_gvar,
@@ -340,9 +369,6 @@ int icd_ioty_send_response(GVariant *resp)
        response.resourceHandle = ICD_INT64_TO_POINTER(resource_handle);
        response.ehResult = (OCEntityHandlerResult)result;
 
-       if (OC_EH_RESOURCE_CREATED == response.ehResult)
-               snprintf(response.resourceUri, sizeof(response.resourceUri), "%s", new_uri_path);
-
        options_size = g_variant_iter_n_children(options);
        response.numSendVendorSpecificHeaderOptions = options_size;
 
@@ -369,7 +395,7 @@ int icd_ioty_send_response(GVariant *resp)
 
        if (OC_STACK_OK != ret) {
                ERR("OCDoResponse() Fail(%d)", ret);
-               return IOTCON_ERROR_IOTIVITY;
+               return icd_ioty_convert_error(ret);
        }
 
        return IOTCON_ERROR_NONE;
@@ -384,8 +410,8 @@ static void _ioty_free_signal_context(void *data)
 }
 
 
-int icd_ioty_find_resource(const char *host_address, const char *resource_type,
-               unsigned int signum, const char *bus_name)
+int icd_ioty_find_resource(const char *host_address, int conn_type,
+               const char *resource_type, unsigned int signal_number, const char *bus_name)
 {
        int len;
        OCStackResult result;
@@ -393,7 +419,6 @@ int icd_ioty_find_resource(const char *host_address, const char *resource_type,
        char uri[PATH_MAX] = {0};
        OCCallbackData cbdata = {0};
        OCConnectivityType oic_conn_type;
-       iotcon_connectivity_type_e conn_type = IOTCON_CONNECTIVITY_IPV4;
 
        if (IC_STR_EQUAL == strcmp(IOTCON_MULTICAST_ADDRESS, host_address)) {
                len = snprintf(uri, sizeof(uri), "%s", OC_RSRVD_WELL_KNOWN_URI);
@@ -416,7 +441,7 @@ int icd_ioty_find_resource(const char *host_address, const char *resource_type,
        }
 
        context->bus_name = ic_utils_strdup(bus_name);
-       context->signum = signum;
+       context->signal_number = signal_number;
 
        cbdata.context = context;
        cbdata.cb = icd_ioty_ocprocess_find_cb;
@@ -434,7 +459,7 @@ int icd_ioty_find_resource(const char *host_address, const char *resource_type,
                ERR("OCDoResource() Fail(%d)", result);
                free(context->bus_name);
                free(context);
-               return IOTCON_ERROR_IOTIVITY;
+               return icd_ioty_convert_error(result);
        }
 
        return IOTCON_ERROR_NONE;
@@ -496,6 +521,11 @@ void icd_ioty_complete(int type, GDBusMethodInvocation *invocation, GVariant *va
        case ICD_CRUD_DELETE:
                ic_dbus_complete_delete(icd_dbus_get_object(), invocation, value);
                break;
+       case ICD_TIZEN_INFO:
+               ic_dbus_complete_get_tizen_info(icd_dbus_get_object(), invocation, value);
+               break;
+       default:
+               INFO("Invalid type(%d)", type);
        }
 }
 
@@ -503,30 +533,48 @@ void icd_ioty_complete(int type, GDBusMethodInvocation *invocation, GVariant *va
 void icd_ioty_complete_error(int type, GDBusMethodInvocation *invocation, int ret_val)
 {
        GVariant *value;
+       GVariant *payload;
+       GVariantBuilder options;
 
        switch (type) {
        case ICD_CRUD_GET:
-               value = g_variant_new("(a(qs)vi)", NULL, NULL, ret_val);
+               g_variant_builder_init(&options, G_VARIANT_TYPE("a(qs)"));
+               payload = icd_payload_representation_empty_gvariant();
+               value = g_variant_new("(a(qs)vi)", &options, payload, ret_val);
                ic_dbus_complete_get(icd_dbus_get_object(), invocation, value);
                break;
        case ICD_CRUD_PUT:
-               value = g_variant_new("(a(qs)vi)", NULL, NULL, ret_val);
+               g_variant_builder_init(&options, G_VARIANT_TYPE("a(qs)"));
+               payload = icd_payload_representation_empty_gvariant();
+               value = g_variant_new("(a(qs)vi)", &options, payload, ret_val);
                ic_dbus_complete_put(icd_dbus_get_object(), invocation, value);
                break;
        case ICD_CRUD_POST:
-               value = g_variant_new("(a(qs)vi)", NULL, NULL, ret_val);
+               g_variant_builder_init(&options, G_VARIANT_TYPE("a(qs)"));
+               payload = icd_payload_representation_empty_gvariant();
+               value = g_variant_new("(a(qs)vi)", &options, payload, ret_val);
                ic_dbus_complete_post(icd_dbus_get_object(), invocation, value);
                break;
        case ICD_CRUD_DELETE:
-               value = g_variant_new("(a(qs)i)", NULL, ret_val);
+               g_variant_builder_init(&options, G_VARIANT_TYPE("a(qs)"));
+               value = g_variant_new("(a(qs)i)", &options, ret_val);
                ic_dbus_complete_delete(icd_dbus_get_object(), invocation, value);
                break;
+       case ICD_TIZEN_INFO:
+               value = g_variant_new("(ssi)", IC_STR_NULL, IC_STR_NULL, ret_val);
+               ic_dbus_complete_get_tizen_info(icd_dbus_get_object(), invocation, value);
+               break;
        }
+
 }
 
 
-static gboolean _icd_ioty_crud(int type, icDbus *object, GDBusMethodInvocation *invocation,
-               GVariant *resource, GVariant *query, GVariant *repr)
+static gboolean _icd_ioty_crud(int type,
+               icDbus *object,
+               GDBusMethodInvocation *invocation,
+               GVariant *resource,
+               GVariant *query,
+               GVariant *repr)
 {
        bool is_secure;
        OCMethod rest_type;
@@ -636,7 +684,7 @@ static gboolean _icd_ioty_crud(int type, icDbus *object, GDBusMethodInvocation *
 
        if (OC_STACK_OK != result) {
                ERR("OCDoResource() Fail(%d)", result);
-               icd_ioty_complete_error(type, invocation, IOTCON_ERROR_IOTIVITY);
+               icd_ioty_complete_error(type, invocation, icd_ioty_convert_error(result));
                return TRUE;
        }
 
@@ -671,8 +719,8 @@ gboolean icd_ioty_delete(icDbus *object, GDBusMethodInvocation *invocation,
 }
 
 
-OCDoHandle icd_ioty_observer_start(GVariant *resource, int observe_type, GVariant *query,
-               unsigned int signal_number, const char *bus_name)
+OCDoHandle icd_ioty_observer_start(GVariant *resource, int observe_type,
+               GVariant *query, unsigned int signal_number, const char *bus_name)
 {
        bool is_secure;
        OCMethod method;
@@ -711,7 +759,7 @@ OCDoHandle icd_ioty_observer_start(GVariant *resource, int observe_type, GVarian
                return NULL;
        }
        context->bus_name = ic_utils_strdup(bus_name);
-       context->signum = signal_number;
+       context->signal_number = signal_number;
 
        cbdata.context = context;
        cbdata.cb = icd_ioty_ocprocess_observe_cb;
@@ -800,73 +848,20 @@ int icd_ioty_observer_stop(OCDoHandle handle, GVariant *options)
        icd_ioty_csdk_unlock();
        if (OC_STACK_OK != ret) {
                ERR("OCCancel() Fail(%d)", ret);
-               return IOTCON_ERROR_IOTIVITY;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-int icd_ioty_register_device_info(GVariant *value)
-{
-       OCStackResult result;
-       OCDeviceInfo device_info = {0};
-
-       g_variant_get(value, "(&s)", &device_info.deviceName);
-
-       icd_ioty_csdk_lock();
-       result = OCSetDeviceInfo(device_info);
-       icd_ioty_csdk_unlock();
-
-       if (OC_STACK_OK != result) {
-               ERR("OCSetDeviceInfo() Fail(%d)", result);
-               return IOTCON_ERROR_IOTIVITY;
-       }
-
-       return IOTCON_ERROR_NONE;
-}
-
-
-int icd_ioty_register_platform_info(GVariant *value)
-{
-       OCStackResult result;
-       OCPlatformInfo platform_info = {0};
-
-       g_variant_get(value, "(&s&s&s&s&s&s&s&s&s&s&s)",
-                       &platform_info.platformID,
-                       &platform_info.manufacturerName,
-                       &platform_info.manufacturerUrl,
-                       &platform_info.modelNumber,
-                       &platform_info.dateOfManufacture,
-                       &platform_info.platformVersion,
-                       &platform_info.operatingSystemVersion,
-                       &platform_info.hardwareVersion,
-                       &platform_info.firmwareVersion,
-                       &platform_info.supportUrl,
-                       &platform_info.systemTime);
-
-       icd_ioty_csdk_lock();
-       result = OCSetPlatformInfo(platform_info);
-       icd_ioty_csdk_unlock();
-
-       if (OC_STACK_OK != result) {
-               ERR("OCSetPlatformInfo() Fail(%d)", result);
-               return IOTCON_ERROR_IOTIVITY;
+               return icd_ioty_convert_error(ret);
        }
 
        return IOTCON_ERROR_NONE;
 }
 
-
-int icd_ioty_get_info(int type, const char *host_address, unsigned int signal_number,
-               const char *bus_name)
+int icd_ioty_get_info(int type, const char *host_address, int conn_type,
+               unsigned int signal_number, const char *bus_name)
 {
        OCStackResult result;
        icd_sig_ctx_s *context;
        OCCallbackData cbdata = {0};
        char uri[PATH_MAX] = {0};
        char *uri_path = NULL;
-       iotcon_connectivity_type_e conn_type = IOTCON_CONNECTIVITY_IPV4;
        OCConnectivityType oic_conn_type;
 
        if (ICD_DEVICE_INFO == type)
@@ -887,7 +882,7 @@ int icd_ioty_get_info(int type, const char *host_address, unsigned int signal_nu
                return IOTCON_ERROR_OUT_OF_MEMORY;
        }
        context->bus_name = ic_utils_strdup(bus_name);
-       context->signum = signal_number;
+       context->signal_number = signal_number;
 
        cbdata.context = context;
        cbdata.cb = icd_ioty_ocprocess_info_cb;
@@ -905,22 +900,277 @@ int icd_ioty_get_info(int type, const char *host_address, unsigned int signal_nu
                ERR("OCDoResource() Fail(%d)", result);
                free(context->bus_name);
                free(context);
-               return IOTCON_ERROR_IOTIVITY;
+               return icd_ioty_convert_error(result);
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+static int _icd_ioty_get_tizen_id(char **tizen_device_id)
+{
+       int ret;
+       char *tizen_id = NULL;
+
+       ret = system_info_get_platform_string(ICD_SYSTEM_INFO_TIZEN_ID, &tizen_id);
+       if (SYSTEM_INFO_ERROR_NONE != ret) {
+               ERR("system_info_get_platform_string() Fail(%d)", ret);
+               return IOTCON_ERROR_SYSTEM;
+       }
+       *tizen_device_id = tizen_id;
+
+       return IOTCON_ERROR_NONE;
+}
+
+static int _ioty_set_device_info()
+{
+       int ret;
+       char *device_name = NULL;
+       OCDeviceInfo device_info = {0};
+
+       ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_DEVICE_NAME, &device_name);
+       if (SYSTEM_SETTINGS_ERROR_NONE != ret) {
+               ERR("system_settings_get_value_string() Fail(%d)", ret);
+               return IOTCON_ERROR_SYSTEM;
+       }
+
+       device_info.deviceName = device_name;
+
+       icd_ioty_csdk_lock();
+       ret = OCSetDeviceInfo(device_info);
+       icd_ioty_csdk_unlock();
+
+       if (OC_STACK_OK != ret) {
+               ERR("OCSetDeviceInfo() Fail(%d)", ret);
+               free(device_name);
+               return icd_ioty_convert_error(ret);
+       }
+
+       free(icd_tizen_info.device_name);
+       icd_tizen_info.device_name = device_name;
+
+       return IOTCON_ERROR_NONE;
+}
+
+static void _icd_ioty_on_device_name_changed_cb(system_settings_key_e key,
+               void *user_data)
+{
+       FN_CALL;
+       int ret;
+
+       ret = _ioty_set_device_info();
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("_ioty_set_device_info() Fail(%d)", ret);
+               return;
+       }
+}
+
+int icd_ioty_set_device_info()
+{
+       int ret;
+
+       ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_DEVICE_NAME,
+                       _icd_ioty_on_device_name_changed_cb, NULL);
+       if (SYSTEM_SETTINGS_ERROR_NONE != ret) {
+               ERR("system_settings_set_changed_cb() Fail(%d)", ret);
+               return IOTCON_ERROR_SYSTEM;
+       }
+
+       ret = _ioty_set_device_info();
+       if (IOTCON_ERROR_NONE != ret) {
+               ERR("_ioty_set_device_info() Fail(%d)", ret);
+               return ret;
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+static void _ioty_free_platform_info(OCPlatformInfo platform_info)
+{
+       free(platform_info.manufacturerName);
+       free(platform_info.manufacturerUrl);
+       free(platform_info.modelNumber);
+       free(platform_info.dateOfManufacture);
+       free(platform_info.platformVersion);
+       free(platform_info.operatingSystemVersion);
+       free(platform_info.hardwareVersion);
+       free(platform_info.firmwareVersion);
+       free(platform_info.supportUrl);
+       free(platform_info.systemTime);
+}
+
+int icd_ioty_set_platform_info()
+{
+       int ret;
+       OCPlatformInfo platform_info = {0};
+
+       ret = system_info_get_platform_string(ICD_SYSTEM_INFO_PLATFORM_NAME,
+                       &platform_info.platformID);
+       if (SYSTEM_INFO_ERROR_NONE != ret) {
+               ERR("system_info_get_platform_string() Fail(%d)", ret);
+               _ioty_free_platform_info(platform_info);
+               return IOTCON_ERROR_SYSTEM;
+       }
+
+       ret = system_info_get_platform_string(ICD_SYSTEM_INFO_MANUF_NAME,
+                       &platform_info.manufacturerName);
+       if (SYSTEM_INFO_ERROR_NONE != ret) {
+               ERR("system_info_get_platform_string() Fail(%d)", ret);
+               _ioty_free_platform_info(platform_info);
+               return IOTCON_ERROR_SYSTEM;
+       }
+
+       ret = system_info_get_platform_string(ICD_SYSTEM_INFO_MODEL_NAME,
+                       &platform_info.modelNumber);
+       if (SYSTEM_INFO_ERROR_NONE != ret) {
+               ERR("system_info_get_platform_string() Fail(%d)", ret);
+               _ioty_free_platform_info(platform_info);
+               return IOTCON_ERROR_SYSTEM;
+       }
+
+       ret = system_info_get_platform_string(ICD_SYSTEM_INFO_PLATFORM_VERSION,
+                       &platform_info.platformVersion);
+       if (SYSTEM_INFO_ERROR_NONE != ret) {
+               ERR("system_info_get_platform_string() Fail(%d)", ret);
+               _ioty_free_platform_info(platform_info);
+               return IOTCON_ERROR_SYSTEM;
+       }
+
+       ret = system_info_get_platform_string(ICD_SYSTEM_INFO_BUILD_STRING,
+                       &platform_info.firmwareVersion);
+       if (SYSTEM_INFO_ERROR_NONE != ret) {
+               ERR("system_info_get_platform_string() Fail(%d)", ret);
+               _ioty_free_platform_info(platform_info);
+               return IOTCON_ERROR_SYSTEM;
+       }
+
+       /* platform_info.manufacturerUrl */
+       /* platform_info.dateOfManufacture */
+       /* platform_info.operatingSystemVersion */
+       /* platform_info.hardwareVersion */
+       /* platform_info.supportUrl */
+       /* platform_info.systemTime */
+
+       icd_ioty_csdk_lock();
+       ret = OCSetPlatformInfo(platform_info);
+       icd_ioty_csdk_unlock();
+
+       if (OC_STACK_OK != ret) {
+               ERR("OCSetPlatformInfo() Fail(%d)", ret);
+               _ioty_free_platform_info(platform_info);
+               return icd_ioty_convert_error(ret);
+       }
+       _ioty_free_platform_info(platform_info);
+
+       return IOTCON_ERROR_NONE;
+}
+
+int icd_ioty_set_tizen_info()
+{
+       int result;
+       OCStackResult ret;
+       OCResourceHandle handle;
+       char *tizen_device_id = NULL;
+
+       result = _icd_ioty_get_tizen_id(&tizen_device_id);
+       if (IOTCON_ERROR_NONE != result) {
+               ERR("_icd_ioty_get_tizen_id() Fail(%d)", result);
+               return result;
+       }
+
+       icd_tizen_info.tizen_device_id = tizen_device_id;
+       DBG("tizen_device_id : %s", icd_tizen_info.tizen_device_id);
+
+       icd_ioty_csdk_lock();
+       ret = OCCreateResource(&handle,
+                       ICD_IOTY_TIZEN_INFO_TYPE,
+                       IC_INTERFACE_DEFAULT,
+                       ICD_IOTY_TIZEN_INFO_URI,
+                       icd_ioty_ocprocess_tizen_info_handler,
+                       NULL,
+                       OC_EXPLICIT_DISCOVERABLE);
+       icd_ioty_csdk_unlock();
+       if (OC_STACK_OK != ret) {
+               ERR("OCCreateResource() Fail(%d)", ret);
+               return icd_ioty_convert_error(ret);
+       }
+
+       return IOTCON_ERROR_NONE;
+}
+
+
+gboolean icd_ioty_get_tizen_info(icDbus *object, GDBusMethodInvocation *invocation,
+               const gchar *host_address, int conn_type)
+{
+       OCStackResult result;
+       OCDevAddr dev_addr = {0};
+       OCCallbackData cbdata = {0};
+       OCConnectivityType oic_conn_type;
+       char host[PATH_MAX] = {0};
+       char *dev_host, *ptr = NULL;
+
+       snprintf(host, sizeof(host), "%s", host_address);
+
+       cbdata.cb = icd_ioty_ocprocess_get_tizen_info_cb;
+       cbdata.context = invocation;
+
+       oic_conn_type = icd_ioty_conn_type_to_oic_conn_type(conn_type);
+       icd_ioty_conn_type_to_oic_transport_type(conn_type, &dev_addr.adapter,
+                       &dev_addr.flags);
+
+       switch (conn_type) {
+       case IOTCON_CONNECTIVITY_IPV4:
+               dev_host = strtok_r(host, ":", &ptr);
+               snprintf(dev_addr.addr, sizeof(dev_addr.addr), "%s", dev_host);
+               dev_addr.port = atoi(strtok_r(NULL, ":", &ptr));
+               break;
+       case IOTCON_CONNECTIVITY_IPV6:
+               dev_host = strtok_r(host, "]", &ptr);
+               snprintf(dev_addr.addr, sizeof(dev_addr.addr), "%s", dev_host);
+               dev_addr.port = atoi(strtok_r(NULL, "]", &ptr));
+               break;
+       default:
+               ERR("Invalid Connectivitiy Type");
+               icd_ioty_complete_error(ICD_TIZEN_INFO, invocation, IOTCON_ERROR_IOTIVITY);
+               return TRUE;
+       }
+
+       icd_ioty_csdk_lock();
+       result = OCDoResource(NULL, OC_REST_GET, ICD_IOTY_TIZEN_INFO_URI, &dev_addr, NULL,
+                       oic_conn_type, OC_LOW_QOS, &cbdata, NULL, 0);
+       icd_ioty_csdk_unlock();
+
+       if (OC_STACK_OK != result) {
+               ERR("OCDoResource() Fail(%d)", result);
+               icd_ioty_complete_error(ICD_TIZEN_INFO, invocation, icd_ioty_convert_error(result));
+               return TRUE;
        }
 
+       return TRUE;
+}
+
+
+int icd_ioty_tizen_info_get_property(char **device_name, char **tizen_device_id)
+{
+       RETV_IF(NULL == device_name, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == tizen_device_id, IOTCON_ERROR_INVALID_PARAMETER);
+
+       *device_name = icd_tizen_info.device_name;
+       *tizen_device_id = icd_tizen_info.tizen_device_id;
+
        return IOTCON_ERROR_NONE;
 }
 
 
-OCDoHandle icd_ioty_subscribe_presence(const char *host_address,
+OCDoHandle icd_ioty_subscribe_presence(const char *host_address, int conn_type,
                const char *resource_type, unsigned int signal_number, const char *bus_name)
 {
        int len;
        OCDoHandle handle;
        OCStackResult result;
+       icd_sig_ctx_s *context;
        char uri[PATH_MAX] = {0};
        OCCallbackData cbdata = {0};
-       icd_sig_ctx_s *context;
+       OCConnectivityType oic_conn_type;
 
        len = snprintf(uri, sizeof(uri), "%s%s", host_address, OC_RSRVD_PRESENCE_URI);
        if (len <= 0 || sizeof(uri) <= len) {
@@ -937,15 +1187,16 @@ OCDoHandle icd_ioty_subscribe_presence(const char *host_address,
                return NULL;
        }
        context->bus_name = ic_utils_strdup(bus_name);
-       context->signum = signal_number;
+       context->signal_number = signal_number;
 
        cbdata.context = context;
        cbdata.cb = icd_ioty_ocprocess_presence_cb;
        cbdata.cd = _ioty_free_signal_context;
 
-       /* In case of IPV4 or IPV6, connectivity type is CT_ADAPTER_IP in iotivity 0.9.2 */
+       oic_conn_type = icd_ioty_conn_type_to_oic_conn_type(conn_type);
+
        icd_ioty_csdk_lock();
-       result = OCDoResource(&handle, OC_REST_PRESENCE, uri, NULL, NULL, CT_ADAPTER_IP,
+       result = OCDoResource(&handle, OC_REST_PRESENCE, uri, NULL, NULL, oic_conn_type,
                        OC_LOW_QOS, &cbdata, NULL, 0);
        icd_ioty_csdk_unlock();
 
@@ -968,7 +1219,7 @@ int icd_ioty_unsubscribe_presence(OCDoHandle handle)
        icd_ioty_csdk_unlock();
        if (OC_STACK_OK != ret) {
                ERR("OCCancel() Fail(%d)", ret);
-               return IOTCON_ERROR_IOTIVITY;
+               return icd_ioty_convert_error(ret);
        }
 
        return IOTCON_ERROR_NONE;
@@ -984,7 +1235,7 @@ int icd_ioty_start_presence(unsigned int time_to_live)
        icd_ioty_csdk_unlock();
        if (OC_STACK_OK != ret) {
                ERR("OCStartPresence() Fail(%d)", ret);
-               return IOTCON_ERROR_IOTIVITY;
+               return icd_ioty_convert_error(ret);
        }
 
        return IOTCON_ERROR_NONE;
@@ -1000,7 +1251,7 @@ int icd_ioty_stop_presence()
        icd_ioty_csdk_unlock();
        if (OC_STACK_OK != ret) {
                ERR("OCStopPresence() Fail(%d)", ret);
-               return IOTCON_ERROR_IOTIVITY;
+               return icd_ioty_convert_error(ret);
        }
 
        return IOTCON_ERROR_NONE;