fix presence unicast callback 52/104152/1 accepted/tizen/3.0/common/20161213.163909 accepted/tizen/3.0/ivi/20161213.025117 accepted/tizen/3.0/mobile/20161213.025037 accepted/tizen/3.0/tv/20161213.025051 accepted/tizen/3.0/wearable/20161213.025100 submit/tizen_3.0/20161212.121610
authorJooseok Park <jooseok.park@samsung.com>
Mon, 12 Dec 2016 11:57:38 +0000 (20:57 +0900)
committerJooseok Park <jooseok.park@samsung.com>
Mon, 12 Dec 2016 11:57:38 +0000 (20:57 +0900)
Change-Id: I60de01959f3a3f69d7a1714a89746cd87113843d

packaging/iotcon.spec
src/ic-ioty.c

index 0cf7c68..f083411 100644 (file)
@@ -1,6 +1,6 @@
 Name:       iotcon
 Summary:    Tizen IoT Connectivity
-Version:    0.3.7
+Version:    0.3.8
 Release:    0
 Group:      Network & Connectivity/Service
 License:    Apache-2.0
index 897dda8..10bafe3 100644 (file)
@@ -726,12 +726,10 @@ int icl_ioty_add_presence_cb(const char *host_address,
                iotcon_presence_h *presence_handle)
 {
        int ret;
-       int conn_extra;
-       int conn_options;
        OCDoHandle handle;
        char uri[PATH_MAX] = {0};
        OCCallbackData cbdata = {0};
-       OCConnectivityType oic_conn_type;
+       OCConnectivityType oic_conn_type = CT_ADAPTER_IP;
        iotcon_presence_h presence = NULL;
        OCDevAddr dev_addr = {0};
 
@@ -749,31 +747,32 @@ int icl_ioty_add_presence_cb(const char *host_address,
        presence->user_data = user_data;
        if (host_address)
                presence->host_address = strdup(host_address);
-       presence->connectivity_type
-               = connectivity_type % IC_CONNECTIVITY_REMOVE_EXTRA_OPTIONS;
        if (resource_type)
                presence->resource_type = strdup(resource_type);
+       if (!(IOTCON_CONNECTIVITY_IP & connectivity_type)) {
+               DBG("default IP type is addeded");
+               connectivity_type |= IOTCON_CONNECTIVITY_IP;
+       }
+       presence->connectivity_type = connectivity_type;
+
+       if (IOTCON_CONNECTIVITY_PREFER_TCP & connectivity_type)
+               oic_conn_type |= CT_ADAPTER_TCP;
+       if (IOTCON_CONNECTIVITY_IPV4_ONLY & connectivity_type)
+               oic_conn_type |= CT_IP_USE_V4;
+       if (IOTCON_CONNECTIVITY_IPV6_ONLY & connectivity_type)
+               oic_conn_type |= CT_IP_USE_V6;
 
        cbdata.context = presence;
        cbdata.cd = NULL;
        cbdata.cb = icl_ioty_ocprocess_presence_cb;
 
-       conn_extra = connectivity_type - presence->connectivity_type;
-
-       conn_options = ic_utils_host_address_get_connectivity(host_address,
-                       presence->connectivity_type);
-       if (NULL == host_address && IOTCON_CONNECTIVITY_IP == presence->connectivity_type) {
-               if (IOTCON_CONNECTIVITY_IPV4_ONLY & conn_extra)
-                       conn_options |= IC_UTILS_CONNECTIVITY_IPV4;
-               else if (IOTCON_CONNECTIVITY_IPV6_ONLY & conn_extra)
-                       conn_options |= IC_UTILS_CONNECTIVITY_IPV6;
-       }
-       oic_conn_type = ic_ioty_convert_connectivity_type(presence->connectivity_type,
-                       conn_options);
-
        if (NULL != host_address) {
+               int temp_conn_type;
+               int conn_options;
+               temp_conn_type = connectivity_type % IC_CONNECTIVITY_REMOVE_EXTRA_OPTIONS;
+               conn_options = ic_utils_host_address_get_connectivity(host_address, temp_conn_type);
                ret = ic_ioty_convert_host_address(host_address,
-                       connectivity_type, conn_options, &dev_addr);
+                       temp_conn_type, conn_options, &dev_addr);
                if (IOTCON_ERROR_NONE != ret) {
                        ERR("ic_ioty_convert_host_address() Fail(%d)", ret);
                        icl_destroy_presence(presence);
@@ -787,7 +786,9 @@ int icl_ioty_add_presence_cb(const char *host_address,
                icl_destroy_presence(presence);
                return ret;
        }
-       DBG("uri:[%s], oic_conn_type:[%d(0x%x)]", uri, oic_conn_type, oic_conn_type);
+
+       DBG("uri:[%s], connectivity_type:[%d(0x%x)], oic_conn_type:[%d(0x%x)]",
+               uri, connectivity_type, connectivity_type, oic_conn_type, oic_conn_type);
        if (NULL != host_address) {
                DBG("dev_addr.addr:[%s], dev_addr.port:[%d]", dev_addr.addr, dev_addr.port);
                ret = OCDoResource(&handle, OC_REST_PRESENCE, uri, &dev_addr, NULL, oic_conn_type,
@@ -796,7 +797,7 @@ int icl_ioty_add_presence_cb(const char *host_address,
                ret = OCDoResource(&handle, OC_REST_PRESENCE, uri, NULL, NULL, oic_conn_type,
                        OC_LOW_QOS, &cbdata, NULL, 0);
        }
-       DBG("handle:[%p]", handle);
+       DBG("oic handle:[%p]", handle);
 
        icl_ioty_mutex_unlock();
        presence->handle = handle;