*/
static void RequestHandlerCB(iotcon_resource_h resource, iotcon_request_h request,void *user_data)
{
-
+
}
/**
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));
iotcon_resource_destroy(g_light_resource);
g_light_resource = NULL;
}
-
+
}
/**
iotcon_presence_trigger_e trigger;
g_bCallbackHit = true;
-
+
if(response == NULL)
{
return;
}
-
+
if (IOTCON_ERROR_NONE != err)
return;
{
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);
}
return;
}
- else if (IOTCON_ERROR_NONE != err)
+ else if (IOTCON_ERROR_NONE != err)
{
presence_response_main_loop_quit(false);
return;
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);
}
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());
* @parameter NA
* @return NA
*/
-
+
void ITs_iotcon_presence_response_startup(void)
{
struct stat stBuff;
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));
}
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;
}
* @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();
}
*/
-
+
}
}
/** @} */
-/** @} */
\ No newline at end of file
+/** @} */
static bool g_found;
static int g_timeout_count;
static bool g_result;
-static bool g_feature;
static GMainLoop *g_loop;
/* ### server side ### */
static gboolean presence_main_loop_quit_idle(gpointer p)
{
-
+
g_main_loop_quit(g_loop);
return G_SOURCE_REMOVE;
}
static void presence_request_handler(iotcon_resource_h resource,
iotcon_request_h request, void *user_data)
{
-
+
}
static void presence_destroy_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);
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
*/
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);
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));
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);
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);
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);
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);
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;
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));
}
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;
}
START_TEST;
int nRet = CreateAndFindResource(PRESENCE_GET_CONN_TYPE_P);
PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "CreateAndFindResource", IotConGetError(nRet));
-
+
return 0;
}
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));
* @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
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"
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;
* @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)
* @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)
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);
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 )
{
* @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)
* @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)
{
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;
}
* @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);
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);
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);
g_main_loop_unref(g_pMainLoop);
g_pMainLoop = NULL;
}
- return;
+ return;
}
/**
* @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);
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);
}
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;
}
/**
* @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)
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);
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);
}
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;
}
/**
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 )
{
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;
*/
void IotconDestroyRemoteResource()
{
- if (g_hClient)
+ if (g_hClient)
{
iotcon_remote_resource_destroy(g_hClient);
g_hClient = NULL;
* @description Create Resource
* @parameter NA
* @return int
-*/
+*/
int IotconCreateResource()
{
int nRet = iotcon_resource_types_create(&g_hTypes);
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;
* @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)
* @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)
* @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)
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)
* @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)
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);
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);
g_main_loop_unref(g_pMainLoop);
g_pMainLoop = NULL;
}
- return;
+ return;
}
/**
* @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)
{
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;
}
* @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);
g_main_loop_unref(g_pMainLoop);
g_pMainLoop = NULL;
}
- return;
+ return;
}
/**
* @function ITs_iotcon_remote_resource_startup
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));
}
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;
}
* @{
*/
-//& 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
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");
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),
}
-//& 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
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");
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));
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
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
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;
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
{
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 );
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
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 );
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
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
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);
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
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);
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
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);
}
-//& 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
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
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
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());
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.
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 );
/* 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());
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
{
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
* @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
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);
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,
*/
static gboolean gmain_loop_quit_idle(gpointer p)
{
-
+
g_main_loop_quit(g_pMainLoop);
return G_SOURCE_REMOVE;
}
* @return NA
*/
static void QuitGmainLoopIdle(bool result)
-{
+{
g_bResult = result;
g_idle_add(gmain_loop_quit_idle, NULL);
}
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;
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
/**
* @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));
&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);
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 */
if (IOTCON_ERROR_NONE != nRet) {
FPRINTF("iotcon_options_create() Fail(%d)", nRet);
iotcon_query_destroy(hquery);
- QuitGmainLoopIdle(false);
+ QuitGmainLoopIdle(false);
return;
}
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);
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;
* @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)
{
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));
}
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;
}
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
*/
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;
}
*/
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));
*/
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));
*/
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));
*/
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));
*/
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));
*/
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));
}
/** @} */
-/** @} */
\ No newline at end of file
+/** @} */
*/
static gboolean gmain_loop_quit_idle(gpointer p)
{
-
+
g_main_loop_quit(g_pMainLoop);
return G_SOURCE_REMOVE;
}
* @return NA
*/
static void QuitGmainLoopIdle(bool result)
-{
+{
g_bResult = result;
g_idle_add(gmain_loop_quit_idle, NULL);
}
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;
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));
&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);
/**
* @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
*/
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,
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,
* @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)
{
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;
* @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);
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);
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;
* @return NA
*/
int IotconCreateResourceLight(void)
-{
+{
iotcon_resource_types_h light_types = NULL;
iotcon_resource_interfaces_h light_ifaces;
int nIotconTimeoutId = 0;
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)
* @return NA
*/
int IotconCreateResourceLED(void)
-{
+{
iotcon_resource_types_h light_types = NULL;
iotcon_resource_interfaces_h light_ifaces;
int nIotconTimeoutId = 0;
* @description create light resource
* @parameter NA
* @return NA
-*/
+*/
int IotconCreateLightResource(void)
{
g_bCheckCb = false;
int nIotconTimeoutId = 0;
-
+
iotcon_resource_types_h hLightTypes = NULL;
IotconDestroyRes();
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));
* @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;
}
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));
}
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;
}
#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
{
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;
}
{
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;
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;
}
{
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;
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;
}
{
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();
}
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;
}
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();
}
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;
}
{
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();
}
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;
}
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);
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;
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;
}
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;
}
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;
}
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");
int ITc_iotcon_resource_types_add_remove_p(void)
{
START_TEST;
-
+
iotcon_resource_types_h hTypes = NULL;
int nRet = iotcon_resource_types_create(&hTypes);
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;
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");
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 );
int ITc_iotcon_resource_types_clone_p(void)
{
START_TEST;
-
+
iotcon_resource_types_h hTypes1, hTypes2;
int nRet = iotcon_resource_types_create(&hTypes1);
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);
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
+/** @} */
//
#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 )\
* @return gboolean
*/
static gboolean gmain_loop_quit_idle(gpointer p)
-{
+{
g_main_loop_quit(g_loop);
return G_SOURCE_REMOVE;
}
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()
{
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));
/**
* @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
*/
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);
* @function CreateAndFindResource
* @description Function to create and find resource
* @parameter NA
-* @return intiger : 0 if sussess
+* @return intiger : 0 if sussess
*/
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)
{
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)
{
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;
/**
* @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)
{
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));
}
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;
return;
}
}
-
+
return;
}
* @return NA
*/
void ITs_iotcon_response_cleanup(void)
-{
+{
if (g_hRemoteResourceResp) {
iotcon_remote_resource_destroy(g_hRemoteResourceResp);
g_hRemoteResourceResp = NULL;
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
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
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);
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.
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
{
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
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;
}
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;
}
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));
}
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)
{
}
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);
*/
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;
}
int ITc_iotcon_state_create_destroy_p(void)
{
START_TEST;
-
+
iotcon_state_h hState = NULL;
int nRet = iotcon_state_create(&hState);
iotcon_state_destroy(hState);
hState = NULL;
-
+
return 0;
}
int ITc_iotcon_state_clone_p(void)
{
START_TEST;
-
+
iotcon_state_h hState = NULL;
int nRet = iotcon_state_clone(g_hState, &hState);
iotcon_state_destroy(hState);
hState = NULL;
-
+
return 0;
}
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));
int ITc_iotcon_state_add_get_bool_p(void)
{
START_TEST;
-
+
bool bSetBoolVal = true;
bool bGetBoolVal;
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;
}
int ITc_iotcon_state_add_get_double_p(void)
{
START_TEST;
-
+
double nSetdoubleVal = 3.4;
double nGetdoubleVal;
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;
}
int ITc_iotcon_state_add_get_str_p(void)
{
START_TEST;
-
+
char *GetValue;
int nRet = iotcon_state_add_str(g_hState, KEY, VALUE);
nRet = iotcon_state_remove(g_hState, KEY);
PRINT_RESULT_NORETURN(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
-
+
return 0;
}
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;
}
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));
int ITc_iotcon_state_add_is_null_p(void)
{
START_TEST;
-
+
bool bVal;
int nRet = iotcon_state_add_null(g_hState, KEY);
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));
* @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
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));
nRet = iotcon_state_remove(g_hState, KEY);
PRINT_RESULT(IOTCON_ERROR_NONE, nRet, "iotcon_state_remove", IotConGetError(nRet));
-
+
return 0;
}
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);
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));
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");
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));
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;
}
int ITc_iotcon_state_get_keys_count_p(void)
{
START_TEST;
-
+
unsigned int nCount =0;
iotcon_state_h hState1, hState2;
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;
}
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
+/** @} */
+
{"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},