[ITC][iotcon][Non-ACR][Fix TC fails - managing multiple callback invoke]
authorperforce <perforce@perforce.(none)>
Wed, 1 Jun 2016 07:19:30 +0000 (16:19 +0900)
committerperforce <perforce@perforce.(none)>
Wed, 1 Jun 2016 07:19:30 +0000 (16:19 +0900)
Change-Id: Ia189ca881a3544a28c3073ba3e8068f20e243e50
Signed-off-by: perforce <perforce@perforce.(none)>
src/itc/iotcon/ITs-iotcon-presence-response.c
src/itc/iotcon/ITs-iotcon-presence.c
src/itc/iotcon/ITs-iotcon-remote-resource.c
src/itc/iotcon/ITs-iotcon-request.c
src/itc/iotcon/ITs-iotcon-resource.c
src/itc/iotcon/ITs-iotcon-response.c
src/itc/iotcon/ITs-iotcon-state.c
src/itc/iotcon/tct-iotcon-native_wearable.h

index 3f17b42..48bc858 100755 (executable)
@@ -51,7 +51,7 @@ enum {
  */
 static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h request,void *user_data)
 {
-       
+
 }
 
 /**
@@ -75,8 +75,8 @@ static int CreateResource(int tc_index)
 
        nRet = iotcon_resource_interfaces_create(&light_ifaces);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet),iotcon_resource_types_destroy(light_types));
-       CHECK_HANDLE_CLEANUP(light_ifaces,"iotcon_resource_interfaces_create",iotcon_resource_types_destroy(light_types));      
-       
+       CHECK_HANDLE_CLEANUP(light_ifaces,"iotcon_resource_interfaces_create",iotcon_resource_types_destroy(light_types));
+
        nRet = iotcon_resource_interfaces_add(light_ifaces, IOTCON_INTERFACE_DEFAULT);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_add", IotConGetError(nRet),iotcon_resource_interfaces_destroy(light_ifaces);iotcon_resource_types_destroy(light_types));
 
@@ -102,7 +102,7 @@ static void DestroyResource()
                iotcon_resource_destroy(g_light_resource);
                g_light_resource = NULL;
        }
-               
+
 }
 
 /**
@@ -147,12 +147,12 @@ static void PresenceResponsePresenceCB(iotcon_presence_h presence,iotcon_error_e
        iotcon_presence_trigger_e trigger;
 
        g_bCallbackHit = true;
-       
+
        if(response == NULL)
        {
                return;
        }
-       
+
        if (IOTCON_ERROR_NONE != err)
                return;
 
@@ -236,7 +236,7 @@ static void FoundResourceCB(iotcon_remote_resource_h resource, iotcon_error_e er
        {
                g_timeout_count++;
                nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_ALL,LIGHT_RESOURCE_TYPE, false, FoundResourceCB, user_data);
-               if (IOTCON_ERROR_NONE != nRet) 
+               if (IOTCON_ERROR_NONE != nRet)
                {
                        FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                        presence_response_main_loop_quit(false);
@@ -244,7 +244,7 @@ static void FoundResourceCB(iotcon_remote_resource_h resource, iotcon_error_e er
                }
                return;
        }
-       else if (IOTCON_ERROR_NONE != err) 
+       else if (IOTCON_ERROR_NONE != err)
        {
                presence_response_main_loop_quit(false);
                return;
@@ -256,29 +256,33 @@ static void FoundResourceCB(iotcon_remote_resource_h resource, iotcon_error_e er
        g_found = true;
 
        nRet = iotcon_remote_resource_get_host_address(resource, &host_address);
-       if (IOTCON_ERROR_NONE != nRet) 
+       if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_get_host_address fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                presence_response_main_loop_quit(false);
                return;
        }
 
+       char *uri;
+       iotcon_remote_resource_get_uri_path(resource, &uri);
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
+
        nRet = iotcon_remote_resource_get_connectivity_type(resource, &conn_type);
-       if (IOTCON_ERROR_NONE != nRet) 
+       if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_get_connectivity_type fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                presence_response_main_loop_quit(false);
                return;
        }
-       
+
        g_nRet = iotcon_add_presence_cb(host_address, conn_type, LIGHT_RESOURCE_TYPE,PresenceResponsePresenceCB, user_data, &g_presence);
-       if (IOTCON_ERROR_NONE != g_nRet) 
+       if (IOTCON_ERROR_NONE != g_nRet)
        {
                FPRINTF("[Line : %d][%s] iotcon_add_presence_cb fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nRet));
                presence_response_main_loop_quit(false);
                return;
        }
-       
+
        g_idle_add(PresenceResponseResourceUpdate, NULL);
 }
 
@@ -296,7 +300,7 @@ static int CreateAndFindResource(int tc_index)
 
        nRet = CreateResource(tc_index);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "CreateResource", IotConGetError(nRet));
-       
+
        nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_ALL,LIGHT_RESOURCE_TYPE, false, FoundResourceCB, GINT_TO_POINTER(tc_index));
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet), DestroyResource());
 
@@ -318,7 +322,7 @@ static int CreateAndFindResource(int tc_index)
  * @parameter     NA
  * @return        NA
  */
+
  void ITs_iotcon_presence_response_startup(void)
 {
        struct stat stBuff;
@@ -329,10 +333,10 @@ static int CreateAndFindResource(int tc_index)
        g_bIotconConnect = true;
        g_bFeatureUnsupported = false;
     int nRet = iotcon_initialize();
-       
+
        if ( !TCTCheckSystemInfoFeatureSupported(IOTCON_FEATURE, API_NAMESPACE) )
        {
-               
+
                if ( nRet != TIZEN_ERROR_NOT_SUPPORTED )
                {
                        FPRINTF("[Line : %d][%s] iotcon_initialize API call returned mismatch %s error for unsupported feature\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
@@ -345,25 +349,25 @@ static int CreateAndFindResource(int tc_index)
                }
                return;
        }
-       
+
        if ( nRet != IOTCON_ERROR_NONE )
        {
                FPRINTF("[Line : %d][%s] iotcon_initialize failed API return %s error \\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
                g_bIotconConnect = false;
                return;
        }
-       
-       if (true == g_bIotconConnect) 
+
+       if (true == g_bIotconConnect)
        {
                nRet = iotcon_start_presence(PRESENCE_INTERVAL);
-               if (IOTCON_ERROR_NONE != nRet) 
+               if (IOTCON_ERROR_NONE != nRet)
                {
                        FPRINTF("[Line : %d][%s] iotcon_start_presence fail in startup : \\n", __LINE__, API_NAMESPACE);
                        g_bIotconConnect = false;
                        iotcon_deinitialize();
                        return;
                }
-       }       
+       }
        return;
 }
 
@@ -375,21 +379,21 @@ static int CreateAndFindResource(int tc_index)
  * @return        NA
  */
 void ITs_iotcon_presence_response_cleanup(void)
-{      
+{
        if(g_presence != NULL)
        {
                iotcon_remove_presence_cb(g_presence);
            g_presence = NULL;
        }
-       
+
        /*
-       if (true == g_bIotconConnect) 
+       if (true == g_bIotconConnect)
        {
                //iotcon_stop_presence();
                //iotcon_deinitialize();
        }
        */
-       
+
 }
 
 
@@ -516,4 +520,4 @@ int ITc_iotcon_presence_response_get_host_address_p(void)
 }
 
 /** @} */
-/** @} */
\ No newline at end of file
+/** @} */
index 5159264..a1c940f 100755 (executable)
@@ -38,7 +38,6 @@ enum {
 static bool g_found;
 static int g_timeout_count;
 static bool g_result;
-static bool g_feature;
 static GMainLoop *g_loop;
 
 /* ### server side ### */
@@ -47,7 +46,7 @@ static iotcon_presence_h g_presence;
 
 static gboolean presence_main_loop_quit_idle(gpointer p)
 {
-       
+
        g_main_loop_quit(g_loop);
        return G_SOURCE_REMOVE;
 }
@@ -62,7 +61,7 @@ static void presence_main_loop_quit(bool result)
 static void presence_request_handler(iotcon_resource_h resource,
                iotcon_request_h request, void *user_data)
 {
-       
+
 }
 
 static void presence_destroy_resource()
@@ -86,16 +85,16 @@ static int presence_create_resource()
 
        nRet = iotcon_resource_interfaces_create(&light_ifaces);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet),iotcon_resource_types_destroy(light_types));
-       
+
        nRet = iotcon_resource_interfaces_add(light_ifaces, IOTCON_INTERFACE_DEFAULT);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_add", IotConGetError(nRet),iotcon_resource_interfaces_destroy(light_ifaces);iotcon_resource_types_destroy(light_types));
-       
+
        nRet = iotcon_resource_interfaces_add(light_ifaces, IOTCON_INTERFACE_BATCH);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_add", IotConGetError(nRet),iotcon_resource_interfaces_destroy(light_ifaces);iotcon_resource_types_destroy(light_types));
-       
+
        nRet = iotcon_resource_create(PRESENCE_LIGHT_RESOURCE_URI, light_types, light_ifaces,(IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE),presence_request_handler,NULL,&g_light_resource);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_create", IotConGetError(nRet),iotcon_resource_interfaces_destroy(light_ifaces);iotcon_resource_types_destroy(light_types));
-       
+
        iotcon_resource_interfaces_destroy(light_ifaces);
        iotcon_resource_types_destroy(light_types);
 
@@ -105,12 +104,12 @@ static int presence_create_resource()
 static void presence_handler(iotcon_presence_h presence, iotcon_error_e err,
                iotcon_presence_response_h response, void *user_data)
 {
-       
+
 }
 /**
 * @function            presence_found_resource
-* @description         get remote resource clone 
-* @parameter           iotcon_remote_resource_h : The remote resource handle, iotcon_error_e : iotcon error    
+* @description         get remote resource clone
+* @parameter           iotcon_remote_resource_h : The remote resource handle, iotcon_error_e : iotcon error
 *                                      user_data : The user data passed from function
 * @return                      NA
 */
