/**
* @brief Finds resources, asynchronously.
- * @details Request to find a resource of @a host_address server with @a resource_type.\n
+ * @details Request to find a resource of @a host_address server with @a query.\n
* @a host_address could be #IOTCON_MULTICAST_ADDRESS for multicast.\n
* If succeed to find the resource, iotcon_found_resource_cb() will be invoked with
* information of the resource.
* @privlevel public
* @privilege %http://tizen.org/privilege/internet
*
- * @remarks The length of @a resource_type should be less than or equal to 61.\n
- * The @a resource_type must start with a lowercase alphabetic character, followed by a sequence
- * of lowercase alphabetic, numeric, ".", or "-" characters, and contains no white space.
+ * @remarks @a host_address should be in the format coap://address:port.\n
+ * (ex. coaps://[fe80::ae5a:14ff:fe24:b8fe]:12345, or coaps://192.168.1.10:12345)
*
* @param[in] host_address The address or addressable name of server
* @param[in] connectivity_type The connectivity type
- * @param[in] resource_type The resource type specified as a filter for the resource
- * @param[in] is_secure The flag for secure communication with the server
+ * @param[in] query The query specified as a filter for the resource
* @param[in] cb The callback function to invoke
* @param[in] user_data The user data to pass to the function
*
*/
int iotcon_find_resource(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
- const char *resource_type,
- bool is_secure,
+ iotcon_query_h query,
iotcon_found_resource_cb cb,
void *user_data);
* @privlevel public
* @privilege %http://tizen.org/privilege/internet
*
+ * @remarks @a host_address should be in the format coap://address:port.\n
+ * (ex. coap://[fe80::ae5a:14ff:fe24:b8fe]:12345, or coap://192.168.1.10:12345)
+ *
* @param[in] host_address The host address of remote server
* @param[in] connectivity_type The connectivity type
+ * @param[in] query The query specified as a filter for the device information
* @param[in] cb The callback function to invoke
* @param[in] user_data The user data to pass to the function
*
*/
int iotcon_find_device_info(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
+ iotcon_query_h query,
iotcon_device_info_cb cb,
void *user_data);
* @privlevel public
* @privilege %http://tizen.org/privilege/internet
*
+ * @remarks @a host_address should be in the format coap://address:port.\n
+ * (ex. coap://[fe80::ae5a:14ff:fe24:b8fe]:12345, or coap://192.168.1.10:12345)
+ *
* @param[in] host_address The host address of remote server
* @param[in] connectivity_type The connectivity type
+ * @param[in] query The query specified as a filter for the platform information
* @param[in] cb The callback function to invoke
* @param[in] user_data The user data to pass to the function
*
*/
int iotcon_find_platform_info(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
+ iotcon_query_h query,
iotcon_platform_info_cb cb,
void *user_data);
*
* @since_tizen 3.0
*
- * @remarks @a type must not be released using free().
+ * @remarks @a resource_type must not be released using free().
+ * @a resource_type must start with a lowercase alphabetic character, followed by a sequence
+ * of lowercase alphabetic, numeric, ".", or "-" characters, and contains no white space.
*
* @param[in] query The handle of the query
* @param[out] resource_type Found resource type from query
#define IC_OBSERVE_ID_MAX_LEN 256
-#define IC_IOTY_COAP "coap://"
-#define IC_IOTY_COAPS "coaps://"
-#define IC_IOTY_MULTICAST_ADDRESS "224.0.1.187:5683"
+#define IC_COAP "coap://"
+#define IC_COAPS "coaps://"
+#define IC_COAP_PREFIX "coap"
+#define IC_MULTICAST_ADDRESS "224.0.1.187:5683"
#endif /* __IOTCON_INTERNAL_COMMON_H__ */
API int iotcon_find_device_info(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
+ iotcon_query_h query,
iotcon_device_info_cb cb,
void *user_data)
{
case IOTCON_CONNECTIVITY_IPV4:
case IOTCON_CONNECTIVITY_IPV6:
case IOTCON_CONNECTIVITY_ALL:
- ret = icl_ioty_find_device_info(host_address, connectivity_type, cb, user_data);
+ ret = icl_ioty_find_device_info(host_address, connectivity_type, query, cb,
+ user_data);
if (IOTCON_ERROR_NONE != ret) {
ERR("icl_ioty_find_device_info() Fail(%d)", ret);
return ret;
API int iotcon_find_platform_info(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
+ iotcon_query_h query,
iotcon_platform_info_cb cb,
void *user_data)
{
case IOTCON_CONNECTIVITY_IPV4:
case IOTCON_CONNECTIVITY_IPV6:
case IOTCON_CONNECTIVITY_ALL:
- ret = icl_ioty_find_platform_info(host_address, connectivity_type, cb, user_data);
+ ret = icl_ioty_find_platform_info(host_address, connectivity_type, query, cb,
+ user_data);
if (IOTCON_ERROR_NONE != ret) {
ERR("icl_ioty_find_platform_info() Fail(%d)", ret);
return ret;
#include "iotcon.h"
#include "ic.h"
+#include "ic-utils.h"
+#include "ic-common.h"
#include "ic-list.h"
#include "ic-value.h"
#include "ic-options.h"
int ic_ioty_convert_connectivity(const char *host_address, int conn_type,
OCDevAddr *dev_addr)
{
+ int index = 0;
char host[PATH_MAX] = {0};
char *dev_host, *ptr = NULL;
RETV_IF(NULL == dev_addr, IOTCON_ERROR_INVALID_PARAMETER);
- snprintf(host, sizeof(host), "%s", host_address);
+ if (IC_EQUAL == strncmp(IC_COAPS, host_address, strlen(IC_COAPS)))
+ index = strlen(IC_COAPS);
+ else if (IC_EQUAL == strncmp(IC_COAP, host_address, strlen(IC_COAP)))
+ index = strlen(IC_COAP);
+
+ snprintf(host, sizeof(host), "%s", &host_address[index]);
switch (conn_type) {
case IOTCON_CONNECTIVITY_IPV4:
{
int connectivity_type;
char host_addr[PATH_MAX] = {0};
+ const char *coap_str;
RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == conn_type, IOTCON_ERROR_INVALID_PARAMETER);
- connectivity_type = _ioty_parse_oic_transport(dev_addr->adapter,
- dev_addr->flags);
+ connectivity_type = _ioty_parse_oic_transport(dev_addr->adapter, dev_addr->flags);
+
+ if (OC_FLAG_SECURE & dev_addr->flags)
+ coap_str = IC_COAPS;
+ else
+ coap_str = IC_COAP;
switch (connectivity_type) {
case IOTCON_CONNECTIVITY_IPV6:
- snprintf(host_addr, sizeof(host_addr), "[%s]:%d", dev_addr->addr,
+ snprintf(host_addr, sizeof(host_addr), "%s[%s]:%d", coap_str, dev_addr->addr,
dev_addr->port);
break;
case IOTCON_CONNECTIVITY_IPV4:
- snprintf(host_addr, sizeof(host_addr), "%s:%d", dev_addr->addr,
+ snprintf(host_addr, sizeof(host_addr), "%s%s:%d", coap_str, dev_addr->addr,
dev_addr->port);
break;
default:
return IOTCON_ERROR_NONE;
}
-iotcon_response_result_e ic_ioty_parse_oic_response_result(OCStackResult result)
+iotcon_response_result_e ic_ioty_parse_oic_response_result(OCStackResult result)
{
switch (result) {
case OC_STACK_OK:
g_idle_add(_icl_ioty_free_cb_data_idle_cb, cb_info);
}
+static char* _icl_ioty_resource_generate_uri(const char *uri_path, iotcon_query_h query)
+{
+ int len;
+ bool loop_first = true;
+ char uri_buf[PATH_MAX] = {0};
+ GHashTableIter iter;
+ gpointer key, value;
+
+ RETV_IF(NULL == uri_path, NULL);
+
+ if (NULL == query || NULL == query->hash)
+ return strdup(uri_path);
+
+ len = snprintf(uri_buf, sizeof(uri_buf), "%s", uri_path);
+
+ /* remove suffix '/' */
+ if ('/' == uri_buf[strlen(uri_buf) - 1]) {
+ uri_buf[strlen(uri_buf) - 1] = '\0';
+ len--;
+ }
+
+ if (query->hash) {
+ g_hash_table_iter_init(&iter, query->hash);
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ int query_len;
+ DBG("query exist. key(%s), value(%s)", key, value);
+
+ if (true == loop_first) {
+ query_len = snprintf(uri_buf + len, sizeof(uri_buf) - len, "?%s=%s",
+ (char *)key, (char *)value);
+ loop_first = false;
+ } else {
+ query_len = snprintf(uri_buf + len, sizeof(uri_buf) - len, ";%s=%s",
+ (char *)key, (char *)value);
+ }
+ len += query_len;
+ }
+ }
+
+ return strdup(uri_buf);
+}
+
int icl_ioty_find_resource(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
- const char *resource_type,
- bool is_secure,
+ iotcon_query_h query,
iotcon_found_resource_cb cb,
void *user_data)
{
FN_CALL;
- int ret, len, timeout;
+ int ret, timeout;
char *coap_str;
+ char *full_uri;
char uri[PATH_MAX] = {0};
icl_cb_s *cb_data;
OCDoHandle handle;
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
- coap_str = is_secure ? IC_IOTY_COAPS : IC_IOTY_COAP;
+ if (IC_EQUAL != strncmp(IC_COAP_PREFIX, host_address, strlen(IC_COAP_PREFIX)))
+ coap_str = IC_COAPS;
if (NULL == host_address) {
- len = snprintf(uri, sizeof(uri), "%s", OC_RSRVD_WELL_KNOWN_URI);
+ snprintf(uri, sizeof(uri), "%s", OC_RSRVD_WELL_KNOWN_URI);
+ } else if (NULL == coap_str) {
+ snprintf(uri, sizeof(uri), "%s%s", host_address, OC_RSRVD_WELL_KNOWN_URI);
} else {
- len = snprintf(uri, sizeof(uri), "%s%s%s", coap_str, host_address,
+ snprintf(uri, sizeof(uri), "%s%s%s", coap_str, host_address,
OC_RSRVD_WELL_KNOWN_URI);
}
- if (len <= 0 || sizeof(uri) <= len) {
- ERR("snprintf() Fail(%d)", len);
- return IOTCON_ERROR_IO_ERROR;
- }
- if (resource_type)
- snprintf(uri + len, sizeof(uri) - len, "?rt=%s", resource_type);
+ full_uri = _icl_ioty_resource_generate_uri(uri, query);
+ if (NULL == full_uri) {
+ ERR("_icl_ioty_resource_generate_uri() Fail");
+ return IOTCON_ERROR_INVALID_PARAMETER;
+ }
cb_data = calloc(1, sizeof(icl_cb_s));
if (NULL == cb_data) {
ERR("calloc() Fail(%d)", errno);
+ free(full_uri);
return IOTCON_ERROR_OUT_OF_MEMORY;
}
cb_data->op = ICL_FIND_RESOURCE;
if (IOTCON_ERROR_NONE != ret) {
ERR("icl_ioty_mutex_lock() Fail(%d)", ret);
_icl_ioty_free_cb_data(cb_data);
+ free(full_uri);
return ret;
}
// TODO: QoS is come from lib.
- ret = OCDoResource(&handle, OC_REST_DISCOVER, uri, NULL, NULL, oic_conn_type,
+ ret = OCDoResource(&handle, OC_REST_DISCOVER, full_uri, NULL, NULL, oic_conn_type,
OC_LOW_QOS, &cbdata, NULL, 0);
icl_ioty_mutex_unlock();
- cb_data->handle = handle;
if (OC_STACK_OK != ret) {
ERR("OCDoResource(DISCOVER) Fail(%d)", ret);
_icl_ioty_free_cb_data(cb_data);
+ free(full_uri);
return ic_ioty_parse_oic_error(ret);
}
+ free(full_uri);
+ cb_data->handle = handle;
iotcon_get_timeout(&timeout);
cb_data->timeout = g_timeout_add_seconds(timeout, _icl_ioty_timeout, cb_data);
int icl_ioty_find_device_info(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
+ iotcon_query_h query,
iotcon_device_info_cb cb,
void *user_data)
{
int ret, timeout;
+ char *coap_str;
+ char *full_uri;
char uri[PATH_MAX] = {0};
icl_cb_s *cb_data = NULL;
OCDoHandle handle;
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+ if (IC_EQUAL != strncmp(IC_COAP_PREFIX, host_address, strlen(IC_COAP_PREFIX)))
+ coap_str = IC_COAP;
+
if (NULL == host_address)
snprintf(uri, sizeof(uri), "%s", OC_RSRVD_DEVICE_URI);
- else
+ else if (NULL == coap_str)
snprintf(uri, sizeof(uri), "%s%s", host_address, OC_RSRVD_DEVICE_URI);
+ else
+ snprintf(uri, sizeof(uri), "%s%s%s", coap_str, host_address, OC_RSRVD_DEVICE_URI);
+
+ full_uri = _icl_ioty_resource_generate_uri(uri, query);
+ if (NULL == full_uri) {
+ ERR("_icl_ioty_resource_generate_uri() Fail");
+ return IOTCON_ERROR_INVALID_PARAMETER;
+ }
cb_data = calloc(1, sizeof(icl_cb_s));
if (NULL == cb_data) {
ERR("calloc() Fail(%d)", errno);
+ free(full_uri);
return IOTCON_ERROR_OUT_OF_MEMORY;
}
cb_data->cb = cb;
if (IOTCON_ERROR_NONE != ret) {
ERR("icl_ioty_mutex_lock() Fail(%d)", ret);
_icl_ioty_free_cb_data(cb_data);
+ free(full_uri);
return ret;
}
// TODO: QoS is come from lib. And user can set QoS to client structure.
- ret = OCDoResource(&handle, OC_REST_DISCOVER, uri, NULL, NULL, oic_conn_type,
+ ret = OCDoResource(&handle, OC_REST_DISCOVER, full_uri, NULL, NULL, oic_conn_type,
OC_LOW_QOS, &cbdata, NULL, 0);
icl_ioty_mutex_unlock();
- cb_data->handle = handle;
if (OC_STACK_OK != ret) {
ERR("OCDoResource(DISCOVER) Fail(%d)", ret);
_icl_ioty_free_cb_data(cb_data);
+ free(full_uri);
return ic_ioty_parse_oic_error(ret);
}
+ cb_data->handle = handle;
iotcon_get_timeout(&timeout);
cb_data->timeout = g_timeout_add_seconds(timeout, _icl_ioty_timeout, cb_data);
int icl_ioty_find_platform_info(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
+ iotcon_query_h query,
iotcon_platform_info_cb cb,
void *user_data)
{
int ret, timeout;
+ char *coap_str;
+ char *full_uri;
char uri[PATH_MAX] = {0};
icl_cb_s *cb_data = NULL;
OCDoHandle handle;
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
+ if (IC_EQUAL != strncmp(IC_COAP_PREFIX, host_address, strlen(IC_COAP_PREFIX)))
+ coap_str = IC_COAP;
+
if (NULL == host_address)
snprintf(uri, sizeof(uri), "%s", OC_RSRVD_PLATFORM_URI);
- else
+ else if (NULL == coap_str)
snprintf(uri, sizeof(uri), "%s%s", host_address, OC_RSRVD_PLATFORM_URI);
+ else
+ snprintf(uri, sizeof(uri), "%s%s%s", coap_str, host_address, OC_RSRVD_PLATFORM_URI);
+
+ full_uri = _icl_ioty_resource_generate_uri(uri, query);
+ if (NULL == full_uri) {
+ ERR("_icl_ioty_resource_generate_uri() Fail");
+ return IOTCON_ERROR_INVALID_PARAMETER;
+ }
cb_data = calloc(1, sizeof(icl_cb_s));
if (NULL == cb_data) {
ERR("calloc() Fail(%d)", errno);
+ free(full_uri);
return IOTCON_ERROR_OUT_OF_MEMORY;
}
cb_data->cb = cb;
if (IOTCON_ERROR_NONE != ret) {
ERR("icl_ioty_mutex_lock() Fail(%d)", ret);
_icl_ioty_free_cb_data(cb_data);
+ free(full_uri);
return ret;
}
// TODO: QoS is come from lib. And user can set QoS to client structure.
- ret = OCDoResource(&handle, OC_REST_DISCOVER, uri, NULL, NULL, oic_conn_type,
+ ret = OCDoResource(&handle, OC_REST_DISCOVER, full_uri, NULL, NULL, oic_conn_type,
OC_LOW_QOS, &cbdata, NULL, 0);
icl_ioty_mutex_unlock();
- cb_data->handle = handle;
if (OC_STACK_OK != ret) {
ERR("OCDoResource(DISCOVER) Fail(%d)", ret);
_icl_ioty_free_cb_data(cb_data);
+ free(full_uri);
return ic_ioty_parse_oic_error(ret);
}
+ cb_data->handle = handle;
iotcon_get_timeout(&timeout);
cb_data->timeout = g_timeout_add_seconds(timeout, _icl_ioty_timeout, cb_data);
iotcon_presence_h *presence_handle)
{
int ret;
+ int index = 0;
OCDoHandle handle;
const char *address;
char uri[PATH_MAX] = {0};
RETV_IF(NULL == presence_handle, IOTCON_ERROR_INVALID_PARAMETER);
if (NULL == host_address)
- address = IC_IOTY_MULTICAST_ADDRESS;
+ address = IC_MULTICAST_ADDRESS;
else
address = host_address;
- snprintf(uri, sizeof(uri), "%s%s", address, OC_RSRVD_PRESENCE_URI);
+ if (IC_EQUAL == strncmp(IC_COAPS, host_address, strlen(IC_COAPS)))
+ index = strlen(IC_COAPS);
+ else if (IC_EQUAL == strncmp(IC_COAP, host_address , strlen(IC_COAP)))
+ index = strlen(IC_COAP);
+
+ snprintf(uri, sizeof(uri), "%s%s", &address[index], OC_RSRVD_PRESENCE_URI);
presence = calloc(1, sizeof(struct icl_presence));
if (NULL == presence) {
return IOTCON_ERROR_NONE;
}
-static char* _icl_ioty_resource_generate_uri(char *uri_path, GHashTable *hash)
-{
- int len;
- bool loop_first = true;
- char uri_buf[PATH_MAX] = {0};
- GHashTableIter iter;
- gpointer key, value;
-
- RETV_IF(NULL == uri_path, NULL);
-
- len = snprintf(uri_buf, sizeof(uri_buf), "%s", uri_path);
-
- /* remove suffix '/' */
- if ('/' == uri_buf[strlen(uri_buf) - 1]) {
- uri_buf[strlen(uri_buf) - 1] = '\0';
- len--;
- }
-
- if (hash) {
- g_hash_table_iter_init(&iter, hash);
- while (g_hash_table_iter_next(&iter, &key, &value)) {
- int query_len;
- DBG("query exist. key(%s), value(%s)", key, value);
-
- if (true == loop_first) {
- query_len = snprintf(uri_buf + len, sizeof(uri_buf) - len, "?%s=%s",
- (char *)key, (char *)value);
- loop_first = false;
- } else {
- query_len = snprintf(uri_buf + len, sizeof(uri_buf) - len, ";%s=%s",
- (char *)key, (char *)value);
- }
- len += query_len;
- }
- }
-
- return strdup(uri_buf);
-}
-
static void _icl_ioty_free_observe_container(void *data)
{
icl_observe_container_s *cb_container = data;
OCConnectivityType oic_conn_type;
OCHeaderOption *oic_options_ptr = NULL;
OCHeaderOption oic_options[MAX_HEADER_OPTIONS];
- GHashTable *query_hash;
icl_observe_container_s *cb_container;
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
/* uri */
- query_hash = (query && query->hash) ? query->hash : NULL;
- uri = _icl_ioty_resource_generate_uri(resource->uri_path, query_hash);
+ uri = _icl_ioty_resource_generate_uri(resource->uri_path, query);
if (NULL == uri) {
- ERR("_icd_ioty_resource_generate_uri() Fail");
+ ERR("_icl_ioty_resource_generate_uri() Fail");
return IOTCON_ERROR_INVALID_PARAMETER;
}
FN_CALL;
int ret, timeout, options_size = 0;
char *uri;
- GHashTable *query_hash;
icl_response_container_s *cb_container;
OCCallbackData cbdata = {0};
OCHeaderOption *oic_options_ptr = NULL;
/* method (request type) */
method = ic_ioty_convert_request_type(req_type);
- /* uri */
- query_hash = (query && query->hash) ? query->hash : NULL;
-
- uri = _icl_ioty_resource_generate_uri(resource->uri_path, query_hash);
+ uri = _icl_ioty_resource_generate_uri(resource->uri_path, query);
if (NULL == uri) {
ERR("_icl_ioty_resource_generate_uri() Fail");
return IOTCON_ERROR_INVALID_PARAMETER;
/* client APIs */
int icl_ioty_find_resource(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
- const char *resource_type,
- bool is_secure,
+ iotcon_query_h query,
iotcon_found_resource_cb cb,
void *user_data);
int icl_ioty_find_device_info(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
+ iotcon_query_h query,
iotcon_device_info_cb cb,
void *user_data);
int icl_ioty_find_platform_info(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
+ iotcon_query_h query,
iotcon_platform_info_cb cb,
void *user_data);
return ret;
}
- snprintf(uri, sizeof(uri), "%s%s%s", IC_IOTY_COAP, host_address, version_uri);
+ snprintf(uri, sizeof(uri), "%s%s%s", IC_COAP, host_address, version_uri);
DBG("uri : %s", uri);
cbdata.cb = _provisioning_find_security_version_cb;
return ret;
}
- snprintf(uri, sizeof(uri), "%s%s%s", IC_IOTY_COAP, host_address,
+ snprintf(uri, sizeof(uri), "%s%s%s", IC_COAP, host_address,
OC_RSRVD_WELL_KNOWN_URI);
cbdata.cb = _provisioning_find_secure_port_cb;
return ret;
}
- snprintf(uri, sizeof(uri), "%s%s%s?%s=%s", IC_IOTY_COAPS, host_address, cred_uri,
+ snprintf(uri, sizeof(uri), "%s%s%s?%s=%s", IC_COAPS, host_address, cred_uri,
subject_uuid, container->cb_data->device_id);
free(host_address);
* If resource_type is NULL, then All resources in host are discovered. */
API int iotcon_find_resource(const char *host_address,
iotcon_connectivity_type_e connectivity_type,
- const char *resource_type,
- bool is_secure,
+ iotcon_query_h query,
iotcon_found_resource_cb cb,
void *user_data)
{
RETV_IF(false == ic_utils_check_permission(IC_PERMISSION_INTERNET),
IOTCON_ERROR_PERMISSION_DENIED);
RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
- RETV_IF(resource_type && (false == icl_resource_check_type(resource_type)),
- IOTCON_ERROR_INVALID_PARAMETER);
switch (connectivity_type) {
case IOTCON_CONNECTIVITY_IPV4:
case IOTCON_CONNECTIVITY_IPV6:
case IOTCON_CONNECTIVITY_ALL:
- ret = icl_ioty_find_resource(host_address, connectivity_type, resource_type,
- is_secure, cb, user_data);
+ ret = icl_ioty_find_resource(host_address, connectivity_type, query, cb,
+ user_data);
if (IOTCON_ERROR_NONE != ret) {
ERR("icl_ioty_find_resource() Fail(%d)", ret);
return ret;
iotcon_remote_resource_h *resource_handle)
{
FN_CALL;
+ char temp[PATH_MAX] = {0};
iotcon_remote_resource_h resource = NULL;
RETV_IF(false == ic_utils_check_ocf_feature(), IOTCON_ERROR_NOT_SUPPORTED);
RETVM_IF(IOTCON_CONNECTIVITY_ALL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER,
"Should use specific connectivity type of the remote resource");
+ if (IC_EQUAL == strncmp(IC_COAP_PREFIX, host_address, strlen(IC_COAP_PREFIX)))
+ snprintf(temp, sizeof(temp), "%s", host_address);
+ else if (policies & IOTCON_RESOURCE_SECURE)
+ snprintf(temp, sizeof(temp), "%s%s", IC_COAPS, host_address);
+ else
+ snprintf(temp, sizeof(temp), "%s%s", IC_COAP, host_address);
+
resource = calloc(1, sizeof(struct icl_remote_resource));
if (NULL == resource) {
ERR("calloc() Fail(%d)", errno);
return IOTCON_ERROR_OUT_OF_MEMORY;
}
- resource->host_address = ic_utils_strdup(host_address);
+ resource->host_address = ic_utils_strdup(temp);
resource->connectivity_type = connectivity_type;
resource->uri_path = ic_utils_strdup(uri_path);
resource->policies = policies;
FN_CALL;
int ret;
GMainLoop *loop;
+ iotcon_query_h query;
loop = g_main_loop_new(NULL, FALSE);
return -1;
}
+ ret = iotcon_query_create(&query);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_query_create() Fail(%d)", ret);
+ return -1;
+ }
+
+ ret = iotcon_query_set_resource_type(query, DOOR_RESOURCE_TYPE);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_query_set_resource_type() Fail(%d)", ret);
+ iotcon_query_destroy(query);
+ return -1;
+ }
+
/* find door typed resources */
ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_ALL,
- DOOR_RESOURCE_TYPE, true, _found_resource, NULL);
+ query, _found_resource, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_resource() Fail(%d)", ret);
+ iotcon_query_destroy(query);
iotcon_deinitialize();
return -1;
}
+ iotcon_query_destroy(query);
+
g_main_loop_run(loop);
g_main_loop_unref(loop);
return;
}
-
door = user_data;
if (IOTCON_REQUEST_GET == type)
}
ret = iotcon_find_device_info(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_ALL,
- _request_device_info, NULL);
+ NULL, _request_device_info, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_device_info() Fail(%d)", ret);
iotcon_deinitialize();
}
ret = iotcon_find_platform_info(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_ALL,
- _request_platform_info, NULL);
+ NULL, _request_platform_info, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_platform_info() Fail(%d)", ret);
iotcon_deinitialize();
FN_CALL;
int ret;
GMainLoop *loop;
+ iotcon_query_h query;
iotcon_remote_resource_h resource;
loop = g_main_loop_new(NULL, FALSE);
return -1;
}
+ ret = iotcon_query_create(&query);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_query_create() Fail(%d)", ret);
+ return -1;
+ }
+
+ ret = iotcon_query_set_resource_type(query, DOOR_RESOURCE_TYPE);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_query_set_resource_type() Fail(%d)", ret);
+ iotcon_query_destroy(query);
+ return -1;
+ }
+
/* find door typed resources */
ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_ALL,
- DOOR_RESOURCE_TYPE, true, _found_resource, &resource);
+ query, _found_resource, &resource);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_resource() Fail(%d)", ret);
+ iotcon_query_destroy(query);
iotcon_deinitialize();
return -1;
}
+ iotcon_query_destroy(query);
+
g_main_loop_run(loop);
g_main_loop_unref(loop);
FN_CALL;
int ret;
GMainLoop *loop;
+ iotcon_query_h query;
loop = g_main_loop_new(NULL, FALSE);
return -1;
}
+ ret = iotcon_query_create(&query);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_query_create() Fail(%d)", ret);
+ return -1;
+ }
+
+ ret = iotcon_query_set_resource_type(query, ROOM_RESOURCE_TYPE);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_query_set_resource_type() Fail(%d)", ret);
+ iotcon_query_destroy(query);
+ return -1;
+ }
+
/* find room typed resources */
ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_ALL,
- ROOM_RESOURCE_TYPE, true, _found_resource, NULL);
+ query, _found_resource, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_resource() Fail(%d)", ret);
+ iotcon_query_destroy(query);
iotcon_deinitialize();
return -1;
}
+ iotcon_query_destroy(query);
+
g_main_loop_run(loop);
g_main_loop_unref(loop);