</method>
<method name="findResource">
<arg type="s" name="host_address" direction="in"/>
+ <arg type="i" name="connectivity" direction="in"/>
<arg type="s" name="type" direction="in"/>
<arg type="u" name="signal_number" direction="in"/>
<arg type="i" name="ret" direction="out"/>
</method>
<method name="getDeviceInfo">
<arg type="s" name="host_address" direction="in"/>
+ <arg type="i" name="connectivity" direction="in"/>
<arg type="u" name="signal_number" direction="in"/>
<arg type="i" name="ret" direction="out"/>
</method>
<method name="getPlatformInfo">
<arg type="s" name="host_address" direction="in"/>
+ <arg type="i" name="connectivity" direction="in"/>
<arg type="u" name="signal_number" direction="in"/>
<arg type="i" name="ret" direction="out"/>
</method>
<method name="getTizenInfo">
<arg type="s" name="host_address" direction="in"/>
+ <arg type="i" name="connectivity" direction="in"/>
<arg type="(ssi)" name="ret" direction="out"/>
</method>
<method name="subscribePresence">
<arg type="s" name="host_address" direction="in"/>
+ <arg type="i" name="connectivity" direction="in"/>
<arg type="s" name="type" direction="in"/>
<arg type="u" name="signal_number" direction="in"/>
<arg type="x" name="presence_h" direction="out"/>
static gboolean _dbus_handle_find_resource(icDbus *object,
GDBusMethodInvocation *invocation,
const gchar *host_address,
+ gint connectivity,
const gchar *type,
guint signal_number)
{
const gchar *sender;
sender = g_dbus_method_invocation_get_sender(invocation);
- ret = icd_ioty_find_resource(host_address, type, signal_number, sender);
+ ret = icd_ioty_find_resource(host_address, connectivity, type, signal_number, sender);
if (IOTCON_ERROR_NONE != ret)
ERR("icd_ioty_find_resource() Fail(%d)", ret);
static gboolean _dbus_handle_get_device_info(icDbus *object,
GDBusMethodInvocation *invocation,
const gchar *host_address,
+ gint connectivity,
guint signal_number)
{
int ret;
const gchar *sender;
sender = g_dbus_method_invocation_get_sender(invocation);
- ret = icd_ioty_get_info(ICD_DEVICE_INFO, host_address, signal_number, sender);
+ ret = icd_ioty_get_info(ICD_DEVICE_INFO, host_address, connectivity, signal_number,
+ sender);
if (IOTCON_ERROR_NONE != ret)
ERR("icd_ioty_get_info(device info) Fail(%d)", ret);
static gboolean _dbus_handle_get_platform_info(icDbus *object,
GDBusMethodInvocation *invocation,
const gchar *host_address,
+ gint connectivity,
guint signal_number)
{
int ret;
const gchar *sender;
sender = g_dbus_method_invocation_get_sender(invocation);
- ret = icd_ioty_get_info(ICD_PLATFORM_INFO, host_address, signal_number, sender);
+ ret = icd_ioty_get_info(ICD_PLATFORM_INFO, host_address, connectivity, signal_number,
+ sender);
if (IOTCON_ERROR_NONE != ret)
ERR("icd_ioty_get_info(platform info) Fail(%d)", ret);
static gboolean _dbus_handle_subscribe_presence(icDbus *object,
GDBusMethodInvocation *invocation,
const gchar *host_address,
+ gint connectivity,
const gchar *type,
guint signal_number)
{
const gchar *sender;
sender = g_dbus_method_invocation_get_sender(invocation);
- presence_h = icd_ioty_subscribe_presence(host_address, type, signal_number, sender);
+ presence_h = icd_ioty_subscribe_presence(host_address, connectivity, type,
+ signal_number, sender);
if (NULL == presence_h)
ERR("icd_ioty_subscribe_presence() Fail");
static int _worker_req_handler(void *context)
{
- int ret;
GVariant *value;
+ int ret, conn_type;
struct icd_req_context *ctx = context;
GVariantBuilder payload_builder;
char addr[PATH_MAX] = {0};
if (ctx->dev_addr->addr && *ctx->dev_addr->addr)
snprintf(addr, sizeof(addr), "%s:%d", ctx->dev_addr->addr, ctx->dev_addr->port);
- value = g_variant_new("(sia(qs)a(ss)iiavxx)",
+ conn_type = icd_ioty_transport_flag_to_conn_type(ctx->dev_addr->adapter,
+ ctx->dev_addr->flags);
+
+ value = g_variant_new("(siia(qs)a(ss)iiavxx)",
addr,
+ conn_type,
ctx->types,
ctx->options,
ctx->query,
}
-int icd_ioty_find_resource(const char *host_address, const char *resource_type,
- unsigned int signum, const char *bus_name)
+int icd_ioty_find_resource(const char *host_address, int conn_type,
+ const char *resource_type, unsigned int signum, const char *bus_name)
{
int len;
OCStackResult result;
char uri[PATH_MAX] = {0};
OCCallbackData cbdata = {0};
OCConnectivityType oic_conn_type;
- iotcon_connectivity_type_e conn_type = IOTCON_CONNECTIVITY_IPV4;
if (IC_STR_EQUAL == strcmp(IOTCON_MULTICAST_ADDRESS, host_address)) {
len = snprintf(uri, sizeof(uri), "%s", OC_RSRVD_WELL_KNOWN_URI);
}
-int icd_ioty_get_info(int type, const char *host_address, unsigned int signal_number,
- const char *bus_name)
+int icd_ioty_get_info(int type, const char *host_address, int conn_type,
+ unsigned int signal_number, const char *bus_name)
{
OCStackResult result;
icd_sig_ctx_s *context;
OCCallbackData cbdata = {0};
char uri[PATH_MAX] = {0};
char *uri_path = NULL;
- iotcon_connectivity_type_e conn_type = IOTCON_CONNECTIVITY_IPV4;
OCConnectivityType oic_conn_type;
if (ICD_DEVICE_INFO == type)
gboolean icd_ioty_get_tizen_info(icDbus *object, GDBusMethodInvocation *invocation,
- const gchar *host_address)
+ const gchar *host_address, int conn_type)
{
OCStackResult result;
OCDevAddr dev_addr = {0};
OCConnectivityType oic_conn_type;
char host[PATH_MAX] = {0};
char *dev_host, *ptr = NULL;
- int conn_type = IOTCON_CONNECTIVITY_IPV4;
snprintf(host, sizeof(host), "%s", host_address);
}
-OCDoHandle icd_ioty_subscribe_presence(const char *host_address,
+OCDoHandle icd_ioty_subscribe_presence(const char *host_address, int conn_type,
const char *resource_type, unsigned int signal_number, const char *bus_name)
{
int len;
OCDoHandle handle;
OCStackResult result;
+ icd_sig_ctx_s *context;
char uri[PATH_MAX] = {0};
OCCallbackData cbdata = {0};
- icd_sig_ctx_s *context;
+ OCConnectivityType oic_conn_type;
len = snprintf(uri, sizeof(uri), "%s%s", host_address, OC_RSRVD_PRESENCE_URI);
if (len <= 0 || sizeof(uri) <= len) {
cbdata.cb = icd_ioty_ocprocess_presence_cb;
cbdata.cd = _ioty_free_signal_context;
+ oic_conn_type = icd_ioty_conn_type_to_oic_conn_type(conn_type);
+
/* In case of IPV4 or IPV6, connectivity type is CT_ADAPTER_IP in iotivity 0.9.2 */
+ if (CT_IP_USE_V4 == oic_conn_type && CT_IP_USE_V6 == oic_conn_type)
+ oic_conn_type = CT_ADAPTER_IP;
+
icd_ioty_csdk_lock();
result = OCDoResource(&handle, OC_REST_PRESENCE, uri, NULL, NULL, CT_ADAPTER_IP,
OC_LOW_QOS, &cbdata, NULL, 0);
int icd_ioty_send_response(GVariant *resp);
-int icd_ioty_find_resource(const char *host_address, const char *resource_type,
- unsigned int signal_number, const char *bus_name);
+int icd_ioty_find_resource(const char *host_address, int conn_type,
+ const char *resource_type, unsigned int signal_number, const char *bus_name);
void icd_ioty_complete(int type, GDBusMethodInvocation *invocation, GVariant *value);
void icd_ioty_complete_error(int type, GDBusMethodInvocation *invocation, int ret_val);
char *support_url,
char *system_time);
-int icd_ioty_get_info(int type, const char *host_address, unsigned int signal_number,
- const char *bus_name);
+int icd_ioty_get_info(int type, const char *host_address, int conn_type,
+ unsigned int signal_number, const char *bus_name);
int icd_ioty_set_tizen_info();
gboolean icd_ioty_get_tizen_info(icDbus *object, GDBusMethodInvocation *invocation,
- const gchar *host_address);
+ const gchar *host_address, int conn_type);
int icd_ioty_tizen_info_get_property(char **device_name, char **tizen_device_id);
-OCDoHandle icd_ioty_subscribe_presence(const char *host_address,
+OCDoHandle icd_ioty_subscribe_presence(const char *host_address, int conn_type,
const char *resource_type, unsigned int signal_number, const char *bus_name);
int icd_ioty_unsubscribe_presence(OCDoHandle handle);
return;
}
- ret = iotcon_remote_resource_get_host(resource, &resource_host);
+ ret = iotcon_remote_resource_get_host_address(resource, &resource_host);
if (IOTCON_ERROR_NONE != ret) {
return;
}
int ret;
const char *type = "core.door";
- ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, type, &_found_resource, NULL);
+ ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4, type,
+ &_found_resource, NULL);
if (IOTCON_ERROR_NONE != ret) {
return;
}
}
value = g_variant_new("(ssba(qs)i)", resource->uri_path, resource->host,
- resource->is_secure, &options, resource->conn_type);
+ resource->is_secure, &options, resource->connectivity_type);
return value;
}
return G_SOURCE_REMOVE;
}
-API int iotcon_get_device_info(const char *host_address, iotcon_device_info_cb cb,
+API int iotcon_get_device_info(const char *host_address,
+ iotcon_connectivity_type_e connectivity_type,
+ iotcon_device_info_cb cb,
void *user_data)
{
GError *error = NULL;
signal_number = icl_dbus_generate_signal_number();
ic_dbus_call_get_device_info_sync(icl_dbus_get_object(), host_address,
- signal_number, &ret, NULL, &error);
+ connectivity_type, signal_number, &ret, NULL, &error);
if (error) {
ERR("ic_dbus_call_get_device_info_sync() Fail(%s)", error->message);
ret = icl_dbus_convert_dbus_error(error->code);
return G_SOURCE_REMOVE;
}
-API int iotcon_get_platform_info(const char *host_address, iotcon_platform_info_cb cb,
+API int iotcon_get_platform_info(const char *host_address,
+ iotcon_connectivity_type_e connectivity_type,
+ iotcon_platform_info_cb cb,
void *user_data)
{
GError *error = NULL;
signal_number = icl_dbus_generate_signal_number();
ic_dbus_call_get_platform_info_sync(icl_dbus_get_object(), host_address,
- signal_number, &ret, NULL, &error);
+ connectivity_type, signal_number, &ret, NULL, &error);
if (error) {
ERR("ic_dbus_call_get_platform_info_sync() Fail(%s)", error->message);
ret = icl_dbus_convert_dbus_error(error->code);
}
-API int iotcon_get_tizen_info(const char *host_address, iotcon_tizen_info_cb cb,
+API int iotcon_get_tizen_info(const char *host_address,
+ iotcon_connectivity_type_e connectivity_type,
+ iotcon_tizen_info_cb cb,
void *user_data)
{
icl_tizen_info_s *cb_container;
cb_container->cb = cb;
cb_container->user_data = user_data;
- ic_dbus_call_get_tizen_info(icl_dbus_get_object(), host_address, NULL,
- _icl_tizen_info_cb, cb_container);
+ ic_dbus_call_get_tizen_info(icl_dbus_get_object(), host_address, connectivity_type,
+ NULL, _icl_tizen_info_cb, cb_container);
return IOTCON_ERROR_NONE;
}
return;
}
- g_variant_get(parameters, "(ia(qs)a(ss)iiavxx)",
+ g_variant_get(parameters, "(siia(qs)a(ss)iiavxx)",
+ NULL, /* host address */
+ NULL, /* connectivity type */
&request_types,
- NULL, // &options,
- NULL, // &query,
- NULL, // &action,
- NULL, // &observer_id,
+ NULL, /* header options */
+ NULL, /* query */
+ NULL, /* observe action */
+ NULL, /* observer_id */
&repr_iter,
&oic_request_h,
&oic_resource_h);
/* The length of resource_type should be less than or equal to 61. */
-API int iotcon_subscribe_presence(const char *host_address, const char *resource_type,
- iotcon_presence_cb cb, void *user_data, iotcon_presence_h *presence_handle)
+API int iotcon_subscribe_presence(const char *host_address,
+ iotcon_connectivity_type_e connectivity_type,
+ const char *resource_type,
+ iotcon_presence_cb cb,
+ void *user_data,
+ iotcon_presence_h *presence_handle)
{
FN_CALL;
GError *error = NULL;
resource_type = ic_utils_dbus_encode_str(resource_type);
- ic_dbus_call_subscribe_presence_sync(icl_dbus_get_object(), host_address,
- resource_type, signal_number, &(presence_container->handle), NULL, &error);
+ ic_dbus_call_subscribe_presence_sync(icl_dbus_get_object(),
+ host_address,
+ connectivity_type,
+ resource_type,
+ signal_number,
+ &(presence_container->handle),
+ NULL,
+ &error);
if (error) {
ERR("ic_dbus_call_subscribe_presence_sync() Fail(%s)", error->message);
ret = icl_dbus_convert_dbus_error(error->code);
iotcon_remote_resource_state_changed_cb cb,
void *user_data)
{
- int ret;
char *host_address;
+ int ret, connectivity_type;
unsigned int get_timer_id;
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
resource->monitoring_handle->get_timer_id = get_timer_id;
/* Device Presence */
- ret = iotcon_remote_resource_get_host(resource, &host_address);
+ ret = iotcon_remote_resource_get_host_address(resource, &host_address);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_remote_resource_get_host_address() Fail(%d)", ret);
+ g_source_remove(resource->monitoring_handle->get_timer_id);
+ free(resource->monitoring_handle);
+ resource->monitoring_handle = NULL;
+ return ret;
+ }
+
+ ret = iotcon_remote_resource_get_connectivity_type(resource, &connectivity_type);
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_remote_resource_get_host() Fail(%d)", ret);
+ ERR("iotcon_remote_resource_get_connectivity_type() Fail(%d)", ret);
g_source_remove(resource->monitoring_handle->get_timer_id);
free(resource->monitoring_handle);
resource->monitoring_handle = NULL;
return ret;
}
- ret = iotcon_subscribe_presence(host_address, NULL, _monitoring_presence_cb, resource,
- &resource->monitoring_handle->presence);
+ ret = iotcon_subscribe_presence(host_address, connectivity_type, NULL,
+ _monitoring_presence_cb, resource, &resource->monitoring_handle->presence);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_subscribe_presence() Fail(%d)", ret);
g_source_remove(resource->monitoring_handle->get_timer_id);
} icl_found_resource_s;
static iotcon_remote_resource_h _icl_remote_resource_from_gvariant(GVariant *payload,
- iotcon_connectivity_type_e conn_type);
+ iotcon_connectivity_type_e connectivity_type);
static void _icl_found_resource_cb(GDBusConnection *connection,
const gchar *sender_name,
gpointer user_data)
{
FN_CALL;
- int conn_type;
+ int connectivity_type;
iotcon_remote_resource_h resource;
GVariant *payload;
cb_container->timeout_id = 0;
}
- g_variant_get(parameters, "(vi)", &payload, &conn_type);
+ g_variant_get(parameters, "(vi)", &payload, &connectivity_type);
- resource = _icl_remote_resource_from_gvariant(payload, conn_type);
+ resource = _icl_remote_resource_from_gvariant(payload, connectivity_type);
if (NULL == resource) {
ERR("icl_remote_resource_from_gvariant() Fail");
return;
cb(resource, IOTCON_ERROR_NONE, cb_container->user_data);
iotcon_remote_resource_destroy(resource);
-
- /* TODO
- * When is callback removed?
- */
}
static gboolean _icl_timeout_find_resource(gpointer p)
/* The length of resource_type should be less than or equal to 61.
* If resource_type is NULL, then All resources in host are discovered. */
-API int iotcon_find_resource(const char *host_address, const char *resource_type,
- iotcon_found_resource_cb cb, void *user_data)
+API int iotcon_find_resource(const char *host_address,
+ iotcon_connectivity_type_e connectivity_type,
+ const char *resource_type,
+ iotcon_found_resource_cb cb,
+ void *user_data)
{
unsigned int sub_id;
GError *error = NULL;
signal_number = icl_dbus_generate_signal_number();
- ic_dbus_call_find_resource_sync(icl_dbus_get_object(), host_address,
+ ic_dbus_call_find_resource_sync(icl_dbus_get_object(), host_address, connectivity_type,
ic_utils_dbus_encode_str(resource_type), signal_number, &ret, NULL, &error);
if (error) {
ERR("ic_dbus_call_find_resource_sync() Fail(%s)", error->message);
/* If you know the information of resource, then you can make a proxy of the resource. */
API int iotcon_remote_resource_create(const char *host,
+ iotcon_connectivity_type_e connectivity_type,
const char *uri_path,
bool is_observable,
iotcon_resource_types_h resource_types,
}
resource->host = ic_utils_strdup(host);
+ resource->connectivity_type = connectivity_type;
resource->uri_path = ic_utils_strdup(uri_path);
resource->is_observable = is_observable;
resource->types = icl_resource_types_ref(resource_types);
return IOTCON_FUNC_CONTINUE;
}
-API int iotcon_remote_resource_clone(iotcon_remote_resource_h src, iotcon_remote_resource_h *dest)
+API int iotcon_remote_resource_clone(iotcon_remote_resource_h src,
+ iotcon_remote_resource_h *dest)
{
int ret;
iotcon_remote_resource_h resource = NULL;
resource->uri_path = ic_utils_strdup(src->uri_path);
resource->host = ic_utils_strdup(src->host);
+ resource->connectivity_type = src->connectivity_type;
resource->device_id = ic_utils_strdup(src->device_id);
resource->is_secure = src->is_secure;
resource->is_observable = src->is_observable;
}
resource->ifaces = src->ifaces;
- resource->conn_type = src->conn_type;
+ resource->connectivity_type = src->connectivity_type;
*dest = resource;
/* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_uri_path(iotcon_remote_resource_h resource, char **uri_path)
+API int iotcon_remote_resource_get_uri_path(iotcon_remote_resource_h resource,
+ char **uri_path)
{
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == uri_path, IOTCON_ERROR_INVALID_PARAMETER);
/* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_host(iotcon_remote_resource_h resource, char **host)
+API int iotcon_remote_resource_get_host_address(iotcon_remote_resource_h resource,
+ char **host)
{
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == host, IOTCON_ERROR_INVALID_PARAMETER);
/* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_device_id(iotcon_remote_resource_h resource, char **device_id)
+API int iotcon_remote_resource_get_connectivity_type(iotcon_remote_resource_h resource,
+ int *connectivity_type)
+{
+ RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER);
+
+ *connectivity_type = resource->connectivity_type;
+
+ return IOTCON_ERROR_NONE;
+}
+
+
+/* The content of the resource should not be freed by user. */
+API int iotcon_remote_resource_get_device_id(iotcon_remote_resource_h resource,
+ char **device_id)
{
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == device_id, IOTCON_ERROR_INVALID_PARAMETER);
}
/* The content of the resource should not be freed by user. */
-API int iotcon_remote_resource_get_types(iotcon_remote_resource_h resource, iotcon_resource_types_h *types)
+API int iotcon_remote_resource_get_types(iotcon_remote_resource_h resource,
+ iotcon_resource_types_h *types)
{
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
}
-API int iotcon_remote_resource_get_interfaces(iotcon_remote_resource_h resource, int *ifaces)
+API int iotcon_remote_resource_get_interfaces(iotcon_remote_resource_h resource,
+ int *ifaces)
{
RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == ifaces, IOTCON_ERROR_INVALID_PARAMETER);
static iotcon_remote_resource_h _icl_remote_resource_from_gvariant(GVariant *payload,
- iotcon_connectivity_type_e conn_type)
+ iotcon_connectivity_type_e connectivity_type)
{
int ret;
iotcon_remote_resource_h resource;
g_variant_get(payload, "(&s&siasib&si)", &uri_path, &device_id, &ifaces, &types_iter,
&is_observable, &is_secure, &addr, &port);
- switch (conn_type) {
+ switch (connectivity_type) {
case IOTCON_CONNECTIVITY_IPV6:
snprintf(host_addr, sizeof(host_addr), "[%s]:%d", addr, port);
break;
while (g_variant_iter_loop(types_iter, "s", &res_type))
iotcon_resource_types_add(res_types, res_type);
- ret = iotcon_remote_resource_create(host_addr, uri_path, !!is_observable, res_types, ifaces,
- &resource);
+ ret = iotcon_remote_resource_create(host_addr, connectivity_type, uri_path,
+ !!is_observable, res_types, ifaces, &resource);
if (res_types)
iotcon_resource_types_destroy(res_types);
iotcon_remote_resource_destroy(resource);
return NULL;
}
- resource->conn_type = conn_type;
+ resource->connectivity_type = connectivity_type;
resource->is_secure = is_secure;
return resource;
iotcon_options_h header_options;
iotcon_resource_types_h types;
int ifaces;
- iotcon_connectivity_type_e conn_type;
+ iotcon_connectivity_type_e connectivity_type;
int64_t observe_handle;
unsigned int observe_sub_id;
icl_remote_resource_caching_h caching_handle;
}
+API int iotcon_request_get_connectivity_type(iotcon_request_h request,
+ int *connectivity_type)
+{
+ RETV_IF(NULL == request, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == connectivity_type, IOTCON_ERROR_INVALID_PARAMETER);
+
+ *connectivity_type = request->connectivity_type;
+
+ return IOTCON_ERROR_NONE;
+}
+
+
/* The content of the request should not be freed by user. */
API int iotcon_request_get_representation(iotcon_request_h request,
iotcon_representation_h *repr)
struct icl_resource_request {
char *host_address;
+ iotcon_connectivity_type_e connectivity_type;
int types;
iotcon_options_h header_options;
iotcon_query_h query;
iotcon_resource_h resource = user_data;
iotcon_request_handler_cb cb = resource->cb;
- g_variant_get(parameters, "(sia(qs)a(ss)iiavxx)",
+ g_variant_get(parameters, "(siia(qs)a(ss)iiavxx)",
&request.host_address,
+ &request.connectivity_type,
&request.types,
&options,
&query,
* @retval #IOTCON_ERROR_NONE Successful
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
- * @see iotcon_remote_resource_get_host()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_device_id()
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_interfaces()
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_remote_resource_get_uri_path()
+ * @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_device_id()
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_interfaces()
* @see iotcon_remote_resource_is_observable()
* @see iotcon_remote_resource_set_options()
*/
-int iotcon_remote_resource_get_host(iotcon_remote_resource_h resource, char **host);
+int iotcon_remote_resource_get_host_address(iotcon_remote_resource_h resource,
+ char **host);
+
+/**
+ * @brief Gets connectivity type of the remote resource
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] request The handle of the remote resource
+ * @param[out] connectivity_type The connectivity type of the remote resource
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+
+ * @see iotcon_remote_resource_get_uri_path()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_device_id()
+ * @see iotcon_remote_resource_get_types()
+ * @see iotcon_remote_resource_get_interfaces()
+ * @see iotcon_remote_resource_is_observable()
+ * @see iotcon_remote_resource_set_options()
+ */
+int iotcon_remote_resource_get_connectivity_type(iotcon_remote_resource_h resource,
+ int *connectivity_type);
/**
* @brief Gets an device id of the remote resource
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_remote_resource_get_uri_path()
- * @see iotcon_remote_resource_get_host()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_interfaces()
* @see iotcon_remote_resource_is_observable()
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_remote_resource_get_uri_path()
- * @see iotcon_remote_resource_get_host()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_device_id()
* @see iotcon_remote_resource_get_interfaces()
* @see iotcon_remote_resource_is_observable()
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_remote_resource_get_uri_path()
- * @see iotcon_remote_resource_get_host()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_device_id()
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_is_observable()
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_remote_resource_get_uri_path()
- * @see iotcon_remote_resource_get_host()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_device_id()
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_interfaces()
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_remote_resource_get_uri_path()
- * @see iotcon_remote_resource_get_host()
+ * @see iotcon_remote_resource_get_host_address()
+ * @see iotcon_remote_resource_get_connectivity_type()
* @see iotcon_remote_resource_get_device_id()
* @see iotcon_remote_resource_get_types()
* @see iotcon_remote_resource_get_interfaces()
* @retval #IOTCON_ERROR_NONE Successful
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
+ * @see iotcon_request_get_connectivity_type()
* @see iotcon_request_get_representation()
* @see iotcon_request_get_types()
* @see iotcon_request_get_options()
int iotcon_request_get_host_address(iotcon_request_h request,
char **host_address);
+/**
+ * @brief Gets connectivity type of the request
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in] request The handle of the request
+ * @param[out] connectivity_type The connectivity type of the request
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #IOTCON_ERROR_NONE Successful
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_representation()
+ * @see iotcon_request_get_types()
+ * @see iotcon_request_get_options()
+ * @see iotcon_request_get_query()
+ * @see iotcon_request_get_observer_action()
+ * @see iotcon_request_get_observer_id()
+ */
+int iotcon_request_get_connectivity_type(iotcon_request_h request,
+ int *connectivity_type);
/**
* @brief Gets an representation of the request
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_connectivity_type()
* @see iotcon_request_get_types()
* @see iotcon_request_get_options()
* @see iotcon_request_get_query()
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_connectivity_type()
* @see iotcon_request_get_representation()
* @see iotcon_request_get_options()
* @see iotcon_request_get_query()
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_connectivity_type()
* @see iotcon_request_get_representation()
* @see iotcon_request_get_types()
* @see iotcon_request_get_query()
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_connectivity_type()
* @see iotcon_request_get_representation()
* @see iotcon_request_get_types()
* @see iotcon_request_get_options()
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_connectivity_type()
* @see iotcon_request_get_representation()
* @see iotcon_request_get_types()
* @see iotcon_request_get_options()
* @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter
*
* @see iotcon_request_get_host_address()
+ * @see iotcon_request_get_connectivity_type()
* @see iotcon_request_get_representation()
* @see iotcon_request_get_types()
* @see iotcon_request_get_options()
* @privilege %http://tizen.org/privilege/internet
*
* @param[in] host_address The host address of remote server
+ * @param[in] connectivity_type The connectivity type
* @param[in] cb The callback function to invoke
* @param[in] user_data The user data to pass to the function
*
* @see iotcon_device_info_cb()
* @see iotcon_device_info_get_property()
*/
-int iotcon_get_device_info(const char *host_address, iotcon_device_info_cb cb,
+int iotcon_get_device_info(const char *host_address,
+ iotcon_connectivity_type_e connectivity_type,
+ iotcon_device_info_cb cb,
void *user_data);
/**
* @privilege %http://tizen.org/privilege/internet
*
* @param[in] host_address The host address of remote server
+ * @param[in] connectivity_type The connectivity type
* @param[in] cb The callback function to invoke
* @param[in] user_data The user data to pass to the function
*
* @see iotcon_platform_info_cb()
* @see iotcon_platform_info_get_property()
*/
-int iotcon_get_platform_info(const char *host_address, iotcon_platform_info_cb cb,
+int iotcon_get_platform_info(const char *host_address,
+ iotcon_connectivity_type_e connectivity_type,
+ iotcon_platform_info_cb cb,
void *user_data);
/**
* @privilege %http://tizen.org/privilege/internet
*
* @param[in] host_address The host address of remote server
+ * @param[in] connectivity_type The connectivity type
* @param[in] cb The callback function to invoke
* @param[in] user_data The user data to pass to the function
*
* @see iotcon_tizen_info_cb()
* @see iotcon_tizen_info_get_property()
*/
-int iotcon_get_tizen_info(const char *host_address, iotcon_tizen_info_cb cb,
+int iotcon_get_tizen_info(const char *host_address,
+ iotcon_connectivity_type_e connectivity_type,
+ iotcon_tizen_info_cb cb,
void *user_data);
/**
* @privilege %http://tizen.org/privilege/internet
*
* @param[in] host_address The address or addressable name of the server
+ * @param[in] connectivity_type The connectivity type
* @param[in] resource_type A resource type that a client has interested in
* @param[in] cb The callback function to invoke
* @param[in] user_data The user data to pass to the function
* @see iotcon_unsubscribe_presence()
* @see iotcon_presence_cb()
*/
-int iotcon_subscribe_presence(const char *host_address, const char *resource_type,
- iotcon_presence_cb cb, void *user_data, iotcon_presence_h *presence_handle);
+int iotcon_subscribe_presence(const char *host_address,
+ iotcon_connectivity_type_e connectivity_type,
+ const char *resource_type,
+ iotcon_presence_cb cb,
+ void *user_data,
+ iotcon_presence_h *presence_handle);
/**
* @brief Unsubscribes to a server's presence events.
* @privilege %http://tizen.org/privilege/internet
*
* @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] cb The callback function to invoke
* @param[in] user_data The user data to pass to the function
*
* @see iotcon_found_resource_cb()
*/
-int iotcon_find_resource(const char *host_address, const char *resource_type,
- iotcon_found_resource_cb cb, void *user_data);
+int iotcon_find_resource(const char *host_address,
+ iotcon_connectivity_type_e connectivity_type,
+ const char *resource_type,
+ iotcon_found_resource_cb cb,
+ void *user_data);
/**
* @brief Creates a new resource handle.
* @since_tizen 3.0
*
* @param[in] host The host address of the resource
+ * @param[in] connectivity_type The connectivity type
* @param[in] uri_path The URI path of the resource.
* @param[in] is_observable Allow observation
* @param[in] resource_types The resource type of the resource. For example, "core.light"
* @see iotcon_remote_resource_clone()
*/
int iotcon_remote_resource_create(const char *host,
+ iotcon_connectivity_type_e connectivity_type,
const char *uri_path,
bool is_observable,
iotcon_resource_types_h resource_types,
* @see iotcon_remote_resource_create()
* @see iotcon_remote_resource_destroy()
*/
-int iotcon_remote_resource_clone(iotcon_remote_resource_h src, iotcon_remote_resource_h *dest);
+int iotcon_remote_resource_clone(iotcon_remote_resource_h src,
+ iotcon_remote_resource_h *dest);
/**
* @brief Specifies the type of function passed to iotcon_remote_resource_observer_start().
static void _on_post(iotcon_remote_resource_h resource, iotcon_representation_h recv_repr,
iotcon_options_h header_options, int response_result, void *user_data)
{
- int ret, ifaces = 0;
iotcon_state_h recv_state;
char *host, *created_uri_path;
+ int ret, connectivity_type, ifaces = 0;
iotcon_resource_types_h types = NULL;
iotcon_remote_resource_h new_door_resource, door_resource;
}
DBG("New resource created : %s", created_uri_path);
- ret = iotcon_remote_resource_get_host(resource, &host);
+ ret = iotcon_remote_resource_get_host_address(resource, &host);
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_remote_resource_get_host() Fail(%d)", ret);
+ ERR("iotcon_remote_resource_get_host_address() Fail(%d)", ret);
+ return;
+ }
+
+ ret = iotcon_remote_resource_get_connectivity_type(resource, &connectivity_type);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_remote_resource_get_connectivity_type() Fail(%d)", ret);
return;
}
return;
}
- ret = iotcon_remote_resource_create(host, created_uri_path, true, types, ifaces,
- &new_door_resource);
+ ret = iotcon_remote_resource_create(host, connectivity_type, created_uri_path, true,
+ types, ifaces, &new_door_resource);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_remote_resource_create() Fail(%d)", ret);
return;
INFO("- Tizen Device ID : %s", tizen_device_id);
}
-static void _found_resource(iotcon_remote_resource_h resource, int result, void *user_data)
+static void _found_resource(iotcon_remote_resource_h resource, int result,
+ void *user_data)
{
GList *node;
char *resource_host;
char *resource_uri_path;
char *resource_device_id;
- int ret, resource_interfaces;
iotcon_presence_h presence_handle;
iotcon_resource_types_h resource_types;
+ int ret, resource_interfaces, connectivity_type;
iotcon_remote_resource_h resource_clone = NULL;
RETM_IF(IOTCON_ERROR_NONE != result, "Invalid result(%d)", result);
device_id_list = g_list_append(device_id_list, door_resource_device_id);
/* get the resource host address */
- ret = iotcon_remote_resource_get_host(resource, &resource_host);
+ ret = iotcon_remote_resource_get_host_address(resource, &resource_host);
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_remote_resource_get_host() Fail(%d)", ret);
+ ERR("iotcon_remote_resource_get_host_address() Fail(%d)", ret);
device_id_list = g_list_remove(device_id_list, door_resource_device_id);
free(door_resource_device_id);
return;
}
DBG("[%s] resource host : %s", resource_uri_path, resource_host);
+ ret = iotcon_remote_resource_get_connectivity_type(resource, &connectivity_type);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_remote_resource_get_connectivity_type() Fail(%d)", ret);
+ device_id_list = g_list_remove(device_id_list, door_resource_device_id);
+ free(door_resource_device_id);
+ return;
+ }
+
/* get the resource interfaces */
ret = iotcon_remote_resource_get_interfaces(resource, &resource_interfaces);
if (IOTCON_ERROR_NONE != ret) {
}
/* get tizen info */
- ret = iotcon_get_tizen_info(resource_host, _get_tizen_info, NULL);
+ ret = iotcon_get_tizen_info(resource_host, connectivity_type, _get_tizen_info, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_get_tizen_info() Fail(%d)", ret);
device_id_list = g_list_remove(device_id_list, door_resource_device_id);
return;
}
- ret = iotcon_subscribe_presence(resource_host, "core.door", _presence_handler, NULL,
- &presence_handle);
+ ret = iotcon_subscribe_presence(resource_host, connectivity_type, "core.door",
+ _presence_handler, NULL, &presence_handle);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_subscribe_presence() Fail(%d)", ret);
device_id_list = g_list_remove(device_id_list, door_resource_device_id);
}
/* find door typed resources */
- ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, "core.door", &_found_resource,
- NULL);
+ ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
+ "core.door", &_found_resource, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_resource() Fail(%d)", ret);
iotcon_close();
return;
}
-
if (IOTCON_OBSERVE_REGISTER == observer_action) {
ret = iotcon_request_get_observer_id(request, &observer_id);
if (IOTCON_ERROR_NONE != ret) {
return -1;
}
- ret = iotcon_get_device_info(IOTCON_MULTICAST_ADDRESS, _get_device_info, NULL);
+ ret = iotcon_get_device_info(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
+ _get_device_info, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_get_device_info() Fail(%d)", ret);
iotcon_close();
return -1;
}
- ret = iotcon_get_platform_info(IOTCON_MULTICAST_ADDRESS, _get_platform_info, NULL);
+ ret = iotcon_get_platform_info(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
+ _get_platform_info, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_get_platform_info() Fail(%d)", ret);
iotcon_close();
}
/* get the resource host address */
- ret = iotcon_remote_resource_get_host(resource, &resource_host);
+ ret = iotcon_remote_resource_get_host_address(resource, &resource_host);
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_remote_resource_get_host() Fail(%d)", ret);
+ ERR("iotcon_remote_resource_get_host_address() Fail(%d)", ret);
device_id_list = g_list_remove(device_id_list, door_resource_device_id);
free(door_resource_device_id);
return;
}
/* find door typed resources */
- ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, "core.door", &_found_resource,
- &resource);
+ ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
+ "core.door", &_found_resource, &resource);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_resource() Fail(%d)", ret);
iotcon_close();
void *user_data)
{
_on_get(recv_repr, response_result);
+
+ iotcon_remote_resource_destroy(resource);
}
static void _on_get_1st(iotcon_remote_resource_h resource,
return strcmp(a, b);
}
-static void _found_resource(iotcon_remote_resource_h resource, int result, void *user_data)
+static void _found_resource(iotcon_remote_resource_h resource, int result,
+ void *user_data)
{
GList *node;
char *resource_host;
char *resource_device_id;
int ret, resource_interfaces;
iotcon_resource_types_h resource_types;
+ iotcon_remote_resource_h cloned_resource;
RETM_IF(IOTCON_ERROR_NONE != result, "Invalid result(%d)", result);
device_id_list = g_list_append(device_id_list, room_resource_device_id);
/* get the resource host address */
- ret = iotcon_remote_resource_get_host(resource, &resource_host);
+ ret = iotcon_remote_resource_get_host_address(resource, &resource_host);
if (IOTCON_ERROR_NONE != ret) {
- ERR("iotcon_remote_resource_get_host() Fail(%d)", ret);
+ ERR("iotcon_remote_resource_get_host_address() Fail(%d)", ret);
device_id_list = g_list_remove(device_id_list, room_resource_device_id);
free(room_resource_device_id);
return;
}
if (TEST_STR_EQUAL == strcmp(room_uri_path, resource_uri_path)) {
+ ret = iotcon_remote_resource_clone(resource, &cloned_resource);
+ if (IOTCON_ERROR_NONE != ret) {
+ ERR("iotcon_remote_resource_clone() Fail(%d)", ret);
+ device_id_list = g_list_remove(device_id_list, room_resource_device_id);
+ free(room_resource_device_id);
+ return;
+ }
+
/* send GET request */
- ret = iotcon_remote_resource_get(resource, NULL, _on_get_1st, NULL);
+ ret = iotcon_remote_resource_get(cloned_resource, NULL, _on_get_1st, NULL);
if (IOTCON_ERROR_NONE != ret)
ERR("iotcon_remote_resource_get() Fail(%d)", ret);
}
}
/* find room typed resources */
- ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, "core.room", &_found_resource,
- NULL);
+ ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_IPV4,
+ "core.room", &_found_resource, NULL);
if (IOTCON_ERROR_NONE != ret) {
ERR("iotcon_find_resource() Fail(%d)", ret);
iotcon_close();