@@ -125,10 +124,33 @@ static void presence_found_resource(iotcon_remote_resource_h resource,
        iotcon_connectivity_type_e presence_conn_type;
        int tc_index = GPOINTER_TO_INT(user_data);
 
+       if (IOTCON_ERROR_TIMEOUT == err && g_timeout_count < TIMEOUT_COUNT_MAX)
+       {
+               g_timeout_count++;
+               nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,PRESENCE_LIGHT_RESOURCE_TYPE, false, presence_found_resource, GINT_TO_POINTER(tc_index));
+               if (IOTCON_ERROR_NONE != nRet)
+               {
+                       FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
+                       presence_main_loop_quit(false);
+                       return;
+               }
+               return;
+       }
+       else if (IOTCON_ERROR_NONE != err)
+       {
+               presence_main_loop_quit(false);
+               return;
+       }
+
+       if (g_found)
+               return;
+
+       g_found = true;
+
        if(resource == NULL)
        {
-               FPRINTF("[Line : %d][%s] iotcon_remote_resource_h is null in presence_found_resource callback. : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1;
+               FPRINTF("[Line : %d][%s] iotcon_remote_resource_h is null in presence_found_resource callback. \\n", __LINE__, API_NAMESPACE);
+               return;
        }
 
        nRet = iotcon_remote_resource_get_host_address(resource, &host_address);
@@ -138,6 +160,10 @@ static void presence_found_resource(iotcon_remote_resource_h resource,
                return;
        }
 
+       char *uri;
+       iotcon_remote_resource_get_uri_path(resource, &uri);
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
+
        nRet = iotcon_remote_resource_get_connectivity_type(resource, &conn_type);
        if (IOTCON_ERROR_NONE != nRet) {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_get_connectivity_type failed: %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
@@ -145,12 +171,12 @@ static void presence_found_resource(iotcon_remote_resource_h resource,
                return;
        }
 
-       switch (tc_index) 
+       switch (tc_index)
        {
                case PRESENCE_ADD_PRESENCE_CB_P:
                case PRESENCE_REMOVE_PRESENCE_CB_P:
                        nRet = iotcon_add_presence_cb(host_address, conn_type,PRESENCE_LIGHT_RESOURCE_TYPE,presence_handler, NULL, &g_presence);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_add_presence_cb failed: %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                presence_main_loop_quit(false);
@@ -166,14 +192,14 @@ static void presence_found_resource(iotcon_remote_resource_h resource,
                        return;
                case PRESENCE_GET_HOST_ADDR_P:
                        nRet = iotcon_add_presence_cb(host_address, conn_type,PRESENCE_LIGHT_RESOURCE_TYPE,presence_handler, NULL, &g_presence);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_add_presence_cb failed: %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                presence_main_loop_quit(false);
                                return;
                        }
                        nRet = iotcon_presence_get_host_address(g_presence, &presence_host_address);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_presence_get_host_address failed: %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                iotcon_remove_presence_cb(g_presence);
@@ -185,14 +211,14 @@ static void presence_found_resource(iotcon_remote_resource_h resource,
                        return;
                case PRESENCE_GET_CONN_TYPE_P:
                        nRet = iotcon_add_presence_cb(host_address, conn_type,PRESENCE_LIGHT_RESOURCE_TYPE,presence_handler, NULL, &g_presence);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_add_presence_cb failed: %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                presence_main_loop_quit(false);
                                return;
                        }
                        nRet = iotcon_presence_get_connectivity_type(g_presence, &presence_conn_type);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_presence_get_connectivity_type failed: %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                iotcon_remove_presence_cb(g_presence);
@@ -204,14 +230,14 @@ static void presence_found_resource(iotcon_remote_resource_h resource,
                        return;
                case PRESENCE_GET_RSRC_TYPE_P:
                        nRet = iotcon_add_presence_cb(host_address, conn_type,PRESENCE_LIGHT_RESOURCE_TYPE,presence_handler, NULL, &g_presence);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_add_presence_cb failed: %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                presence_main_loop_quit(false);
                                return;
                        }
                        nRet = iotcon_presence_get_resource_type(g_presence, &presence_resource_type);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_presence_get_resource_type failed: %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                iotcon_remove_presence_cb(g_presence);
@@ -231,14 +257,14 @@ static int CreateAndFindResource(int tc_index)
        g_loop = g_main_loop_new(NULL, FALSE);
 
        int nRet = presence_create_resource();
-       if (nRet == 1) 
+       if (nRet == 1)
        {
                FPRINTF("[Line : %d][%s] Handle iotcon_remote_resource_h is null in presence_found_resource callback. : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                return 1;
        }
 
        nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,PRESENCE_LIGHT_RESOURCE_TYPE, false, presence_found_resource, GINT_TO_POINTER(tc_index));
-       if (IOTCON_ERROR_NONE != nRet) 
+       if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] Handle iotcon_remote_resource_h is null in presence_found_resource callback. : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                return 1;
@@ -272,10 +298,10 @@ void ITs_iotcon_presence_startup(void)
        g_bIotconConnect = true;
        g_bFeatureUnsupported = false;
     int nRet = iotcon_initialize();
-       
+
        if ( !TCTCheckSystemInfoFeatureSupported(IOTCON_FEATURE, API_NAMESPACE) )
        {
-               
+
                if ( nRet != TIZEN_ERROR_NOT_SUPPORTED )
                {
                        FPRINTF("[Line : %d][%s] iotcon_initialize API call returned mismatch %s error for unsupported feature\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
@@ -288,14 +314,14 @@ void ITs_iotcon_presence_startup(void)
                }
                return;
        }
-       
+
        if ( nRet != IOTCON_ERROR_NONE )
        {
                FPRINTF("[Line : %d][%s] iotcon_initialize failed API return %s error \\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
                g_bIotconConnect = false;
                return;
        }
-       
+
        return;
 }
 
@@ -361,7 +387,7 @@ int ITc_iotcon_presence_get_connectivity_type_p(void)
        START_TEST;
        int nRet = CreateAndFindResource(PRESENCE_GET_CONN_TYPE_P);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "CreateAndFindResource", IotConGetError(nRet));
-       
+
        return 0;
 }
 
@@ -384,7 +410,7 @@ int ITc_iotcon_presence_get_connectivity_type_p(void)
 int ITc_iotcon_presence_get_resource_type_p(void)
 {
        START_TEST;
-           
+
        int nRet = CreateAndFindResource(PRESENCE_GET_RSRC_TYPE_P);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "CreateAndFindResource", IotConGetError(nRet));
 
@@ -430,9 +456,9 @@ int ITc_iotcon_presence_start_stop_presence_p(void)
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 add and remove new presence handle  
+* @description                 add and remove new presence handle
 * @scenario                            call iotcon_add_presence_cb
-* @apicovered                  iotcon_add_presence_cb,iotcon_remove_presence_cb                        
+* @apicovered                  iotcon_add_presence_cb,iotcon_remove_presence_cb
 * @passcase                            When iotcon_add_presence_cb and iotcon_remove_presence_cb is successful.
 * @failcase                            If target API iotcon_add_presence_cb or iotcon_remove_presence_cb or any precondition API fails.
 * @precondition                        iotcon should be connected
index 0046b5e..9d69025 100755 (executable)
@@ -30,6 +30,8 @@ static iotcon_remote_resource_h g_hcacheHandle = NULL;
 static int g_nRetcb;
 static iotcon_resource_h g_light_resource;
 static int g_brightness = 1;
+static int g_timeout_count;
+static bool g_found;
 
 #define ENCAP_LIGHT_RESOURCE_TYPE "core.light"
 #define ENCAP_LIGHT_RESOURCE_URI "/a/light"
@@ -43,26 +45,26 @@ static int g_brightness = 1;
 static void Iotcon_update_lite_resource(void)
 {
        iotcon_state_h state = NULL;
-   
+
        int ret = iotcon_state_create(&state);
-       if (IOTCON_ERROR_NONE != ret) 
+       if (IOTCON_ERROR_NONE != ret)
        {
                FPRINTF("[Line : %d][%s] iotcon_state_create fail\\n", __LINE__, API_NAMESPACE);
                return;
        }
        ret = iotcon_state_add_int(state, "int", ++g_brightness);
-       if (IOTCON_ERROR_NONE != ret) 
+       if (IOTCON_ERROR_NONE != ret)
        {
                FPRINTF("[Line : %d][%s] iotcon_state_add_int fail\\n", __LINE__, API_NAMESPACE);
                iotcon_state_destroy(state);
                return;
        }
        ret = iotcon_lite_resource_update_state(g_hLiteLightResource, state);
-       if (IOTCON_ERROR_NONE != ret) 
+       if (IOTCON_ERROR_NONE != ret)
        {
                FPRINTF("[Line : %d][%s] iotcon_lite_resource_update_state fail\\n", __LINE__, API_NAMESPACE);
                iotcon_state_destroy(state);
-               return; 
+               return;
        }
        iotcon_state_destroy(state);
        return;
@@ -73,7 +75,7 @@ static void Iotcon_update_lite_resource(void)
 * @description         Resourse and request handler
 * @parameter[IN]       iotcon_resource_h resource
 * @parameter[IN]       iotcon_request_h request
-* @parameter[IN]       user_data       
+* @parameter[IN]       user_data
 * @return                      void
 */
 static void IotconRemoteResourceRequestHandlerCB(iotcon_resource_h resource,iotcon_request_h request, void *user_data)
@@ -85,7 +87,7 @@ static void IotconRemoteResourceRequestHandlerCB(iotcon_resource_h resource,iotc
 * @description         Specifies the type of function passed to iotcon_query_foreach()
 * @parameter[IN]       iotcon_remote_resource_h resource
 * @parameter[IN]       iotcon_representation_h representation
-* @parameter[IN]       user_data The user data to pass to the function         
+* @parameter[IN]       user_data The user data to pass to the function
 * @return                      true to continue with the next iteration of the loop.
 */
 static void IotconRepresentationChangedCB(iotcon_remote_resource_h resource, iotcon_representation_h representation, void *user_data)
@@ -93,7 +95,7 @@ static void IotconRepresentationChangedCB(iotcon_remote_resource_h resource, iot
        FPRINTF("[Line : %d][%s] IotconRepresentationChangedCB\\n", __LINE__, API_NAMESPACE);
        iotcon_representation_h repr = NULL;
        g_nRetcb = true;
-       
+
        if((resource == NULL) || (representation == NULL))
        {
                FPRINTF("[Line : %d][%s] IotconRepresentationChangedCB input resource and representation is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
@@ -108,13 +110,13 @@ static void IotconRepresentationChangedCB(iotcon_remote_resource_h resource, iot
                return;
        }
        g_nCheckAPICb = iotcon_remote_resource_stop_caching(g_hcacheHandle);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_stop_caching failed, error returned : %s\\n", __LINE__, API_NAMESPACE , IotConGetError(g_nCheckAPICb));
                g_main_loop_quit(g_pMainLoop);
                g_main_loop_unref(g_pMainLoop);
                g_pMainLoop = NULL;
-               return; 
+               return;
        }
        if ( g_pMainLoop )
        {
@@ -129,7 +131,7 @@ static void IotconRepresentationChangedCB(iotcon_remote_resource_h resource, iot
 * @description         Specifies the type of function passed to iotcon_query_foreach()
 * @parameter[IN]       iotcon_remote_resource_h resource
 * @parameter[IN]       iotcon_representation_h representation
-* @parameter[IN]       user_data The user data to pass to the function         
+* @parameter[IN]       user_data The user data to pass to the function
 * @return                      true to continue with the next iteration of the loop.
 */
 static void IotconMonitoringChangedCB(iotcon_remote_resource_h resource, iotcon_remote_resource_state_e state, void *user_data)
@@ -153,7 +155,7 @@ static void IotconMonitoringChangedCB(iotcon_remote_resource_h resource, iotcon_
 * @description         Specifies the type of function passed to iotcon_query_foreach()
 * @parameter[IN]       iotcon_remote_resource_h resource
 * @parameter[IN]       iotcon_representation_h representation
-* @parameter[IN]       user_data The user data to pass to the function         
+* @parameter[IN]       user_data The user data to pass to the function
 * @return                      true to continue with the next iteration of the loop.
 */
 static void IotconCachingChangedCB(iotcon_remote_resource_h resource, iotcon_representation_h representation, void *user_data)
@@ -163,24 +165,24 @@ static void IotconCachingChangedCB(iotcon_remote_resource_h resource, iotcon_rep
        {
                FPRINTF("[Line : %d][%s] IotconCachingChangedCB input resource and representation is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
        }
-       
+
        g_nRetcb = true;
-       
+
        g_nCheckAPICb = iotcon_remote_resource_stop_caching(g_hcacheHandle);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_stop_caching failed, error returned : %s\\n", __LINE__, API_NAMESPACE , IotConGetError(g_nCheckAPICb));
                g_main_loop_quit(g_pMainLoop);
                g_main_loop_unref(g_pMainLoop);
                g_pMainLoop = NULL;
-               return; 
+               return;
        }
        if ( g_pMainLoop )
        {
                g_main_loop_quit(g_pMainLoop);
                g_main_loop_unref(g_pMainLoop);
                g_pMainLoop = NULL;
-       }       
+       }
        return;
 }
 
@@ -189,21 +191,61 @@ static void IotconCachingChangedCB(iotcon_remote_resource_h resource, iotcon_rep
 * @description         callback function
 * @parameter[IN]       iotcon_remote_resource_h resource
 * @parameter[IN]       iotcon_error_e err
-* @parameter[IN]       user_data The user data to pass to the function         
+* @parameter[IN]       user_data The user data to pass to the function
 * @return                      void
 */
 static void IotcoRemoteResourceMonitoringCB(iotcon_remote_resource_h resource, iotcon_error_e err, void *user_data)
 {
        FPRINTF("[Line : %d][%s] IotcoRemoteResourceMonitoringCB\\n", __LINE__, API_NAMESPACE);
        int nIotconTimeoutId = 0;
+       int nRet;
        g_bCheckCb = true;
-       
+
+       if (IOTCON_ERROR_TIMEOUT == err && g_timeout_count < TIMEOUT_COUNT_MAX)
+       {
+               g_timeout_count++;
+               nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, ENCAP_LIGHT_RESOURCE_TYPE, false, IotcoRemoteResourceMonitoringCB , NULL);
+               if (IOTCON_ERROR_NONE != nRet)
+               {
+                       FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
+                       if ( g_pMainLoop )
+                       {
+                               g_main_loop_quit(g_pMainLoop);
+                               g_main_loop_unref(g_pMainLoop);
+                               g_pMainLoop = NULL;
+                       }
+                       return;
+               }
+               return;
+       }
+       else if (IOTCON_ERROR_NONE != err)
+       {
+               if ( g_pMainLoop )
+               {
+                       g_main_loop_quit(g_pMainLoop);
+                       g_main_loop_unref(g_pMainLoop);
+                       g_pMainLoop = NULL;
+               }
+               return;
+       }
+
+       if (g_found)
+               return;
+
+       g_found = true;
+
        if(resource == NULL)
        {
                FPRINTF("[Line : %d][%s] IotcoRemoteResourceMonitoringCB input resource is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
        }
+
+       char *host_address, *uri;
+       iotcon_remote_resource_get_host_address(resource, &host_address);
+       iotcon_remote_resource_get_uri_path(resource, &uri);
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
+
        g_nCheckAPICb = iotcon_remote_resource_clone(resource, &g_hcacheHandle);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_clone : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
                g_main_loop_quit(g_pMainLoop);
@@ -214,8 +256,8 @@ static void IotcoRemoteResourceMonitoringCB(iotcon_remote_resource_h resource, i
        g_nCheckAPICb = iotcon_remote_resource_start_monitoring(g_hcacheHandle, IotconMonitoringChangedCB,NULL);
        iotcon_resource_destroy(g_light_resource);
        RUN_POLLING_LOOP;
-       
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_start_monitoring : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
                iotcon_remote_resource_destroy(g_hcacheHandle);
@@ -225,13 +267,13 @@ static void IotcoRemoteResourceMonitoringCB(iotcon_remote_resource_h resource, i
                return;
        }
        g_nCheckAPICb = iotcon_remote_resource_stop_monitoring(g_hcacheHandle);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_stop_monitoring failed, error returned : %s\\n", __LINE__, API_NAMESPACE , IotConGetError(g_nCheckAPICb));
                g_main_loop_quit(g_pMainLoop);
                g_main_loop_unref(g_pMainLoop);
                g_pMainLoop = NULL;
-               return; 
+               return;
        }
        iotcon_remote_resource_destroy(g_hcacheHandle);
 
@@ -241,7 +283,7 @@ static void IotcoRemoteResourceMonitoringCB(iotcon_remote_resource_h resource, i
                g_main_loop_unref(g_pMainLoop);
                g_pMainLoop = NULL;
        }
-       return; 
+       return;
 }
 
 /**
@@ -249,21 +291,61 @@ static void IotcoRemoteResourceMonitoringCB(iotcon_remote_resource_h resource, i
 * @description         callback function
 * @parameter[IN]       iotcon_remote_resource_h resource
 * @parameter[IN]       iotcon_error_e err
-* @parameter[IN]       user_data The user data to pass to the function         
+* @parameter[IN]       user_data The user data to pass to the function
 * @return                      void
 */
 static void IotconRemoteResourceCachingCB(iotcon_remote_resource_h resource,iotcon_error_e err, void *user_data)
 {
        FPRINTF("[Line : %d][%s] IotconRemoteResourceCachingCB\\n", __LINE__, API_NAMESPACE);
        int nIotconTimeoutId = 0;
+       int nRet;
        g_bCheckCb = true;
-       
+
+       if (IOTCON_ERROR_TIMEOUT == err && g_timeout_count < TIMEOUT_COUNT_MAX)
+       {
+               g_timeout_count++;
+               nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, ENCAP_LIGHT_RESOURCE_TYPE, false, IotconRemoteResourceCachingCB, NULL);
+               if (IOTCON_ERROR_NONE != nRet)
+               {
+                       FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
+                       if ( g_pMainLoop )
+                       {
+                               g_main_loop_quit(g_pMainLoop);
+                               g_main_loop_unref(g_pMainLoop);
+                               g_pMainLoop = NULL;
+                       }
+                       return;
+               }
+               return;
+       }
+       else if (IOTCON_ERROR_NONE != err)
+       {
+               if ( g_pMainLoop )
+               {
+                       g_main_loop_quit(g_pMainLoop);
+                       g_main_loop_unref(g_pMainLoop);
+                       g_pMainLoop = NULL;
+               }
+               return;
+       }
+
+       if (g_found)
+               return;
+
+       g_found = true;
+
        if(resource == NULL)
        {
                FPRINTF("[Line : %d][%s] IotconRemoteResourceCachingCB input resource is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
        }
+
+       char *host_address, *uri;
+       iotcon_remote_resource_get_host_address(resource, &host_address);
+       iotcon_remote_resource_get_uri_path(resource, &uri);
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
+
        g_nCheckAPICb = iotcon_remote_resource_clone(resource, &g_hcacheHandle);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_clone : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
                g_main_loop_quit(g_pMainLoop);
@@ -272,7 +354,7 @@ static void IotconRemoteResourceCachingCB(iotcon_remote_resource_h resource,iotc
                return;
        }
        g_nCheckAPICb = iotcon_remote_resource_start_caching(g_hcacheHandle, IotconCachingChangedCB, NULL);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_start_caching : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
                iotcon_remote_resource_destroy(g_hcacheHandle);
@@ -283,16 +365,16 @@ static void IotconRemoteResourceCachingCB(iotcon_remote_resource_h resource,iotc
        }
        Iotcon_update_lite_resource();
        RUN_POLLING_LOOP;
-       
+
        iotcon_remote_resource_destroy(g_hcacheHandle);
-    
+
        if ( g_pMainLoop )
        {
                g_main_loop_quit(g_pMainLoop);
                g_main_loop_unref(g_pMainLoop);
                g_pMainLoop = NULL;
        }
-       return; 
+       return;
 }
 
 /**
@@ -300,7 +382,7 @@ static void IotconRemoteResourceCachingCB(iotcon_remote_resource_h resource,iotc
 * @description         callback function
 * @parameter[IN]       iotcon_remote_resource_h resource
 * @parameter[IN]       iotcon_error_e err
-* @parameter[IN]       user_data The user data to pass to the function         
+* @parameter[IN]       user_data The user data to pass to the function
 * @return                      void
 */
 static void IotconRemoteResourceRepresentationCB(iotcon_remote_resource_h resource, iotcon_error_e err, void *user_data)
@@ -308,12 +390,54 @@ static void IotconRemoteResourceRepresentationCB(iotcon_remote_resource_h resour
        FPRINTF("[Line : %d][%s] IotconRemoteResourceRepresentationCB\\n", __LINE__, API_NAMESPACE);
        g_bCheckCb = true;
        int nIotconTimeoutId = 0;
+       int nRet;
+
+       if (IOTCON_ERROR_TIMEOUT == err && g_timeout_count < TIMEOUT_COUNT_MAX)
+       {
+               g_timeout_count++;
+               nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, ENCAP_LIGHT_RESOURCE_TYPE, false, IotconRemoteResourceRepresentationCB, NULL);
+               if (IOTCON_ERROR_NONE != nRet)
+               {
+                       FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
+                       if ( g_pMainLoop )
+                       {
+                               g_main_loop_quit(g_pMainLoop);
+                               g_main_loop_unref(g_pMainLoop);
+                               g_pMainLoop = NULL;
+                       }
+                       return;
+               }
+               return;
+       }
+       else if (IOTCON_ERROR_NONE != err)
+       {
+               if ( g_pMainLoop )
+               {
+                       g_main_loop_quit(g_pMainLoop);
+                       g_main_loop_unref(g_pMainLoop);
+                       g_pMainLoop = NULL;
+               }
+               return;
+       }
+
+       if (g_found)
+               return;
+
+       g_found = true;
+
+
        if(resource == NULL)
        {
                FPRINTF("[Line : %d][%s] IotconRemoteResourceRepresentationCB input resource is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
        }
+
+       char *host_address, *uri;
+       iotcon_remote_resource_get_host_address(resource, &host_address);
+       iotcon_remote_resource_get_uri_path(resource, &uri);
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
+
        g_nCheckAPICb = iotcon_remote_resource_clone(resource, &g_hcacheHandle);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_clone error\\n", __LINE__, API_NAMESPACE);
                g_main_loop_quit(g_pMainLoop);
@@ -322,7 +446,7 @@ static void IotconRemoteResourceRepresentationCB(iotcon_remote_resource_h resour
                return;
        }
        g_nCheckAPICb = iotcon_remote_resource_start_caching(g_hcacheHandle, IotconRepresentationChangedCB, NULL);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_start_caching\\n", __LINE__, API_NAMESPACE);
                iotcon_remote_resource_destroy(g_hcacheHandle);
@@ -333,16 +457,16 @@ static void IotconRemoteResourceRepresentationCB(iotcon_remote_resource_h resour
        }
        Iotcon_update_lite_resource();
        RUN_POLLING_LOOP;
-       
+
        iotcon_remote_resource_destroy(g_hcacheHandle);
-       
+
        if ( g_pMainLoop )
        {
                g_main_loop_quit(g_pMainLoop);
                g_main_loop_unref(g_pMainLoop);
                g_pMainLoop = NULL;
        }
-       return;         
+       return;
 }
 
 /**
@@ -354,11 +478,53 @@ static void IotconRemoteResourceRepresentationCB(iotcon_remote_resource_h resour
  static void IotconRemoteResourceOptionsCB(iotcon_remote_resource_h resource, iotcon_error_e result,void *user_data)
 {
        FPRINTF("[Line : %d][%s] IotconRemoteResourceOptionsCB\\n", __LINE__, API_NAMESPACE);
+       int nRet;
        g_bCheckCb = true;
+
+       if (IOTCON_ERROR_TIMEOUT == result && g_timeout_count < TIMEOUT_COUNT_MAX)
+       {
+               g_timeout_count++;
+               nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,ENCAP_LIGHT_RESOURCE_TYPE, false, IotconRemoteResourceOptionsCB, NULL);
+               if (IOTCON_ERROR_NONE != nRet)
+               {
+                       FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
+                       if ( g_pMainLoop )
+                       {
+                               g_main_loop_quit(g_pMainLoop);
+                               g_main_loop_unref(g_pMainLoop);
+                               g_pMainLoop = NULL;
+                       }
+                       return;
+               }
+               return;
+       }
+       else if (IOTCON_ERROR_NONE != result)
+       {
+               if ( g_pMainLoop )
+               {
+                       g_main_loop_quit(g_pMainLoop);
+                       g_main_loop_unref(g_pMainLoop);
+                       g_pMainLoop = NULL;
+               }
+               return;
+       }
+
+       if (g_found)
+               return;
+
+       g_found = true;
+
+
        if(resource == NULL)
        {
                FPRINTF("[Line : %d][%s] Iotcon_presence_found_resource_cb input resource is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
        }
+
+       char *host_address, *uri;
+       iotcon_remote_resource_get_host_address(resource, &host_address);
+       iotcon_remote_resource_get_uri_path(resource, &uri);
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
+
        g_hResourceHandle = resource;
        if ( g_pMainLoop )
        {
@@ -387,14 +553,14 @@ int IotconCreateRemoteResource()
        nRet = iotcon_resource_interfaces_create(&g_hInterface);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet), iotcon_resource_types_destroy(g_hTypes));
        CHECK_HANDLE(g_hInterface,"iotcon_resource_interfaces_create");
-       
+
        nRet = iotcon_resource_interfaces_add(g_hInterface, IOTCON_INTERFACE_DEFAULT);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_add", IotConGetError(nRet), iotcon_resource_interfaces_destroy(g_hInterface);iotcon_resource_types_destroy(g_hTypes));
-       
+
        nRet = iotcon_remote_resource_create(REMOTE_IP, IOTCON_CONNECTIVITY_IPV4, REMOTE_RESOURCE_LIGHT,IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE, g_hTypes, g_hInterface, &g_hClient);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_remote_resource_create", IotConGetError(nRet),  iotcon_resource_interfaces_destroy(g_hInterface);iotcon_resource_types_destroy(g_hTypes));                                                                          
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_remote_resource_create", IotConGetError(nRet),  iotcon_resource_interfaces_destroy(g_hInterface);iotcon_resource_types_destroy(g_hTypes));
     CHECK_HANDLE(g_hClient,"iotcon_remote_resource_create");
-       
+
     iotcon_resource_types_destroy(g_hTypes);
        iotcon_resource_interfaces_destroy(g_hInterface);
        return 0;
@@ -408,7 +574,7 @@ int IotconCreateRemoteResource()
 */
 void IotconDestroyRemoteResource()
 {
-       if (g_hClient) 
+       if (g_hClient)
        {
                iotcon_remote_resource_destroy(g_hClient);
                g_hClient = NULL;
@@ -420,7 +586,7 @@ void IotconDestroyRemoteResource()
 * @description         Create Resource
 * @parameter           NA
 * @return                      int
-*/     
+*/
 int IotconCreateResource()
 {
        int nRet = iotcon_resource_types_create(&g_hTypes);
@@ -429,32 +595,32 @@ int IotconCreateResource()
 
        nRet = iotcon_resource_types_add(g_hTypes,LIGHT_RESOURCE);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_add", IotConGetError(nRet), iotcon_resource_types_destroy(g_hTypes));
-       
+
        nRet = iotcon_resource_interfaces_create(&g_hInterface);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet), iotcon_resource_types_destroy(g_hTypes));
        CHECK_HANDLE(g_hInterface,"iotcon_resource_interfaces_create");
 
        nRet = iotcon_resource_interfaces_add(g_hInterface, IOTCON_INTERFACE_DEFAULT);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_add", IotConGetError(nRet), iotcon_resource_interfaces_destroy(g_hInterface);iotcon_resource_types_destroy(g_hTypes));
-       
+
        nRet = iotcon_resource_create(REMOTE_RESOURCE_LIGHT,g_hTypes,g_hInterface,(IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE),IotconRemoteResourceRequestHandlerCB,NULL,&g_light_resource);
-    PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_create", IotConGetError(nRet),  iotcon_resource_interfaces_destroy(g_hInterface);iotcon_resource_types_destroy(g_hTypes));                                                                    
-    CHECK_HANDLE(g_light_resource,"iotcon_resource_create");   
-   
+    PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_create", IotConGetError(nRet),  iotcon_resource_interfaces_destroy(g_hInterface);iotcon_resource_types_destroy(g_hTypes));
+    CHECK_HANDLE(g_light_resource,"iotcon_resource_create");
+
     iotcon_resource_types_destroy(g_hTypes);
        iotcon_resource_interfaces_destroy(g_hInterface);
        return 0;
-}      
+}
 
 /**
 * @function            IotconDestroyResource
 * @description         Destroy Resource
 * @parameter           NA
 * @return                      NA
-*/     
+*/
 void IotconDestroyResource()
 {
-       if (g_light_resource) 
+       if (g_light_resource)
        {
                iotcon_resource_destroy(g_light_resource);
                g_light_resource = NULL;
@@ -468,7 +634,7 @@ void IotconDestroyResource()
 * @parameter[IN]       iotcon_error_e err
 * @parameter[IN]       iotcon_request_type_e request_type
 * @parameter[IN]       iotcon_response_h response
-* @parameter[IN]       user_data The user data to pass to the function         
+* @parameter[IN]       user_data The user data to pass to the function
 * @return                      true to continue with the next iteration of the loop.
 */
 static void IotconGetChangedCB(iotcon_remote_resource_h resource, iotcon_error_e err,iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
@@ -493,7 +659,7 @@ static void IotconGetChangedCB(iotcon_remote_resource_h resource, iotcon_error_e
 * @parameter[IN]       iotcon_error_e err
 * @parameter[IN]       iotcon_request_type_e request_type
 * @parameter[IN]       iotcon_response_h response
-* @parameter[IN]       user_data The user data to pass to the function         
+* @parameter[IN]       user_data The user data to pass to the function
 * @return                      true to continue with the next iteration of the loop.
 */
 static void IotconPutChangedCB(iotcon_remote_resource_h resource, iotcon_error_e err,iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
@@ -518,7 +684,7 @@ static void IotconPutChangedCB(iotcon_remote_resource_h resource, iotcon_error_e
 * @parameter[IN]       iotcon_error_e err
 * @parameter[IN]       iotcon_request_type_e request_type
 * @parameter[IN]       iotcon_response_h response
-* @parameter[IN]       user_data The user data to pass to the function         
+* @parameter[IN]       user_data The user data to pass to the function
 * @return                      true to continue with the next iteration of the loop.
 */
 static void IotconPostChangedCB(iotcon_remote_resource_h resource, iotcon_error_e err,iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
@@ -537,13 +703,13 @@ static void IotconPostChangedCB(iotcon_remote_resource_h resource, iotcon_error_
        return;
 }
 /**
-* @function                    IotconDeleteChangedCB 
+* @function                    IotconDeleteChangedCB
 * @description         callback
 * @parameter[IN]       iotcon_remote_resource_h resource
 * @parameter[IN]       iotcon_error_e err
 * @parameter[IN]       iotcon_request_type_e request_type
 * @parameter[IN]       iotcon_response_h response
-* @parameter[IN]       user_data The user data to pass to the function         
+* @parameter[IN]       user_data The user data to pass to the function
 * @return                      true to continue with the next iteration of the loop.
 */
 static void IotconDeleteChangedCB(iotcon_remote_resource_h resource, iotcon_error_e err,iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
@@ -567,7 +733,7 @@ static void IotconDeleteChangedCB(iotcon_remote_resource_h resource, iotcon_erro
 * @description         callback
 * @parameter[IN]       iotcon_remote_resource_h resource
 * @parameter[IN]       iotcon_error_e err
-* @parameter[IN]       user_data The user data to pass to the function         
+* @parameter[IN]       user_data The user data to pass to the function
 * @return                      void
 */
 static void IotconRemoteResourceGetPutPostDelCB(iotcon_remote_resource_h resource, iotcon_error_e err, void *user_data)
@@ -575,48 +741,88 @@ static void IotconRemoteResourceGetPutPostDelCB(iotcon_remote_resource_h resourc
        iotcon_query_h query;
        g_bCheckCb = true;
        int nIotconTimeoutId = 0;
+       int nRet;
        iotcon_representation_h hRepr = NULL;
-       
+
+       if (IOTCON_ERROR_TIMEOUT == err && g_timeout_count < TIMEOUT_COUNT_MAX)
+       {
+               g_timeout_count++;
+               nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, ENCAP_LIGHT_RESOURCE_TYPE, false, IotconRemoteResourceGetPutPostDelCB, NULL);
+               if (IOTCON_ERROR_NONE != nRet)
+               {
+                       FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
+                       if ( g_pMainLoop )
+                       {
+                               g_main_loop_quit(g_pMainLoop);
+                               g_main_loop_unref(g_pMainLoop);
+                               g_pMainLoop = NULL;
+                       }
+                       return;
+               }
+               return;
+       }
+       else if (IOTCON_ERROR_NONE != err)
+       {
+               if ( g_pMainLoop )
+               {
+                       g_main_loop_quit(g_pMainLoop);
+                       g_main_loop_unref(g_pMainLoop);
+                       g_pMainLoop = NULL;
+               }
+               return;
+       }
+
+       if (g_found)
+               return;
+
+       g_found = true;
+
+
        if(resource == NULL)
        {
                FPRINTF("[Line : %d][%s] Iotcon_remote_resource_observe_cb_p input resource is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
        }
-       
+
+       char *host_address, *uri;
+       iotcon_remote_resource_get_host_address(resource, &host_address);
+       iotcon_remote_resource_get_uri_path(resource, &uri);
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
+
        g_nCheckAPICb = iotcon_remote_resource_clone(resource, &g_hcacheHandle);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_clone : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
                return;
        }
        g_nCheckAPICb = iotcon_query_create(&query);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_query_create : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
                iotcon_remote_resource_destroy(g_hcacheHandle);
                return;
        }
        g_nCheckAPICb = iotcon_query_add(query, "key", "value");
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_query_add : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
-               iotcon_query_destroy(query); 
+               iotcon_query_destroy(query);
                iotcon_remote_resource_destroy(g_hcacheHandle);
                return;
        }
        //Get
        g_nCheckAPICb =  iotcon_remote_resource_get(g_hcacheHandle, query, IotconGetChangedCB, NULL);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_get : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
                iotcon_remote_resource_destroy(g_hcacheHandle);
-               iotcon_query_destroy(query); 
+               iotcon_query_destroy(query);
                return;
        }
        RUN_POLLING_LOOP;
-       iotcon_query_destroy(query); 
+       iotcon_query_destroy(query);
        //Put
        g_nCheckAPICb = iotcon_representation_create(&hRepr);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_representation_create : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
                iotcon_remote_resource_destroy(g_hcacheHandle);
@@ -629,28 +835,28 @@ static void IotconRemoteResourceGetPutPostDelCB(iotcon_remote_resource_h resourc
                return;
        }
        g_nCheckAPICb = iotcon_remote_resource_put(g_hcacheHandle, hRepr, NULL, IotconPutChangedCB, NULL);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_get : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
                iotcon_remote_resource_destroy(g_hcacheHandle);
-               iotcon_representation_destroy(hRepr); 
+               iotcon_representation_destroy(hRepr);
                return;
        }
        RUN_POLLING_LOOP;
        //post
        g_nCheckAPICb = iotcon_remote_resource_post(g_hcacheHandle, hRepr, NULL, IotconPostChangedCB, NULL);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_get : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
                iotcon_remote_resource_destroy(g_hcacheHandle);
-               iotcon_representation_destroy(hRepr); 
+               iotcon_representation_destroy(hRepr);
                return;
        }
        RUN_POLLING_LOOP;
-       iotcon_representation_destroy(hRepr); 
+       iotcon_representation_destroy(hRepr);
        //delete
        g_nCheckAPICb = iotcon_remote_resource_delete(g_hcacheHandle, IotconDeleteChangedCB, NULL);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_get : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
                iotcon_remote_resource_destroy(g_hcacheHandle);
@@ -664,7 +870,7 @@ static void IotconRemoteResourceGetPutPostDelCB(iotcon_remote_resource_h resourc
                g_main_loop_unref(g_pMainLoop);
                g_pMainLoop = NULL;
        }
-       return; 
+       return;
 }
 
 /**
@@ -674,7 +880,7 @@ static void IotconRemoteResourceGetPutPostDelCB(iotcon_remote_resource_h resourc
 * @parameter[IN]       iotcon_error_e err
 * @parameter[IN]       int sequence_number
 * @parameter[IN]       iotcon_response_h response
-* @parameter[IN]       user_data The user data to pass to the function         
+* @parameter[IN]       user_data The user data to pass to the function
 * @return                      true to continue with the next iteration of the loop.
 */
 static void IotconObserveChangedCB(iotcon_remote_resource_h resource, iotcon_error_e err,int sequence_number, iotcon_response_h response, void *user_data)
@@ -683,23 +889,23 @@ static void IotconObserveChangedCB(iotcon_remote_resource_h resource, iotcon_err
        {
                FPRINTF("[Line : %d][%s] IotconObserveChangedCB input resource and response is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
        }
-       
+
        g_nRetcb = true;
 
        g_nCheckAPICb = iotcon_remote_resource_observe_deregister(resource);
        if(g_nCheckAPICb != IOTCON_ERROR_NONE)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_observe_deregister failed, error returned : %s\\n", __LINE__, API_NAMESPACE , IotConGetError(g_nCheckAPICb));
-               return;         
+               return;
        }
-       
+
        if ( g_pMainLoop )
        {
                g_main_loop_quit(g_pMainLoop);
                g_main_loop_unref(g_pMainLoop);
                g_pMainLoop = NULL;
        }
-       
+
        return;
 }
 
@@ -708,28 +914,69 @@ static void IotconObserveChangedCB(iotcon_remote_resource_h resource, iotcon_err
 * @description         callback function
 * @parameter[IN]       iotcon_remote_resource_h resource
 * @parameter[IN]       iotcon_error_e err
-* @parameter[IN]       user_data The user data to pass to the function         
+* @parameter[IN]       user_data The user data to pass to the function
 * @return                      void
 */
 static void IotconRemoteResourceObserveCB(iotcon_remote_resource_h resource, iotcon_error_e err, void *user_data)
 {
        FPRINTF("[Line : %d][%s] IotconRemoteResourceObserveCB\\n", __LINE__, API_NAMESPACE);
        int nIotconTimeoutId = 0;
+       int nRet;
        g_bCheckCb = true;
-       
+
+       if (IOTCON_ERROR_TIMEOUT == err && g_timeout_count < TIMEOUT_COUNT_MAX)
+       {
+               g_timeout_count++;
+               nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, ENCAP_LIGHT_RESOURCE_TYPE, false, IotconRemoteResourceObserveCB, NULL);
+               if (IOTCON_ERROR_NONE != nRet)
+               {
+                       FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
+                       iotcon_remote_resource_destroy(g_hcacheHandle);
+                       if ( g_pMainLoop )
+                       {
+                               g_main_loop_quit(g_pMainLoop);
+                               g_main_loop_unref(g_pMainLoop);
+                               g_pMainLoop = NULL;
+                       }
+                       return;
+               }
+               return;
+       }
+       else if (IOTCON_ERROR_NONE != err)
+       {
+               iotcon_remote_resource_destroy(g_hcacheHandle);
+               if ( g_pMainLoop )
+               {
+                       g_main_loop_quit(g_pMainLoop);
+                       g_main_loop_unref(g_pMainLoop);
+                       g_pMainLoop = NULL;
+               }
+               return;
+       }
+
+       if (g_found)
+               return;
+
+       g_found = true;
+
        if(resource == NULL)
        {
                FPRINTF("[Line : %d][%s] IotconRemoteResourceObserveCB input resource is NULL failed !!!\\n", __LINE__, API_NAMESPACE);
        }
-       
+
+       char *host_address, *uri;
+       iotcon_remote_resource_get_host_address(resource, &host_address);
+       iotcon_remote_resource_get_uri_path(resource, &uri);
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
+
        g_nCheckAPICb = iotcon_remote_resource_clone(resource, &g_hcacheHandle);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_clone : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
                return;
        }
        g_nCheckAPICb = iotcon_remote_resource_observe_register(g_hcacheHandle, IOTCON_OBSERVE_IGNORE_OUT_OF_ORDER, NULL, IotconObserveChangedCB, NULL);
-       if (IOTCON_ERROR_NONE != g_nCheckAPICb) 
+       if (IOTCON_ERROR_NONE != g_nCheckAPICb)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_observe_register : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(g_nCheckAPICb));
                iotcon_remote_resource_destroy(g_hcacheHandle);
@@ -744,7 +991,7 @@ static void IotconRemoteResourceObserveCB(iotcon_remote_resource_h resource, iot
                g_main_loop_unref(g_pMainLoop);
                g_pMainLoop = NULL;
        }
-       return; 
+       return;
 }
 /**
  * @function           ITs_iotcon_remote_resource_startup
@@ -762,10 +1009,10 @@ void ITs_iotcon_remote_resource_startup(void)
        g_bIotconConnect = true;
        g_bFeatureUnsupported = false;
     int nRet = iotcon_initialize();
-       
+
        if ( !TCTCheckSystemInfoFeatureSupported(IOTCON_FEATURE, API_NAMESPACE) )
        {
-               
+
                if ( nRet != TIZEN_ERROR_NOT_SUPPORTED )
                {
                        FPRINTF("[Line : %d][%s] iotcon_initialize API call returned mismatch %s error for unsupported feature\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
@@ -778,14 +1025,14 @@ void ITs_iotcon_remote_resource_startup(void)
                }
                return;
        }
-       
+
        if ( nRet != IOTCON_ERROR_NONE )
        {
                FPRINTF("[Line : %d][%s] iotcon_initialize failed API return %s error \\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
                g_bIotconConnect = false;
                return;
        }
-       
+
        return;
 }
 
@@ -811,17 +1058,17 @@ void ITs_iotcon_remote_resource_cleanup(void)
 *  @{
 */
 
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_create_destroy_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Create/destroy a remote resource handle.  
+* @description                 Create/destroy a remote resource handle.
 * @scenario                            call iotcon_initialize() ,create types , add types then create remote resource;
-* @apicovered                  iotcon_remote_resource_create , iotcon_remote_resource_destroy ,iotcon_resource_types_add ,iotcon_resource_types_create.                                        
+* @apicovered                  iotcon_remote_resource_create , iotcon_remote_resource_destroy ,iotcon_resource_types_add ,iotcon_resource_types_create.
 * @passcase                            When iotcon_remote_resource_create and iotcon_remote_resource_destroy is successful.
 * @failcase                            If API iotcon_remote_resource_create and iotcon_remote_resource_destroy fails.
 * @precondition                        iotcon_initialize() should be successfully called
@@ -834,14 +1081,14 @@ int ITc_iotcon_remote_resource_create_destroy_p(void)
        iotcon_remote_resource_h hClient = NULL;
        iotcon_resource_types_h hTypes = NULL;
        iotcon_resource_interfaces_h hInterface = NULL;
-       
+
        int nRet = iotcon_resource_types_create(&hTypes);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_create", IotConGetError(nRet));
        CHECK_HANDLE(hTypes,"iotcon_resource_types_create");
 
        nRet = iotcon_resource_types_add(hTypes, LIGHT_RESOURCE);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_add", IotConGetError(nRet), iotcon_resource_types_destroy(hTypes));
-       
+
        nRet = iotcon_resource_interfaces_create(&hInterface);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet), iotcon_resource_types_destroy(hTypes));
        CHECK_HANDLE(hInterface,"iotcon_resource_interfaces_create");
@@ -849,7 +1096,7 @@ int ITc_iotcon_remote_resource_create_destroy_p(void)
        nRet = iotcon_resource_interfaces_add(hInterface, IOTCON_INTERFACE_DEFAULT);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet),
                                                 iotcon_resource_interfaces_destroy(hInterface);iotcon_resource_types_destroy(hTypes));
-    
+
        nRet = iotcon_remote_resource_create(REMOTE_IP, IOTCON_CONNECTIVITY_IPV4, REMOTE_RESOURCE_LIGHT,IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE
                                                                                , hTypes, hInterface, &hClient);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet),
@@ -864,17 +1111,17 @@ int ITc_iotcon_remote_resource_create_destroy_p(void)
 }
 
 
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_clone_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Creates clone of existing resource .  
+* @description                 Creates clone of existing resource .
 * @scenario                            Call iotcon_remote_resource_clone
-* @apicovered                  iotcon_remote_resource_clone .iotcon_remote_resource_destroy                                    
+* @apicovered                  iotcon_remote_resource_clone .iotcon_remote_resource_destroy
 * @passcase                            When iotcon_remote_resource_clone is successful.
 * @failcase                            If target API iotcon_remote_resource_clone fails.
 * @precondition                        iotcon_initialize() should be successfully called
@@ -888,7 +1135,7 @@ int ITc_iotcon_remote_resource_clone_p(void)
        iotcon_resource_types_h hTypes = NULL;
        iotcon_resource_interfaces_h hInterface = NULL;
        iotcon_remote_resource_h hClonedClient = NULL;
-       
+
        int nRet = iotcon_resource_types_create(&hTypes);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_create", IotConGetError(nRet));
        CHECK_HANDLE(hTypes,"iotcon_resource_types_create");
@@ -903,13 +1150,13 @@ int ITc_iotcon_remote_resource_clone_p(void)
        nRet = iotcon_resource_interfaces_add(hInterface, IOTCON_INTERFACE_DEFAULT);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet),
                                                 iotcon_resource_interfaces_destroy(hInterface);iotcon_resource_types_destroy(hTypes));
-                                                
+
        nRet = iotcon_remote_resource_create(REMOTE_IP, IOTCON_CONNECTIVITY_IPV4, REMOTE_RESOURCE_LIGHT,IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE
                                                                                , hTypes, hInterface, &hClient);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet),
                                                 iotcon_resource_interfaces_destroy(hInterface);iotcon_resource_types_destroy(hTypes));
        CHECK_HANDLE(hClient,"iotcon_remote_resource_create");
-       
+
        nRet = iotcon_remote_resource_clone(hClient, &hClonedClient);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_remote_resource_clone", IotConGetError(nRet),
                                                 iotcon_resource_interfaces_destroy(hInterface);iotcon_resource_types_destroy(hTypes);iotcon_remote_resource_destroy(hClient));
@@ -919,20 +1166,20 @@ int ITc_iotcon_remote_resource_clone_p(void)
        iotcon_remote_resource_destroy(hClient);
        iotcon_remote_resource_destroy(hClonedClient);
        iotcon_resource_types_destroy(hTypes);
-       
+
        return 0;
 }
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_observe_register_deregister_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Register/Deregister remote resource.  
-* @scenario                            call iotcon_remote_resource_clone and iotcon_remote_resource_get to invoke callback function 
-* @apicovered                  iotcon_remote_resource_clone , iotcon_remote_resource_get ,     iotcon_remote_resource_destroy,iotcon_remote_resource_observe_register, iotcon_remote_resource_observe_deregister                               
+* @description                 Register/Deregister remote resource.
+* @scenario                            call iotcon_remote_resource_clone and iotcon_remote_resource_get to invoke callback function
+* @apicovered                  iotcon_remote_resource_clone , iotcon_remote_resource_get ,     iotcon_remote_resource_destroy,iotcon_remote_resource_observe_register, iotcon_remote_resource_observe_deregister
 * @passcase                            When iotcon_query_create is successful.
 * @failcase                            If target API fails.
 * @precondition                        iotcon_initialize() should be successfully called
@@ -941,44 +1188,44 @@ int ITc_iotcon_remote_resource_clone_p(void)
 int ITc_iotcon_remote_resource_observe_register_deregister_p(void)
 {
        START_TEST;
-       
+
        int nIotconTimeoutId = 0;
        int nRet = IotconCreateLiteResource();
     if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLiteResource failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1; 
+               return 1;
        }
        g_bCheckCb = false;
        g_nRetcb = false;
        g_nCheckAPICb = 0;
-       
+
        nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, ENCAP_LIGHT_RESOURCE_TYPE, false, IotconRemoteResourceObserveCB, NULL);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet),IotconDestroyLiteResource());
        RUN_POLLING_LOOP;
-       
+
        if((g_bCheckCb == false) || (g_nRetcb == false))
        {
                FPRINTF("[Line : %d][%s] IotconRemoteResourceObserveCB callback not invoked: \\n", __LINE__, API_NAMESPACE );
                IotconDestroyLiteResource();
                return 1;
        }
-       
+
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, g_nCheckAPICb, "API call inside callback failed", IotConGetError(g_nCheckAPICb),IotconDestroyLiteResource());
     IotconDestroyLiteResource();
        return 0;
 }
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_get_put_post_delete_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Get put post delete remote resource.  
+* @description                 Get put post delete remote resource.
 * @scenario                            call iotcon_remote_resource_clone
-* @apicovered                  iotcon_remote_resource_clone , iotcon_remote_resource_get ,iotcon_representation_create ,iotcon_remote_resource_put,iotcon_remote_resource_post,iotcon_remote_resource_delete                           
+* @apicovered                  iotcon_remote_resource_clone , iotcon_remote_resource_get ,iotcon_representation_create ,iotcon_remote_resource_put,iotcon_remote_resource_post,iotcon_remote_resource_delete
 * @passcase                            When iotcon_remote_resource_clone , iotcon_remote_resource_get ,iotcon_representation_create    ,iotcon_remote_resource_put,iotcon_remote_resource_post,iotcon_remote_resource_delete is successful.
 * @failcase                            If target API fails.
 * @precondition                        iotcon_initialize() should be successfully called
@@ -987,13 +1234,13 @@ int ITc_iotcon_remote_resource_observe_register_deregister_p(void)
 int ITc_iotcon_remote_resource_get_put_post_delete_p(void)
 {
        START_TEST;
-       
+
        int nIotconTimeoutId = 0;
        int nRet = IotconCreateLiteResource();
     if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLiteResource failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1; 
+               return 1;
        }
        g_bCheckCb = false;
        g_nGetCb = false;
@@ -1001,34 +1248,34 @@ int ITc_iotcon_remote_resource_get_put_post_delete_p(void)
        g_nPostCb = false;
        g_nDeleteCb = false;
        g_nCheckAPICb = 0;
-       
+
        nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, ENCAP_LIGHT_RESOURCE_TYPE, false, IotconRemoteResourceGetPutPostDelCB, NULL);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet),IotconDestroyLiteResource());
        RUN_POLLING_LOOP;
-       
+
        if((g_bCheckCb == false) || (g_nGetCb == false) || (g_nPutCb == false) || (g_nPostCb == false) || (g_nDeleteCb == false))
        {
                FPRINTF("[Line : %d][%s] ITc_iotcon_remote_resource_get_put_post_delete_p callback not invoked: \\n", __LINE__, API_NAMESPACE );
                IotconDestroyLiteResource();
                return 1;
        }
-       
+
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, g_nCheckAPICb, "API call inside callback failed", IotConGetError(g_nCheckAPICb),IotconDestroyLiteResource());
     IotconDestroyLiteResource();
-       
+
        return 0;
 }
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_start_stop_caching_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Creates a new query handle.  
+* @description                 Creates a new query handle.
 * @scenario                            call iotcon_query_create
-* @apicovered                  iotcon_remote_resource_clone, iotcon_remote_resource_start_caching, iotcon_remote_resource_stop_caching ,iotcon_remote_resource_destroy                         
+* @apicovered                  iotcon_remote_resource_clone, iotcon_remote_resource_start_caching, iotcon_remote_resource_stop_caching ,iotcon_remote_resource_destroy
 * @passcase                            When iotcon_remote_resource_clone, iotcon_remote_resource_start_caching, iotcon_remote_resource_stop_caching are successful.
 * @failcase                            If target API iotcon_query_create or any precondition API fails.
 * @precondition                        NA
@@ -1039,21 +1286,21 @@ int ITc_iotcon_remote_resource_start_stop_caching_p(void)
 {
        START_TEST;
        int nIotconTimeoutId = 0;
-       
+
        int nRet = IotconCreateLiteResource();
     if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLiteResource failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1; 
+               return 1;
        }
        g_bCheckCb = false;
        g_nRetcb = false;
        g_nCheckAPICb = 0;
-       
+
        nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, ENCAP_LIGHT_RESOURCE_TYPE, false, IotconRemoteResourceCachingCB, NULL);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet), IotconDestroyLiteResource());
        RUN_POLLING_LOOP;
-       
+
        if((g_bCheckCb == false) || (g_nRetcb == false))
        {
                FPRINTF("[Line : %d][%s] IotconRemoteResourceCachingCB callback not invoked: \\n", __LINE__, API_NAMESPACE );
@@ -1061,21 +1308,21 @@ int ITc_iotcon_remote_resource_start_stop_caching_p(void)
                return 1;
        }
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, g_nCheckAPICb, "API call inside callback failed", IotConGetError(g_nCheckAPICb),IotconDestroyLiteResource());
-       
+
        IotconDestroyLiteResource();
        return 0;
 }
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_start_stop_monitoring_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Creates a new query handle.  
+* @description                 Creates a new query handle.
 * @scenario                            call iotcon_query_create
-* @apicovered                  iotcon_remote_resource_clone, iotcon_remote_resource_start_monitoring ,iotcon_remote_resource_stop_monitoring,iotcon_remote_resource_destroy                                    
+* @apicovered                  iotcon_remote_resource_clone, iotcon_remote_resource_start_monitoring ,iotcon_remote_resource_stop_monitoring,iotcon_remote_resource_destroy
 * @passcase                            When iotcon_remote_resource_clone, iotcon_remote_resource_start_monitoring ,iotcon_remote_resource_stop_monitoring are successful.
 * @failcase                            If target API iotcon_query_create or any precondition API fails.
 * @precondition                        NA
@@ -1084,22 +1331,22 @@ int ITc_iotcon_remote_resource_start_stop_caching_p(void)
 int ITc_iotcon_remote_resource_start_stop_monitoring_p(void)
 {
        START_TEST;
-       
+
        int nIotconTimeoutId = 0;
        int nRet = IotconCreateResource();
     if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] IotconCreateRemoteResource failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1; 
+               return 1;
        }
        g_bCheckCb = false;
        g_nRetcb = false;
        g_nCheckAPICb = 0;
-       
+
        nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, ENCAP_LIGHT_RESOURCE_TYPE, false, IotcoRemoteResourceMonitoringCB , NULL);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet), IotconDestroyResource());
        RUN_POLLING_LOOP;
-       
+
        if((g_bCheckCb == false) || (g_nRetcb == false))
        {
                FPRINTF("[Line : %d][%s] IotcoRemoteResourceMonitoringCB callback not invoked: \\n", __LINE__, API_NAMESPACE );
@@ -1107,21 +1354,21 @@ int ITc_iotcon_remote_resource_start_stop_monitoring_p(void)
                return 1;
        }
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, g_nCheckAPICb, "API call inside callback failed", IotConGetError(g_nCheckAPICb),IotconDestroyResource());
-       
+
        return 0;
 }
 
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_get_connectivity_type_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Creates a new query handle.  
+* @description                 Creates a new query handle.
 * @scenario                            call iotcon_remote_resource_get_connectivity_type
-* @apicovered                  iotcon_remote_resource_get_connectivity_type                                    
+* @apicovered                  iotcon_remote_resource_get_connectivity_type
 * @passcase                            When iotcon_remote_resource_get_connectivity_type is successful.
 * @failcase                            If target API iotcon_query_create or any precondition API fails.
 * @precondition                        NA
@@ -1131,33 +1378,33 @@ int ITc_iotcon_remote_resource_start_stop_monitoring_p(void)
 int ITc_iotcon_remote_resource_get_connectivity_type_p(void)
 {
        START_TEST;
-       
+
        iotcon_connectivity_type_e connectivity_type;
        int nRet = IotconCreateRemoteResource();
     if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] IotconCreateRemoteResource failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1; 
+               return 1;
        }
-       
+
        nRet = iotcon_remote_resource_get_connectivity_type(g_hClient, &connectivity_type);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_remote_resource_get_connectivity_type", IotConGetError(nRet), IotconDestroyRemoteResource());
-       
+
     IotconDestroyRemoteResource();
        return 0;
 }
 
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_get_uri_path_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Creates a new query handle.  
+* @description                 Creates a new query handle.
 * @scenario                            call iotcon_remote_resource_get_uri_path
-* @apicovered                  iotcon_remote_resource_get_uri_path                                     
+* @apicovered                  iotcon_remote_resource_get_uri_path
 * @passcase                            When iotcon_remote_resource_get_uri_path is successful.
 * @failcase                            If target API iotcon_query_create or any precondition API fails.
 * @precondition                        NA
@@ -1173,12 +1420,12 @@ int ITc_iotcon_remote_resource_get_uri_path_p(void)
     if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] IotconCreateRemoteResource failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1; 
+               return 1;
        }
        nRet = iotcon_remote_resource_get_uri_path(g_hClient, &uri);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_remote_resource_get_uri_path", IotConGetError(nRet), IotconDestroyRemoteResource());
        CHECK_HANDLE(uri,"iotcon_remote_resource_get_uri_path");
-       
+
        if (0 != strcmp(REMOTE_RESOURCE_LIGHT, uri))
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_get_uri_path failed uri path does not match \"%s\" \\n", __LINE__, API_NAMESPACE, REMOTE_RESOURCE_LED);
@@ -1189,17 +1436,17 @@ int ITc_iotcon_remote_resource_get_uri_path_p(void)
        return 0;
 }
 
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_get_host_address_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Creates a new query handle.  
+* @description                 Creates a new query handle.
 * @scenario                            call iotcon_remote_resource_get_host_address
-* @apicovered                  iotcon_remote_resource_get_host_address                                 
+* @apicovered                  iotcon_remote_resource_get_host_address
 * @passcase                            When iotcon_remote_resource_get_host_address is successful.
 * @failcase                            If target API iotcon_remote_resource_get_host_address or any precondition API fails.
 * @precondition                        NA
@@ -1210,17 +1457,17 @@ int ITc_iotcon_remote_resource_get_host_address_p(void)
        START_TEST;
 
        char *host = NULL;
-    
+
        int nRet = IotconCreateRemoteResource();
     if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] IotconCreateRemoteResource failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1; 
+               return 1;
        }
        nRet = iotcon_remote_resource_get_host_address(g_hClient, &host);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_remote_resource_get_host_address", IotConGetError(nRet), IotconDestroyRemoteResource());
        CHECK_HANDLE(host,"iotcon_remote_resource_get_host_address");
-       
+
        if (0 != strcmp(REMOTE_IP, host))
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_get_host_address failed host address does not match \"%s\" \\n", __LINE__, API_NAMESPACE, REMOTE_IP);
@@ -1231,17 +1478,17 @@ int ITc_iotcon_remote_resource_get_host_address_p(void)
        return 0;
 }
 
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_get_device_id_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Creates a new query handle.  
+* @description                 Creates a new query handle.
 * @scenario                            call iotcon_remote_resource_get_device_id
-* @apicovered                  iotcon_remote_resource_get_device_id                                    
+* @apicovered                  iotcon_remote_resource_get_device_id
 * @passcase                            When iotcon_remote_resource_get_device_id is successful.
 * @failcase                            If target API iotcon_remote_resource_get_device_id or any precondition API fails.
 * @precondition                        NA
@@ -1250,35 +1497,35 @@ int ITc_iotcon_remote_resource_get_host_address_p(void)
 int ITc_iotcon_remote_resource_get_device_id_p(void)
 {
        START_TEST;
-       
+
     int nIotconTimeoutId = 0;
        char *sid;
        g_bCheckCb = false;
-       
+
     int nRet = IotconCreateLiteResource();
     if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLiteResource failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1; 
-       }       
+               return 1;
+       }
        nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,ENCAP_LIGHT_RESOURCE_TYPE, false, IotconRemoteResourceOptionsCB, NULL);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet), IotconDestroyLiteResource());
        RUN_POLLING_LOOP;
-       
+
        if(g_bCheckCb == false)
        {
                FPRINTF("[Line : %d][%s] IotconRemoteResourceOptionsCB callback not invoked: \\n", __LINE__, API_NAMESPACE );
                IotconDestroyLiteResource();
                return 1;
        }
-       
+
        nRet = iotcon_remote_resource_get_device_id(g_hResourceHandle, &sid);
        if(IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_get_device_id failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                iotcon_remote_resource_destroy(g_hResourceHandle);
                IotconDestroyLiteResource();
-               return 1; 
+               return 1;
        }
        CHECK_HANDLE(sid,"iotcon_remote_resource_get_device_id");
        iotcon_remote_resource_destroy(g_hResourceHandle);
@@ -1287,17 +1534,17 @@ int ITc_iotcon_remote_resource_get_device_id_p(void)
 }
 
 
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_get_types_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Creates a new query handle.  
+* @description                 Creates a new query handle.
 * @scenario                            call iotcon_remote_resource_get_types
-* @apicovered                  iotcon_remote_resource_get_types                                        
+* @apicovered                  iotcon_remote_resource_get_types
 * @passcase                            When iotcon_remote_resource_get_types is successful.
 * @failcase                            If target API iotcon_remote_resource_get_types or any precondition API fails.
 * @precondition                        NA
@@ -1308,32 +1555,32 @@ int ITc_iotcon_remote_resource_get_types_p(void)
        START_TEST;
 
        iotcon_resource_types_h hTypes = NULL;
-    
+
        int nRet = IotconCreateRemoteResource();
     if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] IotconCreateRemoteResource failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1; 
+               return 1;
        }
        nRet = iotcon_remote_resource_get_types(g_hClient, &hTypes);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_remote_resource_get_host_address", IotConGetError(nRet), IotconDestroyRemoteResource());
        CHECK_HANDLE(hTypes, "iotcon_remote_resource_get_types");
-       
+
        IotconDestroyRemoteResource();
        return 0;
 }
 
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_get_interfaces_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Creates a new query handle.  
+* @description                 Creates a new query handle.
 * @scenario                            call iotcon_remote_resource_get_interfaces
-* @apicovered                  iotcon_remote_resource_get_interfaces                                   
+* @apicovered                  iotcon_remote_resource_get_interfaces
 * @passcase                            When iotcon_remote_resource_get_interfaces is successful.
 * @failcase                            If target API iotcon_remote_resource_get_interfaces or any precondition API fails.
 * @precondition                        NA
@@ -1344,32 +1591,32 @@ int ITc_iotcon_remote_resource_get_interfaces_p(void)
        START_TEST;
 
        iotcon_resource_interfaces_h ifaces;
-    
+
        int nRet = IotconCreateRemoteResource();
     if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] IotconCreateRemoteResource failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1; 
+               return 1;
        }
        nRet = iotcon_remote_resource_get_interfaces(g_hClient, &ifaces);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_remote_resource_get_interfaces", IotConGetError(nRet), IotconDestroyRemoteResource());
     CHECK_HANDLE(ifaces, "iotcon_remote_resource_get_interfaces");
-       
+
     IotconDestroyRemoteResource();
        return 0;
 }
 
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_get_properties_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Creates a new query handle.  
+* @description                 Creates a new query handle.
 * @scenario                            call iotcon_remote_resource_get_properties
-* @apicovered                  iotcon_remote_resource_get_properties                                   
+* @apicovered                  iotcon_remote_resource_get_properties
 * @passcase                            When iotcon_remote_resource_get_properties is successful.
 * @failcase                            If target API iotcon_remote_resource_get_properties or any precondition API fails.
 * @precondition                        NA
@@ -1380,12 +1627,12 @@ int ITc_iotcon_remote_resource_get_properties_p(void)
        START_TEST;
 
        int properties;
-    
+
        int nRet = IotconCreateRemoteResource();
     if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] IotconCreateRemoteResource failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1; 
+               return 1;
        }
        nRet = iotcon_remote_resource_get_properties(g_hClient, &properties);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_remote_resource_get_properties", IotConGetError(nRet), IotconDestroyRemoteResource());
@@ -1400,15 +1647,15 @@ int ITc_iotcon_remote_resource_get_properties_p(void)
        return 0;
 }
 
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_set_get_options_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Creates a new query handle.  
+* @description                 Creates a new query handle.
 * @scenario                            call iotcon_remote_resource_set_options , iotcon_remote_resource_get_options
 * @apicovered                  iotcon_remote_resource_set_options,iotcon_options_create,       iotcon_options_add,             iotcon_remote_resource_set_options      ,iotcon_remote_resource_get_options
 * @passcase                            When iotcon_remote_resource_set_options,iotcon_options_create,  iotcon_options_add,             iotcon_remote_resource_set_options      ,iotcon_remote_resource_get_options are successful.
@@ -1419,23 +1666,23 @@ int ITc_iotcon_remote_resource_get_properties_p(void)
 int ITc_iotcon_remote_resource_set_get_options_p(void)
 {
        START_TEST;
-       
+
        int nIotconTimeoutId = 0;
        iotcon_options_h hSetOptions = NULL;
        iotcon_options_h hGetOptions;
-    
+
        int nRet = IotconCreateLiteResource();
     if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLiteResource failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1; 
+               return 1;
        }
        g_bCheckCb = false;
-       
+
        nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,ENCAP_LIGHT_RESOURCE_TYPE, false, IotconRemoteResourceOptionsCB, NULL);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet), IotconDestroyLiteResource());
        RUN_POLLING_LOOP;
-       
+
        if(g_bCheckCb == false)
        {
                FPRINTF("[Line : %d][%s] IotconRemoteResourceOptionsCB callback not invoked: \\n", __LINE__, API_NAMESPACE );
@@ -1445,14 +1692,14 @@ int ITc_iotcon_remote_resource_set_get_options_p(void)
        /* options may be NULL */
        nRet = iotcon_remote_resource_set_options(g_hResourceHandle, NULL);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_remote_resource_set_options", IotConGetError(nRet), iotcon_remote_resource_destroy(g_hResourceHandle);IotconDestroyLiteResource());
-       
+
        nRet = iotcon_options_create(&hSetOptions);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_options_create", IotConGetError(nRet), iotcon_remote_resource_destroy(g_hResourceHandle);IotconDestroyLiteResource());
        CHECK_HANDLE(hSetOptions,"iotcon_options_create");
-       
-       nRet = iotcon_options_add(hSetOptions, 2500, "options_value"); 
+
+       nRet = iotcon_options_add(hSetOptions, 2500, "options_value");
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_options_add", IotConGetError(nRet), iotcon_options_destroy(hSetOptions);iotcon_remote_resource_destroy(g_hResourceHandle);IotconDestroyLiteResource());
-       
+
        nRet = iotcon_remote_resource_set_options(g_hResourceHandle, hSetOptions);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_remote_resource_set_options", IotConGetError(nRet), iotcon_options_destroy(hSetOptions);iotcon_remote_resource_destroy(g_hResourceHandle);IotconDestroyLiteResource());
 
@@ -1468,17 +1715,17 @@ int ITc_iotcon_remote_resource_set_get_options_p(void)
        return 0;
 }
 
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_get_cached_representation_p
 * @since_tizen                 3.0
 * @author              SRID(asit.s)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Creates a new query handle.  
+* @description                 Creates a new query handle.
 * @scenario                            call iotcon_query_create
-* @apicovered                  iotcon_remote_resource_clone,iotcon_remote_resource_start_caching,      iotcon_state_create,iotcon_state_add_int,iotcon_lite_resource_update_state,iotcon_remote_resource_get_cached_representation                             
+* @apicovered                  iotcon_remote_resource_clone,iotcon_remote_resource_start_caching,      iotcon_state_create,iotcon_state_add_int,iotcon_lite_resource_update_state,iotcon_remote_resource_get_cached_representation
 * @passcase                            When iotcon_remote_resource_clone,iotcon_remote_resource_start_caching, iotcon_state_create,iotcon_state_add_int,iotcon_lite_resource_update_state,iotcon_remote_resource_get_cached_representation     are successful.
 * @failcase                            If target API or any precondition API fails.
 * @precondition                        NA
@@ -1488,34 +1735,34 @@ int ITc_iotcon_remote_resource_get_cached_representation_p(void)
 {
        START_TEST;
        int nIotconTimeoutId = 0;
-       int nRet = IotconCreateLiteResource(); 
+       int nRet = IotconCreateLiteResource();
     if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLiteResource failed : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-               return 1; 
+               return 1;
        }
        g_bCheckCb = false;
        g_nRetcb = false;
        g_nCheckAPICb = 0;
-       
+
        nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, ENCAP_LIGHT_RESOURCE_TYPE, false, IotconRemoteResourceRepresentationCB, NULL);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_find_resource", IotConGetError(nRet), IotconDestroyLiteResource());
        RUN_POLLING_LOOP;
-       
+
        if((g_bCheckCb == false) || (g_nRetcb == false))
        {
                FPRINTF("[Line : %d][%s] IotconRemoteResourceRepresentationCB callback not invoked: \\n", __LINE__, API_NAMESPACE );
                IotconDestroyLiteResource();
                return 1;
        }
-       
+
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, g_nCheckAPICb, "API call inside callback failed", IotConGetError(g_nCheckAPICb),IotconDestroyLiteResource());
        IotconDestroyLiteResource();
        return 0;
 }
 
-//& purpose: Creates a new query handle. 
-//& type: auto 
+//& purpose: Creates a new query handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_remote_resource_set_get_time_interval_p
 * @since_tizen                 3.0
@@ -1523,8 +1770,8 @@ int ITc_iotcon_remote_resource_get_cached_representation_p(void)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
 * @description                 Sets and Gets the time interval of monitoring & caching API of remote resource.
-* @scenario                            call iotcon_remote_resource_get_time_interval, iotcon_remote_resource_set_time_interval 
-* @apicovered                  iotcon_remote_resource_get_time_interval,iotcon_remote_resource_set_time_interval               
+* @scenario                            call iotcon_remote_resource_get_time_interval, iotcon_remote_resource_set_time_interval
+* @apicovered                  iotcon_remote_resource_get_time_interval,iotcon_remote_resource_set_time_interval
 * @passcase                            When iotcon_remote_resource_get_time_interval,iotcon_remote_resource_set_time_interval are successful.
 * @failcase                            If target API or any precondition API fails.
 * @precondition                        NA
@@ -1533,16 +1780,16 @@ int ITc_iotcon_remote_resource_get_cached_representation_p(void)
 int ITc_iotcon_remote_resource_set_get_time_interval_p(void)
 {
        START_TEST;
-       
+
        int SetTimeInterval = 250;
        int GetTimeInterval = 0;
-       
+
        int nRet = iotcon_remote_resource_set_time_interval(SetTimeInterval);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_remote_resource_set_time_interval", IotConGetError(nRet));
-       
-       nRet = iotcon_remote_resource_get_time_interval(&GetTimeInterval); 
+
+       nRet = iotcon_remote_resource_get_time_interval(&GetTimeInterval);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_remote_resource_get_time_interval", IotConGetError(nRet));
-       
+
        if (SetTimeInterval != GetTimeInterval)
        {
                FPRINTF("[Line : %d][%s] iotcon_remote_resource_set_time_interval and iotcon_remote_resource_get_time_interval does not match\\n", __LINE__, API_NAMESPACE);
index 1d08e3a..3eee218 100755 (executable)
@@ -27,6 +27,8 @@ static bool g_bRequestHandlerCB = false;
 static bool g_bResult;
 static iotcon_resource_h g_hLightResource;
 static iotcon_remote_resource_h g_hRemoteResource;
+static int g_timeout_count;
+static bool g_found;
 
 enum {
        REQUEST_GET_QUERY,
@@ -56,7 +58,7 @@ enum {
  */
 static gboolean gmain_loop_quit_idle(gpointer p)
 {
-       
+
        g_main_loop_quit(g_pMainLoop);
        return G_SOURCE_REMOVE;
 }
@@ -68,7 +70,7 @@ static gboolean gmain_loop_quit_idle(gpointer p)
 * @return                      NA
 */
 static void QuitGmainLoopIdle(bool result)
-{      
+{
        g_bResult = result;
        g_idle_add(gmain_loop_quit_idle, NULL);
 }
@@ -83,7 +85,7 @@ static void QuitGmainLoopIdle(bool result)
 static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h request,
                void *user_data)
 {
-    FPRINTF("Inside RequestHandlerCB callback... \n"); 
+    FPRINTF("Inside RequestHandlerCB callback... \n");
        int nRet;
        int tc_index = GPOINTER_TO_INT(user_data);
        iotcon_query_h hQuery = NULL;
@@ -97,13 +99,13 @@ static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h reques
        iotcon_observe_type_e eObserveType = -1;
        int nObserveId = -1;
        g_bRequestHandlerCB = true;
-       
+
        if(request == NULL)
        {
                FPRINTF("Handle iotcon_request_h is null in RequestHandlerCB callback... \n");
-               return 1;
+               return;
        }
-       switch (tc_index) 
+       switch (tc_index)
        {
                case REQUEST_GET_QUERY:
                        nRet = iotcon_request_get_query(request, &hQuery);
@@ -114,13 +116,13 @@ static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h reques
                        if(hQuery == NULL)
                        {
                                FPRINTF("[Line : %d][%s] hQuery handle NULL : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
-                               QuitGmainLoopIdle(false);\r
+                               QuitGmainLoopIdle(false);
                        }
                        QuitGmainLoopIdle(true);
                        return;
                case REQUEST_GET_HOST_ADDRESS:
                        nRet = iotcon_request_get_host_address(request, &pcHostAddress);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_request_get_host_address fail error returned : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                QuitGmainLoopIdle(false);
@@ -134,7 +136,7 @@ static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h reques
                        return;
                case REQUEST_GET_CONNECTIVITY_TYPE:
                        nRet = iotcon_request_get_connectivity_type(request, &eType);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_request_get_connectivity_type fail error returned : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                QuitGmainLoopIdle(false);
@@ -145,10 +147,10 @@ static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h reques
                                QuitGmainLoopIdle(false);
                        }
                        QuitGmainLoopIdle(true);
-                       return;                 
+                       return;
                case REQUEST_GET_REPRESENTATION:
                        nRet = iotcon_request_get_representation(request, &hRep);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_request_get_representation fail error returned : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                QuitGmainLoopIdle(false);
@@ -162,7 +164,7 @@ static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h reques
                        return;
                case REQUEST_GET_REQUEST_TYPE:
                        nRet = iotcon_request_get_request_type(request, &eRequestType);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_request_get_request_type fail error returned : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                QuitGmainLoopIdle(false);
@@ -173,10 +175,10 @@ static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h reques
                                QuitGmainLoopIdle(false);
                        }
                        QuitGmainLoopIdle(true);
-                       return; 
+                       return;
                case REQUEST_GET_OPTIONS:
                        nRet = iotcon_response_create(request, &hResponse);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_response_create fail error returned : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                QuitGmainLoopIdle(false);
@@ -187,7 +189,7 @@ static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h reques
                                QuitGmainLoopIdle(false);
                        }
                        nRet = iotcon_options_create(&hOptions);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_options_create fail error returned : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                iotcon_response_destroy(hResponse);
@@ -198,9 +200,9 @@ static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h reques
                                FPRINTF("[Line : %d][%s] hOptions handle NULL : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                iotcon_response_destroy(hResponse);
                                QuitGmainLoopIdle(false);
-                       }       
+                       }
                        nRet = iotcon_request_get_options(request, &hGetOptions);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_request_get_options fail error returned : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                iotcon_options_destroy(hOptions);
@@ -212,14 +214,14 @@ static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h reques
                                FPRINTF("[Line : %d][%s] hGetOptions handle NULL : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                iotcon_response_destroy(hResponse);
                                QuitGmainLoopIdle(false);
-                       }       
+                       }
                        iotcon_options_destroy(hOptions);
-                       iotcon_response_destroy(hResponse);     
+                       iotcon_response_destroy(hResponse);
                        QuitGmainLoopIdle(true);
-                       return; 
+                       return;
                case REQUEST_GET_OBSERVE_TYPE:
                        nRet = iotcon_request_get_observe_type(request, &eObserveType);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_request_get_observe_type fail error returned : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                QuitGmainLoopIdle(false);
@@ -230,10 +232,10 @@ static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h reques
                                QuitGmainLoopIdle(false);
                        }
             QuitGmainLoopIdle(true);
-                       return; 
+                       return;
                case REQUEST_GET_OBSERVE_ID:
                        nRet = iotcon_request_get_observe_id(request, &nObserveId);
-                       if (IOTCON_ERROR_NONE != nRet) 
+                       if (IOTCON_ERROR_NONE != nRet)
                        {
                                FPRINTF("[Line : %d][%s] iotcon_request_get_observe_id fail error returned : %s\\n", __LINE__, API_NAMESPACE,IotConGetError(nRet));
                                QuitGmainLoopIdle(false);
@@ -254,24 +256,24 @@ static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h reques
 
 /**
 * @function            CreateResource
-* @description         Called to create and add resource and interface. 
+* @description         Called to create and add resource and interface.
 * @parameter           NA
-* @return                      intiger : 0 if sussess 
+* @return                      intiger : 0 if sussess
 */
 static int CreateResource(int tc_index)
 {
-    FPRINTF("Inside CreateResource... \n");    
+    FPRINTF("Inside CreateResource... \n");
        int nRet;
        //int nIotconTimeoutId = 0;
        iotcon_resource_types_h hLightTypes;
        iotcon_resource_interfaces_h hLightiFaces;
-       
+
        nRet = iotcon_resource_types_create(&hLightTypes);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_create", IotConGetError(nRet));
-       
+
        nRet = iotcon_resource_types_add(hLightTypes, LIGHT_RESOURCE_TYPE);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_add", IotConGetError(nRet),iotcon_resource_types_destroy(hLightTypes));
-       
+
        nRet = iotcon_resource_interfaces_create(&hLightiFaces);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet),iotcon_resource_types_destroy(hLightTypes));
 
@@ -289,7 +291,7 @@ static int CreateResource(int tc_index)
                        &g_hLightResource);
        //RUN_POLLING_LOOP;
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_create", IotConGetError(nRet),iotcon_resource_interfaces_destroy(hLightiFaces);iotcon_resource_types_destroy(hLightTypes));
-               
+
        iotcon_resource_interfaces_destroy(hLightiFaces);
        iotcon_resource_types_destroy(hLightTypes);
 
@@ -306,47 +308,76 @@ static int CreateResource(int tc_index)
 static void GetRemoteResourceCB(iotcon_remote_resource_h resource,     iotcon_error_e err,
                iotcon_request_type_e request_type, iotcon_response_h response, void *user_data)
 {
-    FPRINTF("Inside GetRemoteResourceCB callback... \n");              
+    FPRINTF("Inside GetRemoteResourceCB callback... \n");
        g_bRequestHandlerCB = true;
        QuitGmainLoopIdle(true);
-       
+
        return;
 }
 
 /**
 * @function            FoundResourceCB
-* @description         get remote resource clone 
-* @parameter           iotcon_remote_resource_h : The remote resource handle, iotcon_error_e : iotcon error    
+* @description         get remote resource clone
+* @parameter           iotcon_remote_resource_h : The remote resource handle, iotcon_error_e : iotcon error
 *                                      user_data : The user data passed from function
 * @return                      NA
 */
 static void FoundResourceCB(iotcon_remote_resource_h resource,
                iotcon_error_e err, void *user_data)
 {
-       FPRINTF("Inside FoundResourceCB callback... \n");       
+       FPRINTF("Inside FoundResourceCB callback... \n");
        //int nIotconTimeoutId = 0;
        int nRet;
        g_bRequestHandlerCB = true;
     iotcon_query_h hquery;
        iotcon_options_h hoptions;
-       
+
+       if (IOTCON_ERROR_TIMEOUT == err && g_timeout_count < TIMEOUT_COUNT_MAX)
+       {
+               g_timeout_count++;
+               nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
+                               LIGHT_RESOURCE_TYPE, false, FoundResourceCB, NULL);
+               if (IOTCON_ERROR_NONE != nRet)
+               {
+                       FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
+                       QuitGmainLoopIdle(false);
+                       return;
+               }
+               return;
+       }
+       else if (IOTCON_ERROR_NONE != err)
+       {
+               QuitGmainLoopIdle(false);
+               return;
+       }
+
+       if (g_found)
+               return;
+
+       g_found = true;
+
+       char *host_address, *uri;
+       iotcon_remote_resource_get_host_address(resource, &host_address);
+       iotcon_remote_resource_get_uri_path(resource, &uri);
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
+
        nRet = iotcon_remote_resource_clone(resource, &g_hRemoteResource);
        if (IOTCON_ERROR_NONE != nRet) {
                FPRINTF("iotcon_remote_resource_clone() Fail(%d)", nRet);
-               QuitGmainLoopIdle(false);               
+               QuitGmainLoopIdle(false);
                return;
        }
        nRet = iotcon_query_create(&hquery);
        if (IOTCON_ERROR_NONE != nRet) {
                FPRINTF("iotcon_query_create() Fail(%d)", nRet);
-               QuitGmainLoopIdle(false);               
+               QuitGmainLoopIdle(false);
                return;
        }
        nRet = iotcon_query_add(hquery, "key", "value");
        if (IOTCON_ERROR_NONE != nRet) {
                FPRINTF("iotcon_query_add() Fail(%d)", nRet);
                iotcon_query_destroy(hquery);
-               QuitGmainLoopIdle(false);               
+               QuitGmainLoopIdle(false);
                return;
        }
     /* Add options */
@@ -354,7 +385,7 @@ static void FoundResourceCB(iotcon_remote_resource_h resource,
        if (IOTCON_ERROR_NONE != nRet) {
                FPRINTF("iotcon_options_create() Fail(%d)", nRet);
                iotcon_query_destroy(hquery);
-               QuitGmainLoopIdle(false);               
+               QuitGmainLoopIdle(false);
                return;
        }
 
@@ -363,7 +394,7 @@ static void FoundResourceCB(iotcon_remote_resource_h resource,
                FPRINTF("iotcon_options_add() Fail(%d)", nRet);
                iotcon_query_destroy(hquery);
                iotcon_options_destroy(hoptions);
-               QuitGmainLoopIdle(false);               
+               QuitGmainLoopIdle(false);
                return;
        }
        nRet = iotcon_remote_resource_set_options(g_hRemoteResource, hoptions);
@@ -371,15 +402,15 @@ static void FoundResourceCB(iotcon_remote_resource_h resource,
                FPRINTF("iotcon_remote_resource_set_options() Fail(%d)", nRet);
                iotcon_query_destroy(hquery);
                iotcon_options_destroy(hoptions);
-               QuitGmainLoopIdle(false);               
+               QuitGmainLoopIdle(false);
                return;
-       }       
+       }
        iotcon_options_destroy(hoptions);
        nRet = iotcon_remote_resource_get(g_hRemoteResource, hquery, GetRemoteResourceCB, NULL);
        if (IOTCON_ERROR_NONE != nRet) {
                FPRINTF("iotcon_remote_resource_clone() Fail(%d)", nRet);
                iotcon_query_destroy(hquery);
-               QuitGmainLoopIdle(false);               
+               QuitGmainLoopIdle(false);
                return;
        }
        //RUN_POLLING_LOOP;
@@ -390,7 +421,7 @@ static void FoundResourceCB(iotcon_remote_resource_h resource,
 * @function            CreateAndFindResource
 * @description         Function to create and find resource
 * @parameter           NA
-* @return                      intiger : 0 if sussess 
+* @return                      intiger : 0 if sussess
 */
 static int CreateAndFindResource(int tc_index)
 {
@@ -439,10 +470,10 @@ void ITs_iotcon_request_startup(void)
        g_bIotconConnect = true;
        g_bFeatureUnsupported = false;
     int nRet = iotcon_initialize();
-       
+
        if ( !TCTCheckSystemInfoFeatureSupported(IOTCON_FEATURE, API_NAMESPACE) )
        {
-               
+
                if ( nRet != TIZEN_ERROR_NOT_SUPPORTED )
                {
                        FPRINTF("[Line : %d][%s] iotcon_initialize API call returned mismatch %s error for unsupported feature\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
@@ -455,14 +486,14 @@ void ITs_iotcon_request_startup(void)
                }
                return;
        }
-       
+
        if ( nRet != IOTCON_ERROR_NONE )
        {
                FPRINTF("[Line : %d][%s] iotcon_initialize failed API return %s error \\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
                g_bIotconConnect = false;
                return;
        }
-       
+
        return;
 }
 
@@ -517,10 +548,10 @@ void ITs_iotcon_request_cleanup(void)
 int ITc_iotcon_request_get_query_p(void)
 {
        START_TEST;
-       
+
        int nRet = CreateAndFindResource(REQUEST_GET_QUERY);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "CreateAndFindResource", IotConGetError(nRet));
-       
+
        return 0;
 }
 //& type: auto
@@ -541,10 +572,10 @@ int ITc_iotcon_request_get_query_p(void)
 */
 int ITc_iotcon_request_get_host_address_p(void)
 {
-       START_TEST;     
+       START_TEST;
        int nRet = CreateAndFindResource(REQUEST_GET_HOST_ADDRESS);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "CreateAndFindResource", IotConGetError(nRet));
-       
+
        return 0;
 }
 
@@ -566,7 +597,7 @@ int ITc_iotcon_request_get_host_address_p(void)
 */
 int ITc_iotcon_request_get_connectivity_type_p(void)
 {
-       START_TEST;     
+       START_TEST;
        int nRet = CreateAndFindResource(REQUEST_GET_CONNECTIVITY_TYPE);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "CreateAndFindResource", IotConGetError(nRet));
 
@@ -591,7 +622,7 @@ int ITc_iotcon_request_get_connectivity_type_p(void)
 */
 int ITc_iotcon_request_get_representation_p(void)
 {
-       START_TEST;     
+       START_TEST;
        int nRet = CreateAndFindResource(REQUEST_GET_REPRESENTATION);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "CreateAndFindResource", IotConGetError(nRet));
 
@@ -616,7 +647,7 @@ int ITc_iotcon_request_get_representation_p(void)
 */
 int ITc_iotcon_request_get_request_type_p(void)
 {
-       START_TEST;     
+       START_TEST;
        int nRet = CreateAndFindResource(REQUEST_GET_REQUEST_TYPE);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "CreateAndFindResource", IotConGetError(nRet));
 
@@ -641,7 +672,7 @@ int ITc_iotcon_request_get_request_type_p(void)
 */
 int ITc_iotcon_request_get_options_p(void)
 {
-       START_TEST;     
+       START_TEST;
        int nRet = CreateAndFindResource(REQUEST_GET_OPTIONS);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "CreateAndFindResource", IotConGetError(nRet));
 
@@ -666,7 +697,7 @@ int ITc_iotcon_request_get_options_p(void)
 */
 int ITc_iotcon_request_get_observe_type_p(void)
 {
-       START_TEST;     
+       START_TEST;
        int nRet = CreateAndFindResource(REQUEST_GET_OBSERVE_TYPE);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "CreateAndFindResource", IotConGetError(nRet));
 
@@ -690,7 +721,7 @@ int ITc_iotcon_request_get_observe_type_p(void)
 */
 int ITc_iotcon_request_get_observe_id_p(void)
 {
-       START_TEST;     
+       START_TEST;
        int nRet = CreateAndFindResource(REQUEST_GET_OBSERVE_ID);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "CreateAndFindResource", IotConGetError(nRet));
 
@@ -698,4 +729,4 @@ int ITc_iotcon_request_get_observe_id_p(void)
 }
 
 /** @} */
-/** @} */
\ No newline at end of file
+/** @} */
index 44eaa42..3c41bba 100755 (executable)
@@ -475,7 +475,7 @@ static int CreateRepresentation(iotcon_representation_h *representation)
  */
 static gboolean gmain_loop_quit_idle(gpointer p)
 {
-       
+
        g_main_loop_quit(g_pMainLoop);
        return G_SOURCE_REMOVE;
 }
@@ -487,7 +487,7 @@ static gboolean gmain_loop_quit_idle(gpointer p)
 * @return                      NA
 */
 static void QuitGmainLoopIdle(bool result)
-{      
+{
        g_bResult = result;
        g_idle_add(gmain_loop_quit_idle, NULL);
 }
@@ -502,7 +502,7 @@ static void QuitGmainLoopIdle(bool result)
 static void FindRequestHandlerCB(iotcon_resource_h resource,
                iotcon_request_h request, void *user_data)
 {
-       FPRINTF("Inside FindRequestHandlerCB callback... \n");  
+       FPRINTF("Inside FindRequestHandlerCB callback... \n");
 
        int nRet;
        iotcon_representation_h repr;
@@ -563,74 +563,74 @@ static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h reques
                void *user_data)
 {
     FPRINTF("Inside RequestHandlerCB callback... \n");
-       
+
        int nRet;
        iotcon_representation_h hRep = NULL;
        iotcon_response_h hResponse;
        g_bRequestHandlerCB = true;
-        
+
      nRet = CreateRepresentation(&hRep);
-     if (IOTCON_ERROR_NONE != nRet) { 
-            FPRINTF("CreateRepresentation() Fail(%d)", nRet); 
-            QuitGmainLoopIdle(false); 
-           return; 
-     } 
-  
-     nRet = iotcon_response_create(request, &hResponse); 
-     if (IOTCON_ERROR_NONE != nRet) { 
-            FPRINTF("iotcon_response_create() Fail(%d)", nRet); 
-            QuitGmainLoopIdle(false); 
-            return; 
-     } 
-  
-     nRet = iotcon_response_set_representation(hResponse, IOTCON_INTERFACE_DEFAULT, hRep); 
-     if (IOTCON_ERROR_NONE != nRet) { 
-            FPRINTF("iotcon_response_set_representation() Fail(%d)", nRet); 
-            iotcon_response_destroy(hResponse); 
-            QuitGmainLoopIdle(false);  
-            return; 
-     } 
-  
-     nRet = iotcon_response_set_result(hResponse, IOTCON_RESPONSE_OK); 
-     if (IOTCON_ERROR_NONE != nRet) { 
-            FPRINTF("iotcon_response_set_result() Fail(%d)", nRet); 
-            iotcon_response_destroy(hResponse); 
-            QuitGmainLoopIdle(false);  
-            return; 
+     if (IOTCON_ERROR_NONE != nRet) {
+            FPRINTF("CreateRepresentation() Fail(%d)", nRet);
+            QuitGmainLoopIdle(false);
+           return;
+     }
+
+     nRet = iotcon_response_create(request, &hResponse);
+     if (IOTCON_ERROR_NONE != nRet) {
+            FPRINTF("iotcon_response_create() Fail(%d)", nRet);
+            QuitGmainLoopIdle(false);
+            return;
+     }
+
+     nRet = iotcon_response_set_representation(hResponse, IOTCON_INTERFACE_DEFAULT, hRep);
+     if (IOTCON_ERROR_NONE != nRet) {
+            FPRINTF("iotcon_response_set_representation() Fail(%d)", nRet);
+            iotcon_response_destroy(hResponse);
+            QuitGmainLoopIdle(false);
+            return;
+     }
+
+     nRet = iotcon_response_set_result(hResponse, IOTCON_RESPONSE_OK);
+     if (IOTCON_ERROR_NONE != nRet) {
+            FPRINTF("iotcon_response_set_result() Fail(%d)", nRet);
+            iotcon_response_destroy(hResponse);
+            QuitGmainLoopIdle(false);
+            return;
+     }
+
+    iotcon_representation_destroy(hRep);
+
+     nRet = iotcon_response_send(hResponse);
+     if (IOTCON_ERROR_NONE != nRet) {
+            FPRINTF("iotcon_response_send() Fail(%d)", nRet);
+            iotcon_response_destroy(hResponse);
+            QuitGmainLoopIdle(false);
+            return;
      }
 
-    iotcon_representation_destroy(hRep); 
-
-     nRet = iotcon_response_send(hResponse); 
-     if (IOTCON_ERROR_NONE != nRet) { 
-            FPRINTF("iotcon_response_send() Fail(%d)", nRet); 
-            iotcon_response_destroy(hResponse); 
-            QuitGmainLoopIdle(false);  
-            return; 
-     } 
-  
-     iotcon_response_destroy(hResponse); 
+     iotcon_response_destroy(hResponse);
 }
 
 /**
 * @function            CreateResource
-* @description         Called to create and add resource and interface. 
+* @description         Called to create and add resource and interface.
 * @parameter           NA
-* @return                      intiger : 0 if sussess 
+* @return                      intiger : 0 if sussess
 */
 static int CreateResource(int tc_index)
 {
-    FPRINTF("Inside CreateResource... \n");    
+    FPRINTF("Inside CreateResource... \n");
        int nRet;
        iotcon_resource_types_h hLightTypes;
        iotcon_resource_interfaces_h hLightiFaces;
-       
+
        nRet = iotcon_resource_types_create(&hLightTypes);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_create", IotConGetError(nRet));
-       
+
        nRet = iotcon_resource_types_add(hLightTypes, LIGHT_RESOURCE_TYPE);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_add", IotConGetError(nRet),iotcon_resource_types_destroy(hLightTypes));
-       
+
        nRet = iotcon_resource_interfaces_create(&hLightiFaces);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet),iotcon_resource_types_destroy(hLightTypes));
 
@@ -648,7 +648,7 @@ static int CreateResource(int tc_index)
                        &g_hLightResource);
 
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_create", IotConGetError(nRet),iotcon_resource_interfaces_destroy(hLightiFaces);iotcon_resource_types_destroy(hLightTypes));
-               
+
        iotcon_resource_interfaces_destroy(hLightiFaces);
        iotcon_resource_types_destroy(hLightTypes);
 
@@ -712,8 +712,8 @@ static void ResourceObserveCB(iotcon_remote_resource_h resource,
 
 /**
 * @function            FoundResourceCB
-* @description         get remote resource clone 
-* @parameter           iotcon_remote_resource_h : The remote resource handle, iotcon_error_e : iotcon error    
+* @description         get remote resource clone
+* @parameter           iotcon_remote_resource_h : The remote resource handle, iotcon_error_e : iotcon error
 *                                      user_data : The user data passed from function
 * @return                      NA
 */
@@ -725,7 +725,7 @@ static void FoundResourceCB(iotcon_remote_resource_h resource,
        int nRet;
        int tc_index = (int)user_data;
        int nIotconTimeoutId = 0;
-       
+
        if (IOTCON_ERROR_TIMEOUT == err && nIotconTimeoutId < TIMEOUT_COUNT_MAX) {
                nIotconTimeoutId++;
                nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
@@ -741,6 +741,11 @@ static void FoundResourceCB(iotcon_remote_resource_h resource,
                return;
        }
 
+       char *host_address, *uri;
+       iotcon_remote_resource_get_host_address(resource, &host_address);
+       iotcon_remote_resource_get_uri_path(resource, &uri);
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
+
        switch (tc_index) {
        case RESOURCE_SET_REQUEST_HANDLER:
                nRet = iotcon_resource_set_request_handler(g_hLightResource,
@@ -794,7 +799,7 @@ static void FoundResourceCB(iotcon_remote_resource_h resource,
 * @function            CreateAndFindResource
 * @description         Function to create and find resource
 * @parameter           NA
-* @return                      intiger : 0 if sussess 
+* @return                      intiger : 0 if sussess
 */
 static int CreateAndFindResource(int tc_index)
 {
@@ -837,13 +842,13 @@ static iotcon_resource_h g_hLightResource = NULL;
 static iotcon_resource_h g_hLedResource = NULL;
 iotcon_resource_h g_hResource = NULL;
 iotcon_request_h g_hReq = NULL;
+
 /**
 * @function            IotconResourceTypesForeachCB
 * @description         Callback Function
 * @parameter           const char *type, void *user_data
 * @return                      NA
-*/ 
+*/
 bool IotconResourceTypesForeachCB(const char *type, void *user_data)
 {
        g_bCheckCb = true;
@@ -857,25 +862,25 @@ bool IotconResourceTypesForeachCB(const char *type, void *user_data)
 * @description         Callback Function
 * @parameter           iotcon_resource_h resource, iotcon_request_h request, void *user_data
 * @return                      NA
-*/ 
+*/
 void IotconRequestHandlerCB(iotcon_resource_h resource, iotcon_request_h request, void *user_data)
  {
        g_bCheckCb = true;
        FPRINTF("[Line : %d][%s] Inside IotconRequestHandlerCB callback... \\n", __LINE__, API_NAMESPACE);
-                       
+
        if( resource == NULL)
        {
                FPRINTF("[Line : %d][%s] IotconRequestHandlerCB callback, resource is NULL\\n", __LINE__, API_NAMESPACE);
-       }else{          
+       }else{
                g_hResource = resource;
        }
        if( request == NULL )
        {
                FPRINTF("[Line : %d][%s] IotconRequestHandlerCB callback, request is NULL\\n", __LINE__, API_NAMESPACE);
        }else{
-               g_hReq = request;                       
+               g_hReq = request;
        }
-               
+
     if ( g_pMainLoop )
        {
                g_main_loop_quit(g_pMainLoop);
@@ -883,23 +888,23 @@ void IotconRequestHandlerCB(iotcon_resource_h resource, iotcon_request_h request
                g_pMainLoop = NULL;
                return;
        }
-       
+
        return;
  }
+
 /**
 * @function            IotconSetRequestHandlerCB
 * @description         Callback Function
 * @parameter           iotcon_resource_h resource,iotcon_request_h request, void *user_data
 * @return                      NA
-*/ 
+*/
 void IotconSetRequestHandlerCB(iotcon_resource_h resource,iotcon_request_h request, void *user_data)
 {
        g_bCheckCb = true;
-       
+
        if (user_data)
                ++ (*((int *)user_data));
-       
+
        if(resource == NULL || request == NULL )
        {
                FPRINTF("[Line : %d][%s] IotconSetRequestHandlerCB callback, resource or request is NULL\\n", __LINE__, API_NAMESPACE);
@@ -912,23 +917,23 @@ void IotconSetRequestHandlerCB(iotcon_resource_h resource,iotcon_request_h reque
                return;
        }
        return;
-        
+
 }
 /**
 * @function            IotconDestroyRes
 * @description         destroy resource
 * @parameter           NA
 * @return                      NA
-*/ 
+*/
 void IotconDestroyRes(void)
 {
-       if (g_hLightResource) 
+       if (g_hLightResource)
        {
                iotcon_resource_destroy(g_hLightResource);
                g_hLightResource = NULL;
                return;
        }
-       if (g_hLedResource) 
+       if (g_hLedResource)
        {
                iotcon_resource_destroy(g_hLedResource);
                g_hLedResource = NULL;
@@ -944,7 +949,7 @@ void IotconDestroyRes(void)
  * @return                     NA
  */
 int IotconCreateResourceLight(void)
-{      
+{
        iotcon_resource_types_h light_types = NULL;
        iotcon_resource_interfaces_h light_ifaces;
        int nIotconTimeoutId = 0;
@@ -974,7 +979,7 @@ int IotconCreateResourceLight(void)
        nRet = iotcon_resource_create(REMOTE_RESOURCE_LIGHT,light_types,light_ifaces,
                                  (IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE),IotconSetRequestHandlerCB,NULL,&g_hLightResource);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_create", IotConGetError(nRet),iotcon_resource_types_destroy(light_types);iotcon_resource_interfaces_destroy(light_ifaces));
-       
+
        RUN_POLLING_LOOP;
 
        if(g_hLightResource==NULL)
@@ -999,7 +1004,7 @@ int IotconCreateResourceLight(void)
  * @return                     NA
  */
 int IotconCreateResourceLED(void)
-{      
+{
        iotcon_resource_types_h light_types = NULL;
        iotcon_resource_interfaces_h light_ifaces;
        int nIotconTimeoutId = 0;
@@ -1053,12 +1058,12 @@ int IotconCreateResourceLED(void)
 * @description         create light resource
 * @parameter           NA
 * @return                      NA
-*/ 
+*/
 int IotconCreateLightResource(void)
 {
        g_bCheckCb = false;
     int nIotconTimeoutId = 0;
-       
+
        iotcon_resource_types_h hLightTypes = NULL;
 
        IotconDestroyRes();
@@ -1072,13 +1077,13 @@ int IotconCreateLightResource(void)
     g_nCheckAPICb = 0;
 
        iotcon_resource_interfaces_h ifaces;
-       
+
        nRet = iotcon_resource_interfaces_create(&ifaces);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet),iotcon_resource_types_destroy(hLightTypes));
-       
+
        nRet = iotcon_resource_interfaces_add(ifaces, IOTCON_INTERFACE_BATCH);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_add", IotConGetError(nRet),iotcon_resource_types_destroy(hLightTypes);iotcon_resource_interfaces_destroy(ifaces));
-       
+
        nRet = iotcon_resource_create(REMOTE_RESOURCE_LIGHT,hLightTypes,ifaces,
                  (IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE),IotconRequestHandlerCB,NULL,&g_hLightResource);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_create", IotConGetError(nRet),iotcon_resource_types_remove(hLightTypes, LIGHT_RESOURCE);iotcon_resource_types_destroy(hLightTypes);iotcon_resource_interfaces_destroy(ifaces));
@@ -1097,39 +1102,39 @@ int IotconCreateLightResource(void)
 * @description         create led resource
 * @parameter           NA
 * @return                      NA
-*/ 
+*/
 bool IotconCreateLedResource(void)
 {
        int nIotconTimeoutId = 0;
-       g_bCheckCb = false;     
+       g_bCheckCb = false;
        iotcon_resource_types_h hLedTypes = NULL;
        IotconDestroyRes();
-       
+
        int nRet = iotcon_resource_types_create(&hLedTypes);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_create", IotConGetError(nRet));
        CHECK_HANDLE(hLedTypes,"iotcon_resource_types_create");
-       
+
        nRet = iotcon_resource_types_add(hLedTypes, REMOTE_RESOURCE);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_add", IotConGetError(nRet),iotcon_resource_types_destroy(hLedTypes));
        g_nCheckAPICb = 0;
-       
+
        iotcon_resource_interfaces_h ifaces;
 
        nRet = iotcon_resource_interfaces_create(&ifaces);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet),iotcon_resource_types_destroy(hLedTypes));
-       
+
        nRet = iotcon_resource_interfaces_add(ifaces, IOTCON_INTERFACE_BATCH);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_add", IotConGetError(nRet),iotcon_resource_types_destroy(hLedTypes);iotcon_resource_interfaces_destroy(ifaces));
 
        nRet = iotcon_resource_create(REMOTE_RESOURCE_LED,hLedTypes,ifaces,(IOTCON_RESOURCE_DISCOVERABLE |IOTCON_RESOURCE_OBSERVABLE), IotconRequestHandlerCB, NULL, &g_hLedResource);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_create", IotConGetError(nRet),iotcon_resource_types_remove(hLedTypes, REMOTE_RESOURCE); iotcon_resource_types_destroy(hLedTypes);iotcon_resource_interfaces_destroy(ifaces));
        CHECK_HANDLE(g_hLedResource,"iotcon_resource_create");
-       
+
        RUN_POLLING_LOOP;
 
        iotcon_resource_types_destroy(hLedTypes);
        iotcon_resource_interfaces_destroy(ifaces);
-       
+
        return 0;
 }
 
@@ -1149,10 +1154,10 @@ void ITs_iotcon_resource_startup(void)
        g_bIotconConnect = true;
        g_bFeatureUnsupported = false;
     int nRet = iotcon_initialize();
-       
+
        if ( !TCTCheckSystemInfoFeatureSupported(IOTCON_FEATURE, API_NAMESPACE) )
        {
-               
+
                if ( nRet != TIZEN_ERROR_NOT_SUPPORTED )
                {
                        FPRINTF("[Line : %d][%s] iotcon_initialize API call returned mismatch %s error for unsupported feature\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
@@ -1165,14 +1170,14 @@ void ITs_iotcon_resource_startup(void)
                }
                return;
        }
-       
+
        if ( nRet != IOTCON_ERROR_NONE )
        {
                FPRINTF("[Line : %d][%s] iotcon_initialize failed API return %s error \\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
                g_bIotconConnect = false;
                return;
        }
-       
+
        return;
 }
 
@@ -1188,14 +1193,14 @@ void ITs_iotcon_resource_cleanup(void)
        #if DEBUG
        FPRINTF("[Line : %d][%s] TEST SUIT clean-up: ITs_iotcon_resource_cleanup\\n", __LINE__, API_NAMESPACE);
 #endif
-       
+
        if (g_bIotconConnect)
        {
                iotcon_deinitialize();
                return;
        }
        return;
-       
+
 }
 
 /** @addtogroup itc-iotcon-testcases
@@ -1225,25 +1230,25 @@ int ITc_iotcon_resource_create_destroy_p(void)
 {
        START_TEST;
        int nRet = IotconCreateLightResource();
-       if ( nRet != IOTCON_ERROR_NONE) 
+       if ( nRet != IOTCON_ERROR_NONE)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLightResource error\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
-       if (g_hLightResource) 
+       if (g_hLightResource)
        {
                nRet = iotcon_resource_destroy(g_hLightResource);
                PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_destroy", IotConGetError(nRet));
                g_hLightResource = NULL;
-               
+
        }
-       if (g_hLedResource) 
+       if (g_hLedResource)
        {
                nRet = iotcon_resource_destroy(g_hLedResource);
                PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_destroy", IotConGetError(nRet));
                g_hLedResource = NULL;
        }
-       
+
     return 0;
 }
 
@@ -1269,7 +1274,7 @@ int ITc_iotcon_resource_bind_interface_p(void)
 {
        START_TEST;
        int nRet = IotconCreateLightResource();
-       if ( nRet != IOTCON_ERROR_NONE) 
+       if ( nRet != IOTCON_ERROR_NONE)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLightResource error\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1277,7 +1282,7 @@ int ITc_iotcon_resource_bind_interface_p(void)
        nRet = iotcon_resource_bind_interface(g_hLightResource, IOTCON_INTERFACE_DEFAULT);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_bind_interface", IotConGetError(nRet),IotconDestroyRes());
        IotconDestroyRes();
-       
+
     return 0;
 }
 
@@ -1303,7 +1308,7 @@ int ITc_iotcon_resource_bind_type_p(void)
 {
        START_TEST;
        int nRet = IotconCreateLightResource();
-       if ( nRet != IOTCON_ERROR_NONE) 
+       if ( nRet != IOTCON_ERROR_NONE)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLightResource error\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1311,7 +1316,7 @@ int ITc_iotcon_resource_bind_type_p(void)
        nRet = iotcon_resource_bind_type(g_hLightResource, LIGHT_RESOURCE2);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_bind_type", IotConGetError(nRet),IotconDestroyRes());
        IotconDestroyRes();
-       
+
     return 0;
 }
 
@@ -1364,13 +1369,13 @@ int ITc_iotcon_resource_bind_unbind_child_resource_p(void)
 {
        START_TEST;
        int nRet = IotconCreateResourceLight();
-       if ( nRet != IOTCON_ERROR_NONE) 
+       if ( nRet != IOTCON_ERROR_NONE)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLightResource error\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
-       
-       if ( false != IotconCreateResourceLED() ) 
+
+       if ( false != IotconCreateResourceLED() )
        {
                FPRINTF("[Line : %d][%s] IotconCreateLedResource error\\n", __LINE__, API_NAMESPACE);
                IotconDestroyRes();
@@ -1378,12 +1383,12 @@ int ITc_iotcon_resource_bind_unbind_child_resource_p(void)
        }
        nRet = iotcon_resource_bind_child_resource(g_hLightResource, g_hLedResource);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_bind_child_resource", IotConGetError(nRet),IotconDestroyRes());
-       
+
        nRet = iotcon_resource_unbind_child_resource(g_hLightResource, g_hLedResource);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_unbind_child_resource", IotConGetError(nRet),IotconDestroyRes());
-       
+
        IotconDestroyRes();
-       
+
     return 0;
 }
 
@@ -1408,14 +1413,14 @@ int ITc_iotcon_resource_bind_unbind_child_resource_p(void)
 int ITc_iotcon_resource_get_child_count_p(void)
 {
        START_TEST;
-       int nNumber = 0;
+       unsigned int nNumber = 0;
        int nRet = IotconCreateResourceLight();
-       if ( nRet != IOTCON_ERROR_NONE) 
+       if ( nRet != IOTCON_ERROR_NONE)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLightResource error\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
-       if ( false != IotconCreateResourceLED() ) 
+       if ( false != IotconCreateResourceLED() )
        {
                FPRINTF("[Line : %d][%s] IotconCreateLedResource error\\n", __LINE__, API_NAMESPACE);
                IotconDestroyRes();
@@ -1423,19 +1428,19 @@ int ITc_iotcon_resource_get_child_count_p(void)
        }
        nRet = iotcon_resource_bind_child_resource(g_hLightResource, g_hLedResource);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_bind_child_resource", IotConGetError(nRet),IotconDestroyRes());
-       
+
        nRet = iotcon_resource_get_child_count(g_hLightResource, &nNumber);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_get_child_count", IotConGetError(nRet),IotconDestroyRes());
-       
-       if ( nNumber != 1 ) 
+
+       if ( nNumber != 1 )
        {
                FPRINTF("[Line : %d][%s] no of children not matching nAddNumber != nNumber\\n", __LINE__, API_NAMESPACE);
                IotconDestroyRes();
                return 1;
        }
        nRet = iotcon_resource_unbind_child_resource(g_hLightResource, g_hLedResource);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_unbind_child_resource", IotConGetError(nRet),IotconDestroyRes());    
-       IotconDestroyRes();     
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_unbind_child_resource", IotConGetError(nRet),IotconDestroyRes());
+       IotconDestroyRes();
     return 0;
 }
 
@@ -1461,12 +1466,12 @@ int ITc_iotcon_resource_get_nth_child_p(void)
 {
        START_TEST;
        int nRet = IotconCreateResourceLight();
-       if ( nRet != IOTCON_ERROR_NONE) 
+       if ( nRet != IOTCON_ERROR_NONE)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLightResource error\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
-       if ( false != IotconCreateResourceLED() ) 
+       if ( false != IotconCreateResourceLED() )
        {
                FPRINTF("[Line : %d][%s] IotconCreateLedResource error\\n", __LINE__, API_NAMESPACE);
                IotconDestroyRes();
@@ -1474,13 +1479,13 @@ int ITc_iotcon_resource_get_nth_child_p(void)
        }
        nRet = iotcon_resource_bind_child_resource(g_hLightResource, g_hLedResource);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_bind_child_resource", IotConGetError(nRet),IotconDestroyRes());
-       
+
        nRet = iotcon_resource_get_nth_child(g_hLightResource, 0, &g_hLedResource);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_get_nth_child", IotConGetError(nRet),IotconDestroyRes());
        CHECK_HANDLE(g_hLedResource,"iotcon_resource_get_nth_child");
-       
-       nRet = iotcon_resource_unbind_child_resource(g_hLightResource, g_hLedResource); 
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_unbind_child_resource", IotConGetError(nRet),IotconDestroyRes());    
+
+       nRet = iotcon_resource_unbind_child_resource(g_hLightResource, g_hLedResource);
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_unbind_child_resource", IotConGetError(nRet),IotconDestroyRes());
        IotconDestroyRes();
     return 0;
 }
@@ -1508,14 +1513,14 @@ int ITc_iotcon_resource_get_uri_path_p(void)
        START_TEST;
        char *uri = NULL;
        int nRet = IotconCreateLightResource();
-       if ( nRet != IOTCON_ERROR_NONE) 
+       if ( nRet != IOTCON_ERROR_NONE)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLightResource error\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
        nRet = iotcon_resource_get_uri_path(g_hLightResource, &uri);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_get_uri_path", IotConGetError(nRet),IotconDestroyRes());
-       if (strcmp(REMOTE_RESOURCE_LIGHT, uri) != 0) 
+       if (strcmp(REMOTE_RESOURCE_LIGHT, uri) != 0)
        {
            IotconDestroyRes();
                free(uri);
@@ -1549,7 +1554,7 @@ int ITc_iotcon_resource_get_types_p(void)
        START_TEST;
        iotcon_resource_types_h hTypes = NULL;
     int nRet = IotconCreateLightResource();
-       if ( nRet != IOTCON_ERROR_NONE) 
+       if ( nRet != IOTCON_ERROR_NONE)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLightResource error\\n", __LINE__, API_NAMESPACE);
                return 1;
@@ -1557,7 +1562,7 @@ int ITc_iotcon_resource_get_types_p(void)
        nRet = iotcon_resource_get_types(g_hLightResource, &hTypes);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_get_types", IotConGetError(nRet),IotconDestroyRes());
        CHECK_HANDLE(hTypes,"iotcon_resource_get_types");
-       
+
        IotconDestroyRes();
     return 0;
 }
@@ -1583,26 +1588,26 @@ int ITc_iotcon_resource_get_types_p(void)
 int ITc_iotcon_resource_get_interfaces_p(void)
 {
        START_TEST;
-       
+
        iotcon_resource_interfaces_h hIface = NULL;
-    
+
        int nRet = IotconCreateResourceLight();
-       if ( nRet != IOTCON_ERROR_NONE) 
+       if ( nRet != IOTCON_ERROR_NONE)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLightResource error\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
-       
-       
+
+
        nRet = iotcon_resource_get_interfaces(g_hLightResource, &hIface);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_get_interfaces", IotConGetError(nRet),IotconDestroyRes());
-       
-       if(hIface == NULL) 
+
+       if(hIface == NULL)
        {
-               IotconDestroyRes();     
+               IotconDestroyRes();
                return 1;
        }
-       IotconDestroyRes();     
+       IotconDestroyRes();
     return 0;
 }
 
@@ -1629,19 +1634,19 @@ int ITc_iotcon_resource_get_properties_p(void)
        START_TEST;
        int nProperties = 0;
     int nRet = IotconCreateLightResource();
-       if ( nRet != IOTCON_ERROR_NONE) 
+       if ( nRet != IOTCON_ERROR_NONE)
        {
                FPRINTF("[Line : %d][%s] IotconCreateLightResource error\\n", __LINE__, API_NAMESPACE);
                return 1;
        }
        nRet = iotcon_resource_get_properties(g_hLightResource, &nProperties);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_get_properties", IotConGetError(nRet),IotconDestroyRes());
-       if ((IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE) != nProperties) 
+       if ((IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE) != nProperties)
        {
                IotconDestroyRes();
                return 1;
        }
-       IotconDestroyRes();     
+       IotconDestroyRes();
     return 0;
 }
 
@@ -1665,9 +1670,9 @@ int ITc_iotcon_resource_get_properties_p(void)
 int ITc_iotcon_resource_types_create_destroy_p(void)
 {
        START_TEST;
-       
+
        iotcon_resource_types_h hTypes = NULL;
-       
+
        int nRet = iotcon_resource_types_create(&hTypes);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_create", IotConGetError(nRet));
        CHECK_HANDLE(hTypes,"iotcon_resource_types_create");
@@ -1698,7 +1703,7 @@ int ITc_iotcon_resource_types_create_destroy_p(void)
 int ITc_iotcon_resource_types_add_remove_p(void)
 {
        START_TEST;
-       
+
        iotcon_resource_types_h hTypes = NULL;
 
        int nRet = iotcon_resource_types_create(&hTypes);
@@ -1710,7 +1715,7 @@ int ITc_iotcon_resource_types_add_remove_p(void)
 
        nRet = iotcon_resource_types_remove(hTypes, REMOTE_RESOURCE);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_remove", IotConGetError(nRet),iotcon_resource_types_destroy(hTypes));
-       
+
        iotcon_resource_types_destroy(hTypes);
 
        return 0;
@@ -1740,7 +1745,7 @@ int ITc_iotcon_resource_types_foreach_p(void)
        iotcon_resource_types_h hTypes = NULL;
        int nCount =0;
        g_bCheckCb = false;
-    
+
        int nRet = iotcon_resource_types_create(&hTypes);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_create", IotConGetError(nRet));
        CHECK_HANDLE(hTypes,"iotcon_resource_types_create");
@@ -1750,11 +1755,11 @@ int ITc_iotcon_resource_types_foreach_p(void)
 
        nRet = iotcon_resource_types_add(hTypes, LIGHT_RESOURCE);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_add", IotConGetError(nRet),iotcon_resource_types_destroy(hTypes));
-       
+
        nRet = iotcon_resource_types_foreach(hTypes, IotconResourceTypesForeachCB, &nCount);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_foreach", IotConGetError(nRet),iotcon_resource_types_destroy(hTypes));
-       
-       
+
+
        if(g_bCheckCb == false)
        {
                FPRINTF("[Line : %d][%s] callback not invoked : \\n", __LINE__, API_NAMESPACE );
@@ -1804,7 +1809,7 @@ int ITc_iotcon_resource_types_foreach_p(void)
 int ITc_iotcon_resource_types_clone_p(void)
 {
        START_TEST;
-       
+
        iotcon_resource_types_h hTypes1, hTypes2;
 
        int nRet = iotcon_resource_types_create(&hTypes1);
@@ -1813,11 +1818,11 @@ int ITc_iotcon_resource_types_clone_p(void)
 
        nRet = iotcon_resource_types_add(hTypes1, REMOTE_RESOURCE);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_foreach", IotConGetError(nRet),iotcon_resource_types_destroy(hTypes1));
-       
+
        nRet = iotcon_resource_types_clone(hTypes1, &hTypes2);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_foreach", IotConGetError(nRet),iotcon_resource_types_remove(hTypes1, REMOTE_RESOURCE);iotcon_resource_types_destroy(hTypes1));
        CHECK_HANDLE(hTypes2,"iotcon_resource_types_clone");
-       
+
        nRet = iotcon_resource_types_remove(hTypes1, REMOTE_RESOURCE);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_remove", IotConGetError(nRet),iotcon_resource_types_destroy(hTypes1);iotcon_resource_types_destroy(hTypes2));
        iotcon_resource_types_destroy(hTypes2);
@@ -1847,12 +1852,12 @@ int ITc_iotcon_resource_types_clone_p(void)
 int ITc_iotcon_resource_notify_p(void)
 {
        START_TEST;
-       
+
        int nRet = CreateAndFindResource(RESOURCE_NOTIFY);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "CreateAndFindResource", IotConGetError(nRet));
-       
+
        return 0;
 }
 
 /** @} */
-/** @} */
\ No newline at end of file
+/** @} */
index 1d4fe43..8825b47 100755 (executable)
 //
 #include "ITs-iotcon-common.h"
 
-static iotcon_request_h g_hRequest= NULL;              
+static iotcon_request_h g_hRequest= NULL;
 static bool g_bRequestRespHandlerCB = false;
 static GMainLoop *g_loop;
 static iotcon_resource_h g_hLightResourceResp;
 static iotcon_remote_resource_h g_hRemoteResourceResp;
+static bool g_found;
+static int g_timeout_count;
 
 #define CHECK_HANDLE_CLEANUP(Handle, API, FreeResource) {\
     if ( Handle == NULL )\
@@ -36,7 +38,7 @@ static iotcon_remote_resource_h g_hRemoteResourceResp;
  * @return                     gboolean
  */
 static gboolean gmain_loop_quit_idle(gpointer p)
-{      
+{
        g_main_loop_quit(g_loop);
        return G_SOURCE_REMOVE;
 }
@@ -61,18 +63,18 @@ static void QuitGmainLoopIdle(bool result)
 static void RequestRespHandlerCB(iotcon_resource_h resource, iotcon_request_h request,
                void *user_data)
 {
-       g_bRequestRespHandlerCB = true; 
-       g_hRequest = request;   
+       g_bRequestRespHandlerCB = true;
+       g_hRequest = request;
        QuitGmainLoopIdle(false);
-       
+
        return;
 }
 
 /**
 * @function            CreateResource
-* @description         Called to create and add resource and interface. 
+* @description         Called to create and add resource and interface.
 * @parameter           NA
-* @return                      intiger : 0 if sussess 
+* @return                      intiger : 0 if sussess
 */
 static int CreateResource()
 {
@@ -82,10 +84,10 @@ static int CreateResource()
 
        nRet = iotcon_resource_types_create(&hLightTypes);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_create", IotConGetError(nRet));
-       
+
        nRet = iotcon_resource_types_add(hLightTypes, LIGHT_RESOURCE_TYPE);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_add", IotConGetError(nRet),iotcon_resource_types_destroy(hLightTypes));
-       
+
        nRet = iotcon_resource_interfaces_create(&hLightiFaces);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet),iotcon_resource_types_destroy(hLightTypes));
 
@@ -127,8 +129,8 @@ static void GetRemoteResourceCB(iotcon_remote_resource_h resource,  iotcon_error_
 
 /**
 * @function            FoundResourceCB
-* @description         get remote resource clone 
-* @parameter           iotcon_remote_resource_h : The remote resource handle, iotcon_error_e : iotcon error    
+* @description         get remote resource clone
+* @parameter           iotcon_remote_resource_h : The remote resource handle, iotcon_error_e : iotcon error
 *                                      user_data : The user data passed from function
 * @return                      NA
 */
@@ -136,14 +138,44 @@ static void FoundResourceCB(iotcon_remote_resource_h resource,
                iotcon_error_e err, void *user_data)
 {
        int nRet;
-       g_bRequestRespHandlerCB = true;  
+       g_bRequestRespHandlerCB = true;
+
+       if (IOTCON_ERROR_TIMEOUT == err && g_timeout_count < TIMEOUT_COUNT_MAX)
+       {
+               g_timeout_count++;
+               nRet = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
+                               LIGHT_RESOURCE_TYPE, false, FoundResourceCB, NULL);
+               if (IOTCON_ERROR_NONE != nRet)
+               {
+                       FPRINTF("[Line : %d][%s] iotcon_find_resource fail in startup error returned : %s\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
+                       QuitGmainLoopIdle(false);
+                       return;
+               }
+               return;
+       }
+       else if (IOTCON_ERROR_NONE != err)
+       {
+               QuitGmainLoopIdle(false);
+               return;
+       }
+
+       if (g_found)
+               return;
+
+       g_found = true;
+
+       char *host_address, *uri;
+       iotcon_remote_resource_get_host_address(resource, &host_address);
+       iotcon_remote_resource_get_uri_path(resource, &uri);
+       dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] host_address[%s], uri[%s]", __FUNCTION__, __LINE__, host_address, uri);
+
        nRet = iotcon_remote_resource_clone(resource, &g_hRemoteResourceResp);
        if (IOTCON_ERROR_NONE != nRet) {
                FPRINTF("iotcon_remote_resource_clone() Fail(%d)", nRet);
                QuitGmainLoopIdle(false);
                return;
        }
-       
+
        nRet = iotcon_remote_resource_get(g_hRemoteResourceResp, NULL, GetRemoteResourceCB, NULL);
        if (IOTCON_ERROR_NONE != nRet) {
                FPRINTF("iotcon_remote_resource_clone() Fail(%d)", nRet);
@@ -156,7 +188,7 @@ static void FoundResourceCB(iotcon_remote_resource_h resource,
 * @function            CreateAndFindResource
 * @description         Function to create and find resource
 * @parameter           NA
-* @return                      intiger : 0 if sussess 
+* @return                      intiger : 0 if sussess
 */
 static int CreateAndFindResource()
 {
@@ -186,35 +218,35 @@ static int CreateAndFindResource()
 
 /**
 * @function            CreateResourceInterfaces
-* @description         Function to create and add iotcon interfaces 
+* @description         Function to create and add iotcon interfaces
 * @parameter           iotcon_resource_interfaces_h : iotcon interface handle
-* @return                      intiger : 0 if sussess 
+* @return                      intiger : 0 if sussess
 */
 int CreateResourceInterfaces(iotcon_resource_interfaces_h *ifaces_h)
 {
        int nRet;
        iotcon_resource_interfaces_h hIfaces;
-       
+
        nRet = iotcon_resource_interfaces_create(&hIfaces);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_create", IotConGetError(nRet));
-       
+
 
        nRet = iotcon_resource_interfaces_add(hIfaces, IOTCON_INTERFACE_DEFAULT);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_add", IotConGetError(nRet));
-       
+
        nRet = iotcon_resource_interfaces_add(hIfaces, IOTCON_INTERFACE_BATCH);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_interfaces_add", IotConGetError(nRet));
-       
+
        *ifaces_h = hIfaces;
-       
+
        return 0;
 }
 
 /**
 * @function            CreateResourceTypes
-* @description         Function to create resource type 
+* @description         Function to create resource type
 * @parameter           iotcon_resource_types_h : iotcon resource type handle,  const char * : resource type
-* @return                      intiger : 0 if sussess 
+* @return                      intiger : 0 if sussess
 */
 int CreateResourceTypes(const char *type, iotcon_resource_types_h *types_h)
 {
@@ -223,21 +255,21 @@ int CreateResourceTypes(const char *type, iotcon_resource_types_h *types_h)
 
        nRet = iotcon_resource_types_create(&hTypes);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_create", IotConGetError(nRet));
-       
+
        nRet = iotcon_resource_types_add(hTypes, type);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_resource_types_add", IotConGetError(nRet));
-       
+
        *types_h = hTypes;
-       
+
        return 0;
 }
 
 
 /**
 * @function            CreateState
-* @description         Function to create iotcon states 
+* @description         Function to create iotcon states
 * @parameter           iotcon_state_h : iotcon state handle
-* @return                      intiger : 0 if sussess 
+* @return                      intiger : 0 if sussess
 */
 int CreateState(iotcon_state_h *state_h)
 {
@@ -248,111 +280,111 @@ int CreateState(iotcon_state_h *state_h)
 
        nRet = iotcon_state_create(&hState);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_state_create", IotConGetError(nRet));
-       
+
        nRet = iotcon_state_add_int(hState, "int", 1);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_int", IotConGetError(nRet),iotcon_state_destroy(hState));       
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_int", IotConGetError(nRet),iotcon_state_destroy(hState));
 
        nRet = iotcon_state_add_bool(hState, "bool", true);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_bool", IotConGetError(nRet),iotcon_state_destroy(hState));      
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_bool", IotConGetError(nRet),iotcon_state_destroy(hState));
 
        nRet = iotcon_state_add_double(hState, "double", 1.1);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_double", IotConGetError(nRet),iotcon_state_destroy(hState));    
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_double", IotConGetError(nRet),iotcon_state_destroy(hState));
 
        nRet = iotcon_state_add_null(hState, "null");
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_null", IotConGetError(nRet),iotcon_state_destroy(hState));      
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_null", IotConGetError(nRet),iotcon_state_destroy(hState));
 
        nRet = iotcon_state_add_str(hState, "str", "string");
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_str", IotConGetError(nRet),iotcon_state_destroy(hState));       
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_str", IotConGetError(nRet),iotcon_state_destroy(hState));
 
        nRet = iotcon_state_add_byte_str(hState, "bytestr", byte_str, 3);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_byte_str", IotConGetError(nRet),iotcon_state_destroy(hState));  
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_byte_str", IotConGetError(nRet),iotcon_state_destroy(hState));
 
        /* state */
        nRet = iotcon_state_create(&hValState);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_create", IotConGetError(nRet),iotcon_state_destroy(hState));        
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_create", IotConGetError(nRet),iotcon_state_destroy(hState));
 
        nRet = iotcon_state_add_int(hValState, "hValState", 10);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_int", IotConGetError(nRet),iotcon_state_destroy(hValState);iotcon_state_destroy(hState));       
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_int", IotConGetError(nRet),iotcon_state_destroy(hValState);iotcon_state_destroy(hState));
 
        nRet = iotcon_state_add_state(hState, "state", hValState);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_state", IotConGetError(nRet),iotcon_state_destroy(hValState);iotcon_state_destroy(hState));     
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_state", IotConGetError(nRet),iotcon_state_destroy(hValState);iotcon_state_destroy(hState));
 
        /* state list */
        nRet = iotcon_list_create(IOTCON_TYPE_STATE, &list6);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_state_destroy(hValState);iotcon_state_destroy(hState)); 
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_state_destroy(hValState);iotcon_state_destroy(hState));
 
        nRet = iotcon_list_add_state(list6, hValState, -1);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_state", IotConGetError(nRet),iotcon_list_destroy(list6);iotcon_state_destroy(hValState);iotcon_state_destroy(hState));   
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_state", IotConGetError(nRet),iotcon_list_destroy(list6);iotcon_state_destroy(hValState);iotcon_state_destroy(hState));
        iotcon_state_destroy(hValState);
 
        nRet = iotcon_state_add_list(hState, "state_list", list6);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list6);iotcon_state_destroy(hState));   
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list6);iotcon_state_destroy(hState));
        iotcon_list_destroy(list6);
 
        /* int list */
        nRet = iotcon_list_create(IOTCON_TYPE_INT, &list1);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_state_destroy(hState)); 
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_state_destroy(hState));
 
        nRet = iotcon_list_add_int(list1, 1, -1);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_int", IotConGetError(nRet),iotcon_list_destroy(list1);iotcon_state_destroy(hState));     
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_int", IotConGetError(nRet),iotcon_list_destroy(list1);iotcon_state_destroy(hState));
 
        nRet = iotcon_state_add_list(hState, "int_list", list1);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list1);iotcon_state_destroy(hState));   
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list1);iotcon_state_destroy(hState));
        iotcon_list_destroy(list1);
 
        /* boolean list */
        nRet = iotcon_list_create(IOTCON_TYPE_BOOL, &list2);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_state_destroy(hState)); 
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_state_destroy(hState));
 
        nRet = iotcon_list_add_bool(list2, true, -1);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_bool", IotConGetError(nRet),iotcon_list_destroy(list2);iotcon_state_destroy(hState));    
-       
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_bool", IotConGetError(nRet),iotcon_list_destroy(list2);iotcon_state_destroy(hState));
+
        nRet = iotcon_state_add_list(hState, "bool_list", list2);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list2);iotcon_state_destroy(hState));   
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list2);iotcon_state_destroy(hState));
        iotcon_list_destroy(list2);
 
        /* string list */
        nRet = iotcon_list_create(IOTCON_TYPE_STR, &list3);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_state_destroy(hState)); 
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_state_destroy(hState));
 
        nRet = iotcon_list_add_str(list3, "string", -1);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_str", IotConGetError(nRet),iotcon_list_destroy(list3);iotcon_state_destroy(hState));     
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_str", IotConGetError(nRet),iotcon_list_destroy(list3);iotcon_state_destroy(hState));
 
        nRet = iotcon_state_add_list(hState, "str_list", list3);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list3);iotcon_state_destroy(hState));   
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list3);iotcon_state_destroy(hState));
        iotcon_list_destroy(list3);
 
        /* byte string list */
        nRet = iotcon_list_create(IOTCON_TYPE_BYTE_STR, &list4);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_state_destroy(hState)); 
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_state_destroy(hState));
 
        nRet = iotcon_list_add_byte_str(list4, byte_str, 3, -1);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_byte_str", IotConGetError(nRet),iotcon_list_destroy(list4);iotcon_state_destroy(hState));        
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_byte_str", IotConGetError(nRet),iotcon_list_destroy(list4);iotcon_state_destroy(hState));
 
        nRet = iotcon_state_add_list(hState, "byte_str_list", list4);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list4);iotcon_state_destroy(hState));   
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list4);iotcon_state_destroy(hState));
 
        /* list list */
        nRet = iotcon_list_create(IOTCON_TYPE_LIST, &list5);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_list_destroy(list4);iotcon_state_destroy(hState));      
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_list_destroy(list4);iotcon_state_destroy(hState));
 
        nRet = iotcon_list_add_list(list5, list4, -1);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_list", IotConGetError(nRet),iotcon_list_destroy(list5);iotcon_list_destroy(list4);iotcon_state_destroy(hState)); 
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_list", IotConGetError(nRet),iotcon_list_destroy(list5);iotcon_list_destroy(list4);iotcon_state_destroy(hState));
        iotcon_list_destroy(list4);
 
        nRet = iotcon_state_add_list(hState, "list_list", list5);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list5);iotcon_state_destroy(hState));   
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list5);iotcon_state_destroy(hState));
        iotcon_list_destroy(list5);
 
        /* double list */
        nRet = iotcon_list_create(IOTCON_TYPE_DOUBLE, &list7);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_state_destroy(hState)); 
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet),iotcon_state_destroy(hState));
 
        nRet = iotcon_list_add_double(list7, 1.1, -1);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_double", IotConGetError(nRet),iotcon_list_destroy(list7);iotcon_state_destroy(hState));  
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_list_add_double", IotConGetError(nRet),iotcon_list_destroy(list7);iotcon_state_destroy(hState));
 
        nRet =iotcon_state_add_list(hState, "double_list", list7);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list7);iotcon_state_destroy(hState));   
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet),iotcon_list_destroy(list7);iotcon_state_destroy(hState));
        iotcon_list_destroy(list7);
 
        *state_h = hState;
@@ -362,9 +394,9 @@ int CreateState(iotcon_state_h *state_h)
 
 /**
 * @function            CreateRepresentation
-* @description         Function to create iotcon representation 
+* @description         Function to create iotcon representation
 * @parameter           iotcon_representation_h : iotcon representation handle
-* @return                      intiger : 0 if sussess 
+* @return                      intiger : 0 if sussess
 */
 int CreateRepresentation(iotcon_representation_h *representation)
 {
@@ -463,10 +495,10 @@ void ITs_iotcon_response_startup(void)
        g_bIotconConnect = true;
        g_bFeatureUnsupported = false;
     int nRet = iotcon_initialize();
-       
+
        if ( !TCTCheckSystemInfoFeatureSupported(IOTCON_FEATURE, API_NAMESPACE) )
        {
-               
+
                if ( nRet != TIZEN_ERROR_NOT_SUPPORTED )
                {
                        FPRINTF("[Line : %d][%s] iotcon_initialize API call returned mismatch %s error for unsupported feature\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
@@ -479,18 +511,18 @@ void ITs_iotcon_response_startup(void)
                }
                return;
        }
-       
+
        if ( nRet != IOTCON_ERROR_NONE )
        {
                FPRINTF("[Line : %d][%s] iotcon_initialize failed API return %s error \\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
                g_bIotconConnect = false;
                return;
        }
-       
-       if (true == g_bIotconConnect) 
+
+       if (true == g_bIotconConnect)
        {
                nRet = CreateAndFindResource();
-               if (1 == nRet) 
+               if (1 == nRet)
                {
                        FPRINTF("[Line : %d][%s] CreateAndFindResource fail in startup : \\n", __LINE__, API_NAMESPACE);
                        g_bIotconConnect = false;
@@ -498,7 +530,7 @@ void ITs_iotcon_response_startup(void)
                        return;
                }
        }
-       
+
        return;
 }
 
@@ -510,7 +542,7 @@ void ITs_iotcon_response_startup(void)
  * @return                     NA
  */
 void ITs_iotcon_response_cleanup(void)
-{      
+{
        if (g_hRemoteResourceResp) {
                iotcon_remote_resource_destroy(g_hRemoteResourceResp);
                g_hRemoteResourceResp = NULL;
@@ -518,26 +550,26 @@ void ITs_iotcon_response_cleanup(void)
        if (g_hLightResourceResp) {
                iotcon_resource_destroy(g_hLightResourceResp);
                g_hLightResourceResp = NULL;
-       }       
+       }
        if( g_bIotconConnect )
        {
                iotcon_deinitialize();
        }
-       
+
        return;
 }
 
-// purpose: Creates a new hResponse handle and destroy it. 
-//& type: auto 
+// purpose: Creates a new hResponse handle and destroy it.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_response_create_destroy_p
 * @since_tizen                 3.0
 * @author              SRID(gaurav.m2)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Creates a new hResponse handle and destroy it.  
+* @description                 Creates a new hResponse handle and destroy it.
 * @scenario                            call iotcon_response_create and iotcon_response_destroy
-* @apicovered                  iotcon_response_create,iotcon_response_destroy                          
+* @apicovered                  iotcon_response_create,iotcon_response_destroy
 * @passcase                            When iotcon_response_create and iotcon_response_destroy is successful.
 * @failcase                            If target API iotcon_response_create or iotcon_response_destroy fails.
 * @precondition                        NA
@@ -546,31 +578,31 @@ void ITs_iotcon_response_cleanup(void)
 int ITc_iotcon_response_create_destroy_p(void)
 {
        START_TEST;
-       iotcon_response_h hResponse = NULL; 
+       iotcon_response_h hResponse = NULL;
        g_bRequestRespHandlerCB = false;
-       
-       //target api    
+
+       //target api
        int nRet = iotcon_response_create(g_hRequest, &hResponse);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_response_create", IotConGetError(nRet));
        CHECK_HANDLE(hResponse,"iotcon_response_create");
-       
+
        //target api
        iotcon_response_destroy(hResponse);
-       
+
     return 0;
 }
 
-// purpose: Set and Get the options for response handle. 
-//& type: auto 
+// purpose: Set and Get the options for response handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_response_set_get_options_p
 * @since_tizen                 3.0
 * @author              SRID(gaurav.m2)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Get  and set the options for hResponse handle.  
+* @description                 Get  and set the options for hResponse handle.
 * @scenario                            call iotcon_response_get_options,iotcon_response_set_options
-* @apicovered                  iotcon_response_get_options      & iotcon_response_set_options                          
+* @apicovered                  iotcon_response_get_options      & iotcon_response_set_options
 * @passcase                            When iotcon_response_get_options & iotcon_response_set_options is successful.
 * @failcase                            If target API iotcon_response_get_options  or iotcon_response_set_options API fails.
 * @precondition                        NA
@@ -579,28 +611,28 @@ int ITc_iotcon_response_create_destroy_p(void)
 int ITc_iotcon_response_set_get_options_p(void)
 {
        START_TEST;
-       iotcon_response_h hResponse = NULL; 
+       iotcon_response_h hResponse = NULL;
        int nRet = 0;
        g_bRequestRespHandlerCB = false;
-       
+
        iotcon_options_h hOptions;
        iotcon_options_h hGetOptions;
 
        nRet = iotcon_response_create(g_hRequest, &hResponse);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_response_create", IotConGetError(nRet));
-       CHECK_HANDLE_CLEANUP(hResponse,"iotcon_response_create",iotcon_response_destroy(hResponse));    
-       
+       CHECK_HANDLE_CLEANUP(hResponse,"iotcon_response_create",iotcon_response_destroy(hResponse));
+
        nRet = iotcon_options_create(&hOptions);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_options_create", IotConGetError(nRet),iotcon_response_destroy(hResponse));
        CHECK_HANDLE_CLEANUP(hOptions,"iotcon_options_create",iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));
 
        nRet = iotcon_response_set_options(hResponse, hOptions);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_set_options", IotConGetError(nRet),iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));
-       
+
        nRet = iotcon_response_get_options(hResponse, &hGetOptions);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_get_options", IotConGetError(nRet),iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));
        CHECK_HANDLE_CLEANUP(hGetOptions,"iotcon_response_get_options",iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));
-       
+
        if(hOptions != hGetOptions)
        {
                FPRINTF("[Line : %d][%s] Values of set get not matched!!!\\n", __LINE__, API_NAMESPACE);
@@ -608,25 +640,25 @@ int ITc_iotcon_response_set_get_options_p(void)
                iotcon_response_destroy(hResponse);
         return 1;
        }
-       
+
        iotcon_options_destroy(hOptions);
        iotcon_response_destroy(hResponse);
-       
+
        return 0;
 }
 
 
-// purpose: Set and Get the representation for handle. 
-//& type: auto 
+// purpose: Set and Get the representation for handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_response_set_get_representation_p
 * @since_tizen                 3.0
 * @author              SRID(gaurav.m2)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Create the representation ,set it and get the representation for hResponse handle.  
+* @description                 Create the representation ,set it and get the representation for hResponse handle.
 * @scenario                            call iotcon_response_get_representation & iotcon_response_set_representation
-* @apicovered                  iotcon_representation_create,iotcon_response_get_representation  iotcon_representation_destroy and iotcon_response_set_representation                           
+* @apicovered                  iotcon_representation_create,iotcon_response_get_representation  iotcon_representation_destroy and iotcon_response_set_representation
 * @passcase                            When iotcon_response_get_representation & iotcon_response_set_representation is successful.
 * @failcase                            If target API iotcon_response_get_representation,iotcon_response_set_representation ,iotcon_representation_destroy
                                                or any precondition API fails.
@@ -640,40 +672,40 @@ int ITc_iotcon_response_set_get_representation_p(void)
        iotcon_representation_h hRep = NULL;
        iotcon_representation_h hRepresentation = NULL;
        g_bRequestRespHandlerCB = false;
-       
+
        int nRet = iotcon_response_create(g_hRequest, &hResponse);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_response_create", IotConGetError(nRet));
        CHECK_HANDLE(hResponse,"iotcon_response_create");
-       
+
        nRet = iotcon_representation_create(&hRep);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_representation_create", IotConGetError(nRet),iotcon_response_destroy(hResponse));         
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_representation_create", IotConGetError(nRet),iotcon_response_destroy(hResponse));
        CHECK_HANDLE_CLEANUP(hRep,"iotcon_representation_create",iotcon_response_destroy(hResponse));
-       
+
        nRet = iotcon_response_set_representation(hResponse, IOTCON_INTERFACE_DEFAULT, hRep);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_set_representation", IotConGetError(nRet),iotcon_representation_destroy(hRep);iotcon_response_destroy(hResponse););      
-       
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_set_representation", IotConGetError(nRet),iotcon_representation_destroy(hRep);iotcon_response_destroy(hResponse););
+
        nRet = iotcon_response_get_representation(hResponse, &hRepresentation);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_get_representation", IotConGetError(nRet),iotcon_representation_destroy(hRep);iotcon_response_destroy(hResponse));       
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_get_representation", IotConGetError(nRet),iotcon_representation_destroy(hRep);iotcon_response_destroy(hResponse));
        CHECK_HANDLE(hRepresentation,"iotcon_response_get_representation");
-       
+
        iotcon_representation_destroy(hRepresentation);
        iotcon_representation_destroy(hRep);
        iotcon_response_destroy(hResponse);
-               
+
     return 0;
 }
 
-// purpose: Get and set the result for handle. 
-//& type: auto 
+// purpose: Get and set the result for handle.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_response_set_get_result_p
 * @since_tizen                 3.0
 * @author              SRID(gaurav.m2)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Set the result for response handle and check it with the Get Result.  
+* @description                 Set the result for response handle and check it with the Get Result.
 * @scenario                            call iotcon_response_get_result and iotcon_response_set_result
-* @apicovered                  iotcon_response_get_result      ,iotcon_response_set_result                             
+* @apicovered                  iotcon_response_get_result      ,iotcon_response_set_result
 * @passcase                            When iotcon_response_get_result & iotcon_response_set_result is successful.
 * @failcase                            If target API iotcon_response_get_result ,iotcon_response_set_result or any precondition API fails.
 * @precondition                        NA
@@ -683,44 +715,44 @@ int ITc_iotcon_response_set_get_result_p(void)
 {
        START_TEST;
        g_bRequestRespHandlerCB = false;
-       iotcon_response_result_e eResponseResult;       
+       iotcon_response_result_e eResponseResult;
        iotcon_response_h hResponse;
-       int i;  
-       
+       int i;
+
        int nRet = iotcon_response_create(g_hRequest, &hResponse);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_response_create", IotConGetError(nRet));
        CHECK_HANDLE(hResponse,"iotcon_response_create");
-       
+
        for (i = IOTCON_RESPONSE_OK; i <= IOTCON_RESPONSE_FORBIDDEN; i++) {
-               
+
                nRet = iotcon_response_set_result(hResponse, i);
-               PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_set_result", IotConGetError(nRet),iotcon_response_destroy(hResponse));           
-               
+               PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_set_result", IotConGetError(nRet),iotcon_response_destroy(hResponse));
+
                nRet = iotcon_response_get_result(hResponse, &eResponseResult);
-               PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_get_result", IotConGetError(nRet),iotcon_response_destroy(hResponse));   
+               PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_get_result", IotConGetError(nRet),iotcon_response_destroy(hResponse));
                if(eResponseResult != i)
                {
                        FPRINTF("[Line : %d][%s] Values of set get not matched in !!!\\n", __LINE__, API_NAMESPACE);
                        iotcon_response_destroy(hResponse);
                        return 1;
-               }       
+               }
        }
-       
+
        iotcon_response_destroy(hResponse);
-       
+
        return 0;
 }
-// purpose: Send response to the client. 
-//& type: auto 
+// purpose: Send response to the client.
+//& type: auto
 /**
 * @testcase                    ITc_iotcon_response_send_p
 * @since_tizen                 3.0
 * @author              SRID(gaurav.m2)
 * @reviewer            SRID(parshant.v)
 * @type                                auto
-* @description                 Send response to the client.  
+* @description                 Send response to the client.
 * @scenario                            call iotcon_response_send
-* @apicovered                  iotcon_response_send                                    
+* @apicovered                  iotcon_response_send
 * @passcase                            When iotcon_response_send is successful.
 * @failcase                            If target API iotcon_response_send or any precondition API fails.
 * @precondition                        NA
@@ -733,42 +765,42 @@ int ITc_iotcon_response_send_p(void)
        iotcon_response_h hResponse = NULL;
        iotcon_options_h hOptions = NULL;
        iotcon_representation_h hRep = NULL;
-       
+
        int nRet = iotcon_response_create(g_hRequest, &hResponse);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_response_create", IotConGetError(nRet));
        CHECK_HANDLE(hResponse,"iotcon_response_create");
-               
+
        nRet = iotcon_options_create(&hOptions);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_options_create", IotConGetError(nRet),iotcon_response_destroy(hResponse));                
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_options_create", IotConGetError(nRet),iotcon_response_destroy(hResponse));
        CHECK_HANDLE_CLEANUP(hOptions,"iotcon_options_create",iotcon_response_destroy(hResponse));
-       
+
        nRet = iotcon_options_add(hOptions, 2048, "1");
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_options_add", IotConGetError(nRet),iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));          
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_options_add", IotConGetError(nRet),iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));
 
        nRet = iotcon_response_set_result(hResponse, IOTCON_RESPONSE_OK);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_set_result", IotConGetError(nRet),iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));          
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_set_result", IotConGetError(nRet),iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));
 
        nRet = iotcon_response_set_options(hResponse, hOptions);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_set_options", IotConGetError(nRet),iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));         
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_set_options", IotConGetError(nRet),iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));
 
        nRet = CreateRepresentation(&hRep);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "CreateRepresentation", IotConGetError(nRet),iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));                
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "CreateRepresentation", IotConGetError(nRet),iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));
        CHECK_HANDLE_CLEANUP(hRep,"CreateRepresentation",iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));
-       
+
        nRet = iotcon_representation_create(&hRep);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_representation_create", IotConGetError(nRet),iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));                
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_representation_create", IotConGetError(nRet),iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));
        CHECK_HANDLE_CLEANUP(hRep,"iotcon_representation_create",iotcon_options_destroy(hOptions);iotcon_representation_destroy(hRep);iotcon_response_destroy(hResponse));
-               
+
        nRet = iotcon_response_set_representation(hResponse, IOTCON_INTERFACE_DEFAULT, hRep);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_set_representation", IotConGetError(nRet),iotcon_representation_destroy(hRep);iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));              
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_set_representation", IotConGetError(nRet),iotcon_representation_destroy(hRep);iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));
 
-       //target api    
+       //target api
        nRet = iotcon_response_send(hResponse);
-       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_send", IotConGetError(nRet),iotcon_representation_destroy(hRep);iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));            
-       
+       PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_response_send", IotConGetError(nRet),iotcon_representation_destroy(hRep);iotcon_options_destroy(hOptions);iotcon_response_destroy(hResponse));
+
        iotcon_representation_destroy(hRep);
        iotcon_options_destroy(hOptions);
        iotcon_response_destroy(hResponse);
-       
+
     return 0;
 }
index 921c28e..060a800 100755 (executable)
@@ -34,13 +34,13 @@ static iotcon_representation_h g_hRepr;
 bool IotconStateCB(iotcon_state_h state, const char *key, void *user_data)
 {
        FPRINTF("[Line : %d][%s] Inside IotconStateCB callback\\n", __LINE__, API_NAMESPACE);
-       
+
        if((state == NULL) || (key == NULL))
        {
                FPRINTF("[Line : %d][%s] Inside IotconStateCB fails as input values are NULL \\n", __LINE__, API_NAMESPACE);
-       }       
+       }
        g_bCheckCb = true;
-       
+
        return IOTCON_FUNC_CONTINUE;
 }
 
@@ -60,10 +60,10 @@ void ITs_iotcon_state_startup(void)
        g_bIotconConnect = true;
        g_bFeatureUnsupported = false;
     int nRet = iotcon_initialize();
-       
+
        if ( !TCTCheckSystemInfoFeatureSupported(IOTCON_FEATURE, API_NAMESPACE) )
        {
-               
+
                if ( nRet != TIZEN_ERROR_NOT_SUPPORTED )
                {
                        FPRINTF("[Line : %d][%s] iotcon_initialize API call returned mismatch %s error for unsupported feature\\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
@@ -76,14 +76,14 @@ void ITs_iotcon_state_startup(void)
                }
                return;
        }
-       
+
        if ( nRet != IOTCON_ERROR_NONE )
        {
                FPRINTF("[Line : %d][%s] iotcon_initialize failed API return %s error \\n", __LINE__, API_NAMESPACE, IotConGetError(nRet));
                g_bIotconConnect = false;
                return;
        }
-               
+
        nRet = iotcon_state_create(&g_hState);
        if (IOTCON_ERROR_NONE != nRet)
        {
@@ -101,7 +101,7 @@ void ITs_iotcon_state_startup(void)
        }
 
        nRet = iotcon_representation_create(&g_hRepr);
-       if (IOTCON_ERROR_NONE != nRet) 
+       if (IOTCON_ERROR_NONE != nRet)
        {
                FPRINTF("[Line : %d][%s] iotcon_representation_create fail in startup \\n", __LINE__, API_NAMESPACE);
                iotcon_state_destroy(g_hState);
@@ -130,20 +130,20 @@ void ITs_iotcon_state_startup(void)
  */
 void ITs_iotcon_state_cleanup(void)
 {
-       
+
 #if DEBUG
        FPRINTF("[Line : %d][%s] TEST SUIT clean-up: ITs_Iotcon_State_p\\n", __LINE__, API_NAMESPACE);
 #endif
 
        if(g_hRepr)
                iotcon_representation_destroy(g_hRepr);
-       
-       if (g_hState) 
+
+       if (g_hState)
                iotcon_state_destroy(g_hState);
 
        if (g_bIotconConnect)
                iotcon_deinitialize();
-       
+
        return;
 }
 
@@ -173,7 +173,7 @@ void ITs_iotcon_state_cleanup(void)
 int ITc_iotcon_state_create_destroy_p(void)
 {
        START_TEST;
-               
+
        iotcon_state_h hState = NULL;
 
        int nRet = iotcon_state_create(&hState);
@@ -182,7 +182,7 @@ int ITc_iotcon_state_create_destroy_p(void)
 
        iotcon_state_destroy(hState);
        hState = NULL;
-               
+
     return 0;
 }
 
@@ -205,7 +205,7 @@ int ITc_iotcon_state_create_destroy_p(void)
 int ITc_iotcon_state_clone_p(void)
 {
        START_TEST;
-               
+
        iotcon_state_h hState = NULL;
 
        int nRet = iotcon_state_clone(g_hState, &hState);
@@ -214,7 +214,7 @@ int ITc_iotcon_state_clone_p(void)
 
        iotcon_state_destroy(hState);
        hState = NULL;
-       
+
        return 0;
 }
 
@@ -238,10 +238,10 @@ int ITc_iotcon_state_clone_p(void)
 int ITc_iotcon_state_add_get_int_p(void)
 {
        START_TEST;
-               
+
        int nSetIntVal = 10;
        int nGetIntVal;
-               
+
        int nRet = iotcon_state_add_int(g_hState, KEY, nSetIntVal);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_int", IotConGetError(nRet));
 
@@ -277,7 +277,7 @@ int ITc_iotcon_state_add_get_int_p(void)
 int ITc_iotcon_state_add_get_bool_p(void)
 {
        START_TEST;
-       
+
        bool bSetBoolVal = true;
        bool bGetBoolVal;
 
@@ -291,10 +291,10 @@ int ITc_iotcon_state_add_get_bool_p(void)
                FPRINTF("[Line : %d][%s] value mismatch \\n", __LINE__, API_NAMESPACE );
                return 1;
        }
-       
+
        nRet = iotcon_state_remove(g_hState, KEY);
        PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
-       
+
        return 0;
 }
 
@@ -318,7 +318,7 @@ int ITc_iotcon_state_add_get_bool_p(void)
 int ITc_iotcon_state_add_get_double_p(void)
 {
        START_TEST;
-               
+
        double nSetdoubleVal = 3.4;
        double nGetdoubleVal;
 
@@ -332,10 +332,10 @@ int ITc_iotcon_state_add_get_double_p(void)
                FPRINTF("[Line : %d][%s] value mismatch \\n", __LINE__, API_NAMESPACE );
                return 1;
        }
-       
+
        nRet = iotcon_state_remove(g_hState, KEY);
        PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
-       
+
        return 0;
 }
 
@@ -359,7 +359,7 @@ int ITc_iotcon_state_add_get_double_p(void)
 int ITc_iotcon_state_add_get_str_p(void)
 {
        START_TEST;
-               
+
        char *GetValue;
 
        int nRet = iotcon_state_add_str(g_hState, KEY, VALUE);
@@ -375,7 +375,7 @@ int ITc_iotcon_state_add_get_str_p(void)
 
        nRet = iotcon_state_remove(g_hState, KEY);
        PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
-       
+
        return 0;
 
 }
@@ -401,29 +401,29 @@ int ITc_iotcon_state_add_get_str_p(void)
 int ITc_iotcon_state_add_get_list_p(void)
 {
        START_TEST;
-       
+
        iotcon_list_h hList;
-       
+
        int nRet = iotcon_list_create(IOTCON_TYPE_INT,&hList);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_list_create", IotConGetError(nRet));
        CHECK_HANDLE(hList,"iotcon_list_create");
-       
+
        nRet = iotcon_state_add_list(g_hState, KEY, hList);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_list", IotConGetError(nRet));
 
        nRet = iotcon_state_get_list(g_hState, KEY, &hList);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_state_get_list", IotConGetError(nRet));
        CHECK_HANDLE(hList,"iotcon_state_get_list");
-       
+
        nRet = iotcon_state_remove(g_hState, KEY);
        PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
-       
+
        if(hList)
        {
                iotcon_list_destroy(hList);
-               hList = NULL;                   
+               hList = NULL;
        }
-       
+
        return 0;
 }
 
@@ -448,22 +448,22 @@ int ITc_iotcon_state_add_get_list_p(void)
 int ITc_iotcon_state_add_get_state_p(void)
 {
        START_TEST;
-       
+
        iotcon_state_h hState1, hState2;
-       
+
        int nRet = iotcon_state_create(&hState1);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_state_create", IotConGetError(nRet));
        CHECK_HANDLE(hState1,"iotcon_state_create");
 
        nRet = iotcon_state_add_state(g_hState, KEY, hState1);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_state", IotConGetError(nRet),iotcon_state_destroy(hState1));
-       
+
        iotcon_state_destroy(hState1);
 
        nRet = iotcon_state_get_state(g_hState, KEY, &hState2);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_state_get_state", IotConGetError(nRet));
        CHECK_HANDLE(hState2,"iotcon_state_get_state");
-       
+
        nRet = iotcon_state_remove(g_hState, KEY);
        PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
 
@@ -489,7 +489,7 @@ int ITc_iotcon_state_add_get_state_p(void)
 int ITc_iotcon_state_add_is_null_p(void)
 {
        START_TEST;
-       
+
        bool bVal;
 
        int nRet = iotcon_state_add_null(g_hState, KEY);
@@ -502,7 +502,7 @@ int ITc_iotcon_state_add_is_null_p(void)
                FPRINTF("[Line : %d][%s] value is not null  : \\n", __LINE__, API_NAMESPACE );
                return 1;
        }
-       
+
        nRet = iotcon_state_remove(g_hState, KEY);
        PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
 
@@ -520,7 +520,7 @@ int ITc_iotcon_state_add_is_null_p(void)
 * @since_tizen                         3.0
 * @description                 scenario to remove state
 * @scenario                            add different states like int,double,bool,null \n
-*                                              iotcon_state_remove 
+*                                              iotcon_state_remove
 * @apicovered                  iotcon_state_remove
 * @passcase                            if iotcon_state_remove passes
 * @failcase                            if iotcon_state_remove fails
@@ -530,11 +530,11 @@ int ITc_iotcon_state_add_is_null_p(void)
 int ITc_iotcon_state_remove_p(void)
 {
        START_TEST;
-       
+
        int nSetIntVal = 10;
        bool bSetVal = true;
        double nSetDbVal = 3.4;
-               
+
        int nRet = iotcon_state_add_int(g_hState, KEY, nSetIntVal);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_int", IotConGetError(nRet));
 
@@ -564,7 +564,7 @@ int ITc_iotcon_state_remove_p(void)
 
        nRet = iotcon_state_remove(g_hState, KEY);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
-       
+
        return 0;
 }
 
@@ -589,9 +589,9 @@ int ITc_iotcon_state_remove_p(void)
 int ITc_iotcon_state_get_type_p(void)
 {
        START_TEST;
-       
+
        iotcon_type_e eType;
-       
+
        int nSetIntVal = 10;
 
        int nRet = iotcon_state_add_int(g_hState, KEY, nSetIntVal);
@@ -599,13 +599,13 @@ int ITc_iotcon_state_get_type_p(void)
 
        nRet = iotcon_state_get_type(g_hState, KEY, &eType);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_state_get_type", IotConGetError(nRet));
-       
+
        if(eType != IOTCON_TYPE_INT)
        {
                FPRINTF("[Line : %d][%s] value mismatch  : \\n", __LINE__, API_NAMESPACE );
                return 1;
        }
-       
+
        nRet = iotcon_state_remove(g_hState, KEY);
        PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
 
@@ -633,10 +633,10 @@ int ITc_iotcon_state_get_type_p(void)
 int ITc_iotcon_state_foreach_p(void)
 {
        START_TEST;
-       
+
        iotcon_state_h hState1, hState2;
        g_bCheckCb = false;
-                       
+
        int nRet = iotcon_state_create(&hState1);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_state_create", IotConGetError(nRet));
        CHECK_HANDLE(hState1,"iotcon_state_create");
@@ -644,7 +644,7 @@ int ITc_iotcon_state_foreach_p(void)
        nRet = iotcon_state_create(&hState2);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_create", IotConGetError(nRet),iotcon_state_destroy(hState2);iotcon_state_destroy(hState1));
        CHECK_HANDLE(hState2,"iotcon_state_create");
-       
+
        nRet = iotcon_state_add_state(g_hState, VALUE, hState1);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_state", IotConGetError(nRet),iotcon_state_destroy(hState2);iotcon_state_destroy(hState1));
 
@@ -661,16 +661,16 @@ int ITc_iotcon_state_foreach_p(void)
                iotcon_state_destroy(hState1);hState1 = NULL;
                return 1;
        }
-       
+
        nRet = iotcon_state_remove(g_hState, VALUE);
        PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
-       
+
        nRet = iotcon_state_remove(g_hState, KEY);
        PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
-               
+
        iotcon_state_destroy(hState2);hState2 = NULL;
        iotcon_state_destroy(hState1);hState1 = NULL;
-       
+
        return 0;
 }
 
@@ -694,7 +694,7 @@ int ITc_iotcon_state_foreach_p(void)
 int ITc_iotcon_state_get_keys_count_p(void)
 {
        START_TEST;
-        
+
        unsigned int nCount =0;
        iotcon_state_h hState1, hState2;
 
@@ -715,23 +715,23 @@ int ITc_iotcon_state_get_keys_count_p(void)
        nRet = iotcon_state_get_keys_count(g_hState, &nCount);
        PRINT_RESULT_CLEANUP(IOTCON_ERROR_NONE, nRet, "iotcon_state_get_keys_count", IotConGetError(nRet),iotcon_state_destroy(hState2);iotcon_state_destroy(hState1));
 
-       if (2 != nCount) 
+       if (2 != nCount)
        {
                FPRINTF("[Line : %d][%s] value mismatch  : \\n", __LINE__, API_NAMESPACE );
                iotcon_state_destroy(hState2);hState2 = NULL;
                iotcon_state_destroy(hState1);hState1 = NULL;
                return 1;
        }
-       
+
        nRet = iotcon_state_remove(g_hState, VALUE);
        PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
-       
+
        nRet = iotcon_state_remove(g_hState, KEY);
        PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
 
        iotcon_state_destroy(hState2);hState2 = NULL;
        iotcon_state_destroy(hState1);hState1 = NULL;
-       
+
        return 0;
 }
 
@@ -755,35 +755,38 @@ int ITc_iotcon_state_get_keys_count_p(void)
 int ITc_iotcon_state_add_get_byte_str_p(void)
 {
        START_TEST;
-               
-       char *GetValue = NULL;
-       const char *SetValue = "value";
+
+       unsigned char *GetValue = NULL;
+       unsigned char SetValue[5] = { 1, 2, 3, 4, 5 };
        int len =  0;
-       
-       int nRet = iotcon_state_add_byte_str(g_hState, KEY, SetValue, 5);
+       int i;
+
+       int nRet = iotcon_state_add_byte_str(g_hState, KEY, SetValue, sizeof(SetValue)/sizeof(unsigned char));
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_state_add_str", IotConGetError(nRet));
 
        nRet = iotcon_state_get_byte_str(g_hState, KEY, &GetValue, &len);
        PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_state_get_str", IotConGetError(nRet));
-       
-       if(0 != strcmp(GetValue,SetValue)) 
-       {
-               FPRINTF("[Line : %d][%s] value mismatch \\n", __LINE__, API_NAMESPACE );
-               iotcon_state_remove(g_hState, KEY);
-               return 1;
-       }
-       
-       if( 5 != len )
+
+       if( sizeof(SetValue)/sizeof(unsigned char) != len )
        {
                FPRINTF("[Line : %d][%s] len mismatch \\n", __LINE__, API_NAMESPACE );
                iotcon_state_remove(g_hState, KEY);
                return 1;
        }
 
+       for (i = 0; i < sizeof(SetValue)/sizeof(unsigned char); i++) {
+               if (GetValue[i] != SetValue[i]) {
+                       FPRINTF("[Line : %d][%s] value mismatch \\n", __LINE__, API_NAMESPACE );
+                       iotcon_state_remove(g_hState, KEY);
+                       return 1;
+               }
+       }
+
        nRet = iotcon_state_remove(g_hState, KEY);
        PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
        return 0;
 }
 
 /** @} */
-/** @} */
\ No newline at end of file
+/** @} */
+
index bd2d5ab..f0f54ec 100755 (executable)
@@ -238,7 +238,7 @@ testcase tc_array[] = {
     {"ITc_iotcon_remote_resource_get_properties_p", ITc_iotcon_remote_resource_get_properties_p, ITs_iotcon_remote_resource_startup, ITs_iotcon_remote_resource_cleanup},
     {"ITc_iotcon_remote_resource_set_get_options_p", ITc_iotcon_remote_resource_set_get_options_p, ITs_iotcon_remote_resource_startup, ITs_iotcon_remote_resource_cleanup},
     {"ITc_iotcon_remote_resource_get_cached_representation_p", ITc_iotcon_remote_resource_get_cached_representation_p, ITs_iotcon_remote_resource_startup, ITs_iotcon_remote_resource_cleanup},
-       {"ITc_iotcon_remote_resource_set_get_time_interval_p", ITc_iotcon_remote_resource_set_get_time_interval_p, ITs_iotcon_remote_resource_startup, ITs_iotcon_remote_resource_cleanup},     
+       {"ITc_iotcon_remote_resource_set_get_time_interval_p", ITc_iotcon_remote_resource_set_get_time_interval_p, ITs_iotcon_remote_resource_startup, ITs_iotcon_remote_resource_cleanup},
     {"ITc_iotcon_representation_create_destroy_p", ITc_iotcon_representation_create_destroy_p, ITs_iotcon_representation_startup, ITs_iotcon_representation_cleanup},
     {"ITc_iotcon_representation_clone_p", ITc_iotcon_representation_clone_p, ITs_iotcon_representation_startup, ITs_iotcon_representation_cleanup},
     {"ITc_iotcon_representation_set_get_uri_path_p", ITc_iotcon_representation_set_get_uri_path_p, ITs_iotcon_representation_startup, ITs_iotcon_representation_cleanup